[clang] NFC: remove carriage return from AST tests

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D112372
This commit is contained in:
Matheus Izvekov 2021-10-24 00:44:17 +02:00
parent 8dbbe3356b
commit 32d45862fc
No known key found for this signature in database
GPG Key ID: 5C771D2BB8AB9907
8 changed files with 2155 additions and 2155 deletions

View File

@ -1,261 +1,261 @@
// Test without serialization:
// RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++11 -Wno-deprecated-declarations -ast-dump -ast-dump-filter Test %s \
// RUN: | FileCheck --strict-whitespace %s
//
// Test with serialization:
// RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++11 -Wno-deprecated-declarations -emit-pch -o %t %s
// RUN: %clang_cc1 -x c++ -triple x86_64-pc-linux -std=c++11 -Wno-deprecated-declarations \
// RUN: -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
// RUN: | FileCheck --strict-whitespace %s
int TestLocation
__attribute__((unused));
// CHECK: VarDecl{{.*}}TestLocation
// CHECK-NEXT: UnusedAttr 0x{{[^ ]*}} <line:[[@LINE-2]]:16>
int TestIndent
__attribute__((unused));
// CHECK: {{^}}VarDecl{{.*TestIndent[^()]*$}}
// CHECK-NEXT: {{^}}`-UnusedAttr{{[^()]*$}}
void TestAttributedStmt() {
switch (1) {
case 1:
[[clang::fallthrough]];
case 2:
;
}
}
// CHECK: FunctionDecl{{.*}}TestAttributedStmt
// CHECK: AttributedStmt
// CHECK-NEXT: FallThroughAttr
// CHECK-NEXT: NullStmt
[[clang::warn_unused_result]] int TestCXX11DeclAttr();
// CHECK: FunctionDecl{{.*}}TestCXX11DeclAttr
// CHECK-NEXT: WarnUnusedResultAttr
int TestAlignedNull __attribute__((aligned));
// CHECK: VarDecl{{.*}}TestAlignedNull
// CHECK-NEXT: AlignedAttr {{.*}} aligned
// CHECK-NEXT: <<<NULL>>>
int TestAlignedExpr __attribute__((aligned(4)));
// CHECK: VarDecl{{.*}}TestAlignedExpr
// CHECK-NEXT: AlignedAttr {{.*}} aligned
// CHECK-NEXT: ConstantExpr
// CHECK-NEXT: value: Int 4
// CHECK-NEXT: IntegerLiteral
int TestEnum __attribute__((visibility("default")));
// CHECK: VarDecl{{.*}}TestEnum
// CHECK-NEXT: VisibilityAttr{{.*}} Default
class __attribute__((lockable)) Mutex {
} mu1, mu2;
int TestExpr __attribute__((guarded_by(mu1)));
// CHECK: VarDecl{{.*}}TestExpr
// CHECK-NEXT: GuardedByAttr
// CHECK-NEXT: DeclRefExpr{{.*}}mu1
class Mutex TestVariadicExpr __attribute__((acquired_after(mu1, mu2)));
// CHECK: VarDecl{{.*}}TestVariadicExpr
// CHECK: AcquiredAfterAttr
// CHECK-NEXT: DeclRefExpr{{.*}}mu1
// CHECK-NEXT: DeclRefExpr{{.*}}mu2
void function1(void *) {
int TestFunction __attribute__((cleanup(function1)));
}
// CHECK: VarDecl{{.*}}TestFunction
// CHECK-NEXT: CleanupAttr{{.*}} Function{{.*}}function1
void TestIdentifier(void *, int)
__attribute__((pointer_with_type_tag(ident1,1,2)));
// CHECK: FunctionDecl{{.*}}TestIdentifier
// CHECK: ArgumentWithTypeTagAttr{{.*}} pointer_with_type_tag ident1
void TestBool(void *, int)
__attribute__((pointer_with_type_tag(bool1,1,2)));
// CHECK: FunctionDecl{{.*}}TestBool
// CHECK: ArgumentWithTypeTagAttr{{.*}}pointer_with_type_tag bool1 1 2 IsPointer
void TestUnsigned(void *, int)
__attribute__((pointer_with_type_tag(unsigned1,1,2)));
// CHECK: FunctionDecl{{.*}}TestUnsigned
// CHECK: ArgumentWithTypeTagAttr{{.*}} pointer_with_type_tag unsigned1 1 2
void TestInt(void) __attribute__((constructor(123)));
// CHECK: FunctionDecl{{.*}}TestInt
// CHECK-NEXT: ConstructorAttr{{.*}} 123
static int TestString __attribute__((alias("alias1")));
// CHECK: VarDecl{{.*}}TestString
// CHECK-NEXT: AliasAttr{{.*}} "alias1"
extern struct s1 TestType
__attribute__((type_tag_for_datatype(ident1,int)));
// CHECK: VarDecl{{.*}}TestType
// CHECK-NEXT: TypeTagForDatatypeAttr{{.*}} int
void TestLabel() {
L: __attribute__((unused)) int i;
// CHECK: LabelStmt{{.*}}'L'
// CHECK: VarDecl{{.*}}i 'int'
// CHECK-NEXT: UnusedAttr{{.*}}
M: __attribute(()) int j;
// CHECK: LabelStmt {{.*}} 'M'
// CHECK-NEXT: DeclStmt
// CHECK-NEXT: VarDecl {{.*}} j 'int'
N: __attribute(()) ;
// CHECK: LabelStmt {{.*}} 'N'
// CHECK-NEXT: NullStmt
}
namespace Test {
extern "C" int printf(const char *format, ...);
// CHECK: FunctionDecl{{.*}}printf
// CHECK-NEXT: ParmVarDecl{{.*}}format{{.*}}'const char *'
// CHECK-NEXT: BuiltinAttr{{.*}}Implicit
// CHECK-NEXT: FormatAttr{{.*}}Implicit printf 1 2
alignas(8) extern int x;
extern int x;
// CHECK: VarDecl{{.*}} x 'int'
// CHECK: VarDecl{{.*}} x 'int'
// CHECK-NEXT: AlignedAttr{{.*}} Inherited
}
int __attribute__((cdecl)) TestOne(void), TestTwo(void);
// CHECK: FunctionDecl{{.*}}TestOne{{.*}}__attribute__((cdecl))
// CHECK: FunctionDecl{{.*}}TestTwo{{.*}}__attribute__((cdecl))
void func() {
auto Test = []() __attribute__((no_thread_safety_analysis)) {};
// CHECK: CXXMethodDecl{{.*}}operator() 'void () const'
// CHECK: NoThreadSafetyAnalysisAttr
// Because GNU's noreturn applies to the function type, and this lambda does
// not have a capture list, the call operator and the function pointer
// conversion should both be noreturn, but the method should not contain a
// NoReturnAttr because the attribute applied to the type.
auto Test2 = []() __attribute__((noreturn)) { while(1); };
// CHECK: CXXMethodDecl{{.*}}operator() 'void () __attribute__((noreturn)) const'
// CHECK-NOT: NoReturnAttr
// CHECK: CXXConversionDecl{{.*}}operator void (*)() __attribute__((noreturn))
}
namespace PR20930 {
struct S {
struct { int Test __attribute__((deprecated)); };
// CHECK: FieldDecl{{.*}}Test 'int'
// CHECK-NEXT: DeprecatedAttr
};
void f() {
S s;
s.Test = 1;
// CHECK: IndirectFieldDecl{{.*}}Test 'int'
// CHECK: DeprecatedAttr
}
}
struct __attribute__((objc_bridge_related(NSParagraphStyle,,))) TestBridgedRef;
// CHECK: CXXRecordDecl{{.*}} struct TestBridgedRef
// CHECK-NEXT: ObjCBridgeRelatedAttr{{.*}} NSParagraphStyle
void TestExternalSourceSymbolAttr1()
__attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration)));
// CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr1
// CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Swift" "module" GeneratedDeclaration
void TestExternalSourceSymbolAttr2()
__attribute__((external_source_symbol(defined_in="module", language="Swift")));
// CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr2
// CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Swift" "module"{{$}}
void TestExternalSourceSymbolAttr3()
__attribute__((external_source_symbol(generated_declaration, language="Objective-C++", defined_in="module")));
// CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr3
// CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Objective-C++" "module" GeneratedDeclaration
void TestExternalSourceSymbolAttr4()
__attribute__((external_source_symbol(defined_in="Some external file.cs", generated_declaration, language="C Sharp")));
// CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr4
// CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "C Sharp" "Some external file.cs" GeneratedDeclaration
void TestExternalSourceSymbolAttr5()
__attribute__((external_source_symbol(generated_declaration, defined_in="module", language="Swift")));
// CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr5
// CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Swift" "module" GeneratedDeclaration
namespace TestNoEscape {
void noescapeFunc(int *p0, __attribute__((noescape)) int *p1) {}
// CHECK: `-FunctionDecl{{.*}} noescapeFunc 'void (int *, __attribute__((noescape)) int *)'
// CHECK-NEXT: ParmVarDecl
// CHECK-NEXT: ParmVarDecl
// CHECK-NEXT: NoEscapeAttr
}
namespace TestSuppress {
[[gsl::suppress("at-namespace")]];
// CHECK: NamespaceDecl{{.*}} TestSuppress
// CHECK-NEXT: EmptyDecl{{.*}}
// CHECK-NEXT: SuppressAttr{{.*}} at-namespace
[[gsl::suppress("on-decl")]]
void TestSuppressFunction();
// CHECK: FunctionDecl{{.*}} TestSuppressFunction
// CHECK-NEXT: SuppressAttr{{.*}} on-decl
void f() {
int *i;
[[gsl::suppress("on-stmt")]] {
// CHECK: AttributedStmt
// CHECK-NEXT: SuppressAttr{{.*}} on-stmt
// CHECK-NEXT: CompoundStmt
i = reinterpret_cast<int*>(7);
}
}
}
namespace TestLifetimeCategories {
class [[gsl::Owner(int)]] AOwner{};
// CHECK: CXXRecordDecl{{.*}} class AOwner
// CHECK: OwnerAttr {{.*}} int
class [[gsl::Pointer(int)]] APointer{};
// CHECK: CXXRecordDecl{{.*}} class APointer
// CHECK: PointerAttr {{.*}} int
class [[gsl::Pointer]] PointerWithoutArgument{};
// CHECK: CXXRecordDecl{{.*}} class PointerWithoutArgument
// CHECK: PointerAttr
class [[gsl::Owner]] OwnerWithoutArgument{};
// CHECK: CXXRecordDecl{{.*}} class OwnerWithoutArgument
// CHECK: OwnerAttr
} // namespace TestLifetimeCategories
// Verify the order of attributes in the Ast. It must reflect the order
// in the parsed source.
int mergeAttrTest() __attribute__((deprecated)) __attribute__((warn_unused_result));
int mergeAttrTest() __attribute__((annotate("test")));
int mergeAttrTest() __attribute__((unused,no_thread_safety_analysis));
// CHECK: FunctionDecl{{.*}} mergeAttrTest
// CHECK-NEXT: DeprecatedAttr
// CHECK-NEXT: WarnUnusedResultAttr
// CHECK: FunctionDecl{{.*}} mergeAttrTest
// CHECK-NEXT: DeprecatedAttr{{.*}} Inherited
// CHECK-NEXT: WarnUnusedResultAttr{{.*}} Inherited
// CHECK-NEXT: AnnotateAttr{{.*}}
// CHECK: FunctionDecl{{.*}} mergeAttrTest
// CHECK-NEXT: DeprecatedAttr{{.*}} Inherited
// CHECK-NEXT: WarnUnusedResultAttr{{.*}} Inherited
// CHECK-NEXT: AnnotateAttr{{.*}} Inherited
// CHECK-NEXT: UnusedAttr
// CHECK-NEXT: NoThreadSafetyAnalysisAttr
// Test without serialization:
// RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++11 -Wno-deprecated-declarations -ast-dump -ast-dump-filter Test %s \
// RUN: | FileCheck --strict-whitespace %s
//
// Test with serialization:
// RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++11 -Wno-deprecated-declarations -emit-pch -o %t %s
// RUN: %clang_cc1 -x c++ -triple x86_64-pc-linux -std=c++11 -Wno-deprecated-declarations \
// RUN: -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
// RUN: | FileCheck --strict-whitespace %s
int TestLocation
__attribute__((unused));
// CHECK: VarDecl{{.*}}TestLocation
// CHECK-NEXT: UnusedAttr 0x{{[^ ]*}} <line:[[@LINE-2]]:16>
int TestIndent
__attribute__((unused));
// CHECK: {{^}}VarDecl{{.*TestIndent[^()]*$}}
// CHECK-NEXT: {{^}}`-UnusedAttr{{[^()]*$}}
void TestAttributedStmt() {
switch (1) {
case 1:
[[clang::fallthrough]];
case 2:
;
}
}
// CHECK: FunctionDecl{{.*}}TestAttributedStmt
// CHECK: AttributedStmt
// CHECK-NEXT: FallThroughAttr
// CHECK-NEXT: NullStmt
[[clang::warn_unused_result]] int TestCXX11DeclAttr();
// CHECK: FunctionDecl{{.*}}TestCXX11DeclAttr
// CHECK-NEXT: WarnUnusedResultAttr
int TestAlignedNull __attribute__((aligned));
// CHECK: VarDecl{{.*}}TestAlignedNull
// CHECK-NEXT: AlignedAttr {{.*}} aligned
// CHECK-NEXT: <<<NULL>>>
int TestAlignedExpr __attribute__((aligned(4)));
// CHECK: VarDecl{{.*}}TestAlignedExpr
// CHECK-NEXT: AlignedAttr {{.*}} aligned
// CHECK-NEXT: ConstantExpr
// CHECK-NEXT: value: Int 4
// CHECK-NEXT: IntegerLiteral
int TestEnum __attribute__((visibility("default")));
// CHECK: VarDecl{{.*}}TestEnum
// CHECK-NEXT: VisibilityAttr{{.*}} Default
class __attribute__((lockable)) Mutex {
} mu1, mu2;
int TestExpr __attribute__((guarded_by(mu1)));
// CHECK: VarDecl{{.*}}TestExpr
// CHECK-NEXT: GuardedByAttr
// CHECK-NEXT: DeclRefExpr{{.*}}mu1
class Mutex TestVariadicExpr __attribute__((acquired_after(mu1, mu2)));
// CHECK: VarDecl{{.*}}TestVariadicExpr
// CHECK: AcquiredAfterAttr
// CHECK-NEXT: DeclRefExpr{{.*}}mu1
// CHECK-NEXT: DeclRefExpr{{.*}}mu2
void function1(void *) {
int TestFunction __attribute__((cleanup(function1)));
}
// CHECK: VarDecl{{.*}}TestFunction
// CHECK-NEXT: CleanupAttr{{.*}} Function{{.*}}function1
void TestIdentifier(void *, int)
__attribute__((pointer_with_type_tag(ident1,1,2)));
// CHECK: FunctionDecl{{.*}}TestIdentifier
// CHECK: ArgumentWithTypeTagAttr{{.*}} pointer_with_type_tag ident1
void TestBool(void *, int)
__attribute__((pointer_with_type_tag(bool1,1,2)));
// CHECK: FunctionDecl{{.*}}TestBool
// CHECK: ArgumentWithTypeTagAttr{{.*}}pointer_with_type_tag bool1 1 2 IsPointer
void TestUnsigned(void *, int)
__attribute__((pointer_with_type_tag(unsigned1,1,2)));
// CHECK: FunctionDecl{{.*}}TestUnsigned
// CHECK: ArgumentWithTypeTagAttr{{.*}} pointer_with_type_tag unsigned1 1 2
void TestInt(void) __attribute__((constructor(123)));
// CHECK: FunctionDecl{{.*}}TestInt
// CHECK-NEXT: ConstructorAttr{{.*}} 123
static int TestString __attribute__((alias("alias1")));
// CHECK: VarDecl{{.*}}TestString
// CHECK-NEXT: AliasAttr{{.*}} "alias1"
extern struct s1 TestType
__attribute__((type_tag_for_datatype(ident1,int)));
// CHECK: VarDecl{{.*}}TestType
// CHECK-NEXT: TypeTagForDatatypeAttr{{.*}} int
void TestLabel() {
L: __attribute__((unused)) int i;
// CHECK: LabelStmt{{.*}}'L'
// CHECK: VarDecl{{.*}}i 'int'
// CHECK-NEXT: UnusedAttr{{.*}}
M: __attribute(()) int j;
// CHECK: LabelStmt {{.*}} 'M'
// CHECK-NEXT: DeclStmt
// CHECK-NEXT: VarDecl {{.*}} j 'int'
N: __attribute(()) ;
// CHECK: LabelStmt {{.*}} 'N'
// CHECK-NEXT: NullStmt
}
namespace Test {
extern "C" int printf(const char *format, ...);
// CHECK: FunctionDecl{{.*}}printf
// CHECK-NEXT: ParmVarDecl{{.*}}format{{.*}}'const char *'
// CHECK-NEXT: BuiltinAttr{{.*}}Implicit
// CHECK-NEXT: FormatAttr{{.*}}Implicit printf 1 2
alignas(8) extern int x;
extern int x;
// CHECK: VarDecl{{.*}} x 'int'
// CHECK: VarDecl{{.*}} x 'int'
// CHECK-NEXT: AlignedAttr{{.*}} Inherited
}
int __attribute__((cdecl)) TestOne(void), TestTwo(void);
// CHECK: FunctionDecl{{.*}}TestOne{{.*}}__attribute__((cdecl))
// CHECK: FunctionDecl{{.*}}TestTwo{{.*}}__attribute__((cdecl))
void func() {
auto Test = []() __attribute__((no_thread_safety_analysis)) {};
// CHECK: CXXMethodDecl{{.*}}operator() 'void () const'
// CHECK: NoThreadSafetyAnalysisAttr
// Because GNU's noreturn applies to the function type, and this lambda does
// not have a capture list, the call operator and the function pointer
// conversion should both be noreturn, but the method should not contain a
// NoReturnAttr because the attribute applied to the type.
auto Test2 = []() __attribute__((noreturn)) { while(1); };
// CHECK: CXXMethodDecl{{.*}}operator() 'void () __attribute__((noreturn)) const'
// CHECK-NOT: NoReturnAttr
// CHECK: CXXConversionDecl{{.*}}operator void (*)() __attribute__((noreturn))
}
namespace PR20930 {
struct S {
struct { int Test __attribute__((deprecated)); };
// CHECK: FieldDecl{{.*}}Test 'int'
// CHECK-NEXT: DeprecatedAttr
};
void f() {
S s;
s.Test = 1;
// CHECK: IndirectFieldDecl{{.*}}Test 'int'
// CHECK: DeprecatedAttr
}
}
struct __attribute__((objc_bridge_related(NSParagraphStyle,,))) TestBridgedRef;
// CHECK: CXXRecordDecl{{.*}} struct TestBridgedRef
// CHECK-NEXT: ObjCBridgeRelatedAttr{{.*}} NSParagraphStyle
void TestExternalSourceSymbolAttr1()
__attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration)));
// CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr1
// CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Swift" "module" GeneratedDeclaration
void TestExternalSourceSymbolAttr2()
__attribute__((external_source_symbol(defined_in="module", language="Swift")));
// CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr2
// CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Swift" "module"{{$}}
void TestExternalSourceSymbolAttr3()
__attribute__((external_source_symbol(generated_declaration, language="Objective-C++", defined_in="module")));
// CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr3
// CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Objective-C++" "module" GeneratedDeclaration
void TestExternalSourceSymbolAttr4()
__attribute__((external_source_symbol(defined_in="Some external file.cs", generated_declaration, language="C Sharp")));
// CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr4
// CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "C Sharp" "Some external file.cs" GeneratedDeclaration
void TestExternalSourceSymbolAttr5()
__attribute__((external_source_symbol(generated_declaration, defined_in="module", language="Swift")));
// CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr5
// CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Swift" "module" GeneratedDeclaration
namespace TestNoEscape {
void noescapeFunc(int *p0, __attribute__((noescape)) int *p1) {}
// CHECK: `-FunctionDecl{{.*}} noescapeFunc 'void (int *, __attribute__((noescape)) int *)'
// CHECK-NEXT: ParmVarDecl
// CHECK-NEXT: ParmVarDecl
// CHECK-NEXT: NoEscapeAttr
}
namespace TestSuppress {
[[gsl::suppress("at-namespace")]];
// CHECK: NamespaceDecl{{.*}} TestSuppress
// CHECK-NEXT: EmptyDecl{{.*}}
// CHECK-NEXT: SuppressAttr{{.*}} at-namespace
[[gsl::suppress("on-decl")]]
void TestSuppressFunction();
// CHECK: FunctionDecl{{.*}} TestSuppressFunction
// CHECK-NEXT: SuppressAttr{{.*}} on-decl
void f() {
int *i;
[[gsl::suppress("on-stmt")]] {
// CHECK: AttributedStmt
// CHECK-NEXT: SuppressAttr{{.*}} on-stmt
// CHECK-NEXT: CompoundStmt
i = reinterpret_cast<int*>(7);
}
}
}
namespace TestLifetimeCategories {
class [[gsl::Owner(int)]] AOwner{};
// CHECK: CXXRecordDecl{{.*}} class AOwner
// CHECK: OwnerAttr {{.*}} int
class [[gsl::Pointer(int)]] APointer{};
// CHECK: CXXRecordDecl{{.*}} class APointer
// CHECK: PointerAttr {{.*}} int
class [[gsl::Pointer]] PointerWithoutArgument{};
// CHECK: CXXRecordDecl{{.*}} class PointerWithoutArgument
// CHECK: PointerAttr
class [[gsl::Owner]] OwnerWithoutArgument{};
// CHECK: CXXRecordDecl{{.*}} class OwnerWithoutArgument
// CHECK: OwnerAttr
} // namespace TestLifetimeCategories
// Verify the order of attributes in the Ast. It must reflect the order
// in the parsed source.
int mergeAttrTest() __attribute__((deprecated)) __attribute__((warn_unused_result));
int mergeAttrTest() __attribute__((annotate("test")));
int mergeAttrTest() __attribute__((unused,no_thread_safety_analysis));
// CHECK: FunctionDecl{{.*}} mergeAttrTest
// CHECK-NEXT: DeprecatedAttr
// CHECK-NEXT: WarnUnusedResultAttr
// CHECK: FunctionDecl{{.*}} mergeAttrTest
// CHECK-NEXT: DeprecatedAttr{{.*}} Inherited
// CHECK-NEXT: WarnUnusedResultAttr{{.*}} Inherited
// CHECK-NEXT: AnnotateAttr{{.*}}
// CHECK: FunctionDecl{{.*}} mergeAttrTest
// CHECK-NEXT: DeprecatedAttr{{.*}} Inherited
// CHECK-NEXT: WarnUnusedResultAttr{{.*}} Inherited
// CHECK-NEXT: AnnotateAttr{{.*}} Inherited
// CHECK-NEXT: UnusedAttr
// CHECK-NEXT: NoThreadSafetyAnalysisAttr

View File

@ -1,68 +1,68 @@
// Test without serialization:
// RUN: %clang_cc1 -fdouble-square-bracket-attributes -triple x86_64-apple-macosx10.10.0 \
// RUN: -ast-dump -ast-dump-filter Test %s \
// RUN: | FileCheck --strict-whitespace %s
//
// Test with serialization:
// RUN: %clang_cc1 -fdouble-square-bracket-attributes -triple x86_64-apple-macosx10.10.0 \
// RUN: -emit-pch -o %t %s
// RUN: %clang_cc1 -x objective-c -fdouble-square-bracket-attributes -triple x86_64-apple-macosx10.10.0 \
// RUN: -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
// RUN: | FileCheck --strict-whitespace %s
@interface NSObject
@end
[[clang::objc_exception]]
@interface Test1 {
// CHECK: ObjCInterfaceDecl{{.*}} Test1
// CHECK-NEXT: ObjCExceptionAttr{{.*}}
[[clang::iboutlet]] NSObject *Test2;
// CHECK: ObjCIvarDecl{{.*}} Test2
// CHECK-NEXT: IBOutletAttr
}
@property (readonly) [[clang::objc_returns_inner_pointer]] void *Test3, *Test4;
// CHECK: ObjCPropertyDecl{{.*}} Test3 'void *' readonly
// CHECK-NEXT: ObjCReturnsInnerPointerAttr
// CHECK-NEXT: ObjCPropertyDecl{{.*}} Test4 'void *' readonly
// CHECK-NEXT: ObjCReturnsInnerPointerAttr
@property (readonly) [[clang::iboutlet]] NSObject *Test5;
// CHECK: ObjCPropertyDecl{{.*}} Test5 'NSObject *' readonly
// CHECK-NEXT: IBOutletAttr
// CHECK: ObjCMethodDecl{{.*}} implicit{{.*}} Test3
// CHECK-NEXT: ObjCReturnsInnerPointerAttr
// CHECK: ObjCMethodDecl{{.*}} implicit{{.*}} Test4
// CHECK-NEXT: ObjCReturnsInnerPointerAttr
// CHECK: ObjCMethodDecl{{.*}} implicit{{.*}} Test5
// CHECK-NOT: IBOutletAttr
@end
[[clang::objc_runtime_name("name")]] @protocol Test6;
// CHECK: ObjCProtocolDecl{{.*}} Test6
// CHECK-NEXT: ObjCRuntimeNameAttr{{.*}} "name"
[[clang::objc_protocol_requires_explicit_implementation]]
@protocol Test7
// CHECK: ObjCProtocolDecl{{.*}} Test7
// CHECK-NEXT: ObjCExplicitProtocolImplAttr
@end
@interface Test8
// CHECK: ObjCInterfaceDecl{{.*}} Test8
-(void)Test9 [[clang::ns_consumes_self]];
// CHECK: ObjCMethodDecl{{.*}} Test9 'void'
// CHECK-NEXT: NSConsumesSelfAttr
-(void) [[clang::ns_consumes_self]] Test10: (int)Test11;
// CHECK: ObjCMethodDecl{{.*}} Test10: 'void'
// CHECK-NEXT: |-ParmVarDecl{{.*}} Test11 'int'
// CHECK-NEXT: `-NSConsumesSelfAttr
-(void)Test12: (int *) [[clang::noescape]] Test13 to:(int)Test14 [[clang::ns_consumes_self]];
// CHECK: ObjCMethodDecl{{.*}} Test12:to: 'void'
// CHECK-NEXT: |-ParmVarDecl{{.*}} Test13 'int *'
// CHECK-NEXT: | `-NoEscapeAttr
// CHECK-NEXT: |-ParmVarDecl{{.*}} Test14 'int'
// CHECK-NEXT: `-NSConsumesSelfAttr
@end
// Test without serialization:
// RUN: %clang_cc1 -fdouble-square-bracket-attributes -triple x86_64-apple-macosx10.10.0 \
// RUN: -ast-dump -ast-dump-filter Test %s \
// RUN: | FileCheck --strict-whitespace %s
//
// Test with serialization:
// RUN: %clang_cc1 -fdouble-square-bracket-attributes -triple x86_64-apple-macosx10.10.0 \
// RUN: -emit-pch -o %t %s
// RUN: %clang_cc1 -x objective-c -fdouble-square-bracket-attributes -triple x86_64-apple-macosx10.10.0 \
// RUN: -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
// RUN: | FileCheck --strict-whitespace %s
@interface NSObject
@end
[[clang::objc_exception]]
@interface Test1 {
// CHECK: ObjCInterfaceDecl{{.*}} Test1
// CHECK-NEXT: ObjCExceptionAttr{{.*}}
[[clang::iboutlet]] NSObject *Test2;
// CHECK: ObjCIvarDecl{{.*}} Test2
// CHECK-NEXT: IBOutletAttr
}
@property (readonly) [[clang::objc_returns_inner_pointer]] void *Test3, *Test4;
// CHECK: ObjCPropertyDecl{{.*}} Test3 'void *' readonly
// CHECK-NEXT: ObjCReturnsInnerPointerAttr
// CHECK-NEXT: ObjCPropertyDecl{{.*}} Test4 'void *' readonly
// CHECK-NEXT: ObjCReturnsInnerPointerAttr
@property (readonly) [[clang::iboutlet]] NSObject *Test5;
// CHECK: ObjCPropertyDecl{{.*}} Test5 'NSObject *' readonly
// CHECK-NEXT: IBOutletAttr
// CHECK: ObjCMethodDecl{{.*}} implicit{{.*}} Test3
// CHECK-NEXT: ObjCReturnsInnerPointerAttr
// CHECK: ObjCMethodDecl{{.*}} implicit{{.*}} Test4
// CHECK-NEXT: ObjCReturnsInnerPointerAttr
// CHECK: ObjCMethodDecl{{.*}} implicit{{.*}} Test5
// CHECK-NOT: IBOutletAttr
@end
[[clang::objc_runtime_name("name")]] @protocol Test6;
// CHECK: ObjCProtocolDecl{{.*}} Test6
// CHECK-NEXT: ObjCRuntimeNameAttr{{.*}} "name"
[[clang::objc_protocol_requires_explicit_implementation]]
@protocol Test7
// CHECK: ObjCProtocolDecl{{.*}} Test7
// CHECK-NEXT: ObjCExplicitProtocolImplAttr
@end
@interface Test8
// CHECK: ObjCInterfaceDecl{{.*}} Test8
-(void)Test9 [[clang::ns_consumes_self]];
// CHECK: ObjCMethodDecl{{.*}} Test9 'void'
// CHECK-NEXT: NSConsumesSelfAttr
-(void) [[clang::ns_consumes_self]] Test10: (int)Test11;
// CHECK: ObjCMethodDecl{{.*}} Test10: 'void'
// CHECK-NEXT: |-ParmVarDecl{{.*}} Test11 'int'
// CHECK-NEXT: `-NSConsumesSelfAttr
-(void)Test12: (int *) [[clang::noescape]] Test13 to:(int)Test14 [[clang::ns_consumes_self]];
// CHECK: ObjCMethodDecl{{.*}} Test12:to: 'void'
// CHECK-NEXT: |-ParmVarDecl{{.*}} Test13 'int *'
// CHECK-NEXT: | `-NoEscapeAttr
// CHECK-NEXT: |-ParmVarDecl{{.*}} Test14 'int'
// CHECK-NEXT: `-NSConsumesSelfAttr
@end

View File

@ -1,54 +1,54 @@
// Test without serialization:
// RUN: %clang_cc1 -triple x86_64-pc-linux -fdouble-square-bracket-attributes \
// RUN: -Wno-deprecated-declarations -ast-dump -ast-dump-filter Test %s \
// RUN: | FileCheck --strict-whitespace %s
//
// Test with serialization:
// RUN: %clang_cc1 -triple x86_64-pc-linux -fdouble-square-bracket-attributes \
// RUN: -Wno-deprecated-declarations -emit-pch -o %t %s
// RUN: %clang_cc1 -x c -triple x86_64-pc-linux -fdouble-square-bracket-attributes \
// RUN: -Wno-deprecated-declarations -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
// RUN: | FileCheck --strict-whitespace %s
int Test1 [[deprecated]];
// CHECK: VarDecl{{.*}}Test1
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:13> "" ""
enum [[deprecated("Frobble")]] Test2 {
Test3 [[deprecated]]
};
// CHECK: EnumDecl{{.*}}Test2
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:8, col:28> "Frobble" ""
// CHECK-NEXT: EnumConstantDecl{{.*}}Test3
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:11> "" ""
struct [[deprecated]] Test4 {
[[deprecated("Frobble")]] int Test5, Test6;
int Test7 [[deprecated]] : 12;
};
// CHECK: RecordDecl{{.*}}Test4
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:10> "" ""
// CHECK-NEXT: FieldDecl{{.*}}Test5
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:5, col:25> "Frobble" ""
// CHECK-NEXT: FieldDecl{{.*}}Test6
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:5, col:25> "Frobble" ""
// CHECK-NEXT: FieldDecl{{.*}}Test7
// CHECK-NEXT: ConstantExpr{{.*}}'int'
// CHECK-NEXT: value: Int 12
// CHECK-NEXT: IntegerLiteral{{.*}}'int' 12
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:15> "" ""
struct [[deprecated]] Test8;
// CHECK: RecordDecl{{.*}}Test8
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:10> "" ""
[[deprecated]] void Test9(int Test10 [[deprecated]]);
// CHECK: FunctionDecl{{.*}}Test9
// CHECK-NEXT: ParmVarDecl{{.*}}Test10
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:40> "" ""
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:3> "" ""
void Test11 [[deprecated]](void);
// CHECK: FunctionDecl{{.*}}Test11
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:15> "" ""
// Test without serialization:
// RUN: %clang_cc1 -triple x86_64-pc-linux -fdouble-square-bracket-attributes \
// RUN: -Wno-deprecated-declarations -ast-dump -ast-dump-filter Test %s \
// RUN: | FileCheck --strict-whitespace %s
//
// Test with serialization:
// RUN: %clang_cc1 -triple x86_64-pc-linux -fdouble-square-bracket-attributes \
// RUN: -Wno-deprecated-declarations -emit-pch -o %t %s
// RUN: %clang_cc1 -x c -triple x86_64-pc-linux -fdouble-square-bracket-attributes \
// RUN: -Wno-deprecated-declarations -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
// RUN: | FileCheck --strict-whitespace %s
int Test1 [[deprecated]];
// CHECK: VarDecl{{.*}}Test1
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:13> "" ""
enum [[deprecated("Frobble")]] Test2 {
Test3 [[deprecated]]
};
// CHECK: EnumDecl{{.*}}Test2
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:8, col:28> "Frobble" ""
// CHECK-NEXT: EnumConstantDecl{{.*}}Test3
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:11> "" ""
struct [[deprecated]] Test4 {
[[deprecated("Frobble")]] int Test5, Test6;
int Test7 [[deprecated]] : 12;
};
// CHECK: RecordDecl{{.*}}Test4
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:10> "" ""
// CHECK-NEXT: FieldDecl{{.*}}Test5
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:5, col:25> "Frobble" ""
// CHECK-NEXT: FieldDecl{{.*}}Test6
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:5, col:25> "Frobble" ""
// CHECK-NEXT: FieldDecl{{.*}}Test7
// CHECK-NEXT: ConstantExpr{{.*}}'int'
// CHECK-NEXT: value: Int 12
// CHECK-NEXT: IntegerLiteral{{.*}}'int' 12
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:15> "" ""
struct [[deprecated]] Test8;
// CHECK: RecordDecl{{.*}}Test8
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:10> "" ""
[[deprecated]] void Test9(int Test10 [[deprecated]]);
// CHECK: FunctionDecl{{.*}}Test9
// CHECK-NEXT: ParmVarDecl{{.*}}Test10
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:40> "" ""
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:3> "" ""
void Test11 [[deprecated]](void);
// CHECK: FunctionDecl{{.*}}Test11
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:15> "" ""

File diff suppressed because it is too large Load Diff

View File

@ -1,62 +1,62 @@
// RUN: not %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -fms-extensions -ast-dump -ast-dump-filter Test %s | FileCheck -check-prefix CHECK -strict-whitespace %s
namespace TestInvalidRParenOnCXXUnresolvedConstructExpr {
template <class T>
void f(T i, T j) {
return T (i, j;
}
}
// CHECK: NamespaceDecl {{.*}} <{{.*}}> {{.*}} TestInvalidRParenOnCXXUnresolvedConstructExpr
// CHECK-NEXT: `-FunctionTemplateDecl
// CHECK-NEXT: |-TemplateTypeParmDecl
// CHECK-NEXT: `-FunctionDecl
// CHECK-NEXT: |-ParmVarDecl
// CHECK-NEXT: |-ParmVarDecl
// CHECK-NEXT: `-CompoundStmt
// CHECK-NEXT: `-ReturnStmt
// CHECK-NEXT: `-CXXUnresolvedConstructExpr {{.*}} <col:10, col:16> 'T'
// CHECK-NEXT: |-DeclRefExpr {{.*}} <col:13> 'T' lvalue ParmVar {{.*}} 'i' 'T'
// CHECK-NEXT: `-DeclRefExpr {{.*}} <col:16> 'T' lvalue ParmVar {{.*}} 'j' 'T'
namespace TestInvalidIf {
int g(int i) {
if (invalid_condition)
return 4;
else
return i;
}
}
// CHECK: NamespaceDecl {{.*}} <{{.*}}> {{.*}} TestInvalidIf
// CHECK-NEXT: `-FunctionDecl
// CHECK-NEXT: |-ParmVarDecl
// CHECK-NEXT: `-CompoundStmt
// CHECK-NEXT: `-IfStmt {{.*}} <line:25:3, line:28:12>
// CHECK-NEXT: |-OpaqueValueExpr {{.*}} <<invalid sloc>> 'bool'
// CHECK-NEXT: |-ReturnStmt {{.*}} <line:26:5, col:12>
// CHECK-NEXT: | `-IntegerLiteral {{.*}} <col:12> 'int' 4
// CHECK-NEXT: `-ReturnStmt {{.*}} <line:28:5, col:12>
// CHECK-NEXT: `-ImplicitCastExpr {{.*}} <col:12> 'int' <LValueToRValue>
// CHECK-NEXT: `-DeclRefExpr {{.*}} <col:12> 'int' lvalue ParmVar {{.*}} 'i' 'int'
namespace TestInvalidFunctionDecl {
struct Str {
double foo1(double, invalid_type);
};
double Str::foo1(double, invalid_type)
{ return 45; }
}
// CHECK: NamespaceDecl {{.*}} <{{.*}}> {{.*}} TestInvalidFunctionDecl
// CHECK-NEXT: |-CXXRecordDecl {{.*}} <line:44:1, line:46:1> line:44:8 struct Str definition
// CHECK: | |-CXXRecordDecl {{.*}} <col:1, col:8> col:8 implicit struct Str
// CHECK-NEXT: | `-CXXMethodDecl {{.*}} <line:45:4, col:36> col:11 invalid foo1 'double (double, int)'
// CHECK-NEXT: | |-ParmVarDecl {{.*}} <col:16> col:22 'double'
// CHECK-NEXT: | `-ParmVarDecl {{.*}} <col:24, <invalid sloc>> col:36 invalid 'int'
// CHECK-NEXT: `-CXXMethodDecl {{.*}} parent {{.*}} <line:47:1, line:48:14> line:47:13 invalid foo1 'double (double, int)'
// CHECK-NEXT: |-ParmVarDecl {{.*}} <col:18> col:24 'double'
// CHECK-NEXT: |-ParmVarDecl {{.*}} <col:26, <invalid sloc>> col:38 invalid 'int'
// CHECK-NEXT: `-CompoundStmt {{.*}} <line:48:1, col:14>
// CHECK-NEXT: `-ReturnStmt {{.*}} <col:3, col:10>
// CHECK-NEXT: `-ImplicitCastExpr {{.*}} <col:10> 'double' <IntegralToFloating>
// CHECK-NEXT: `-IntegerLiteral {{.*}} <col:10> 'int' 45
// RUN: not %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -fms-extensions -ast-dump -ast-dump-filter Test %s | FileCheck -check-prefix CHECK -strict-whitespace %s
namespace TestInvalidRParenOnCXXUnresolvedConstructExpr {
template <class T>
void f(T i, T j) {
return T (i, j;
}
}
// CHECK: NamespaceDecl {{.*}} <{{.*}}> {{.*}} TestInvalidRParenOnCXXUnresolvedConstructExpr
// CHECK-NEXT: `-FunctionTemplateDecl
// CHECK-NEXT: |-TemplateTypeParmDecl
// CHECK-NEXT: `-FunctionDecl
// CHECK-NEXT: |-ParmVarDecl
// CHECK-NEXT: |-ParmVarDecl
// CHECK-NEXT: `-CompoundStmt
// CHECK-NEXT: `-ReturnStmt
// CHECK-NEXT: `-CXXUnresolvedConstructExpr {{.*}} <col:10, col:16> 'T'
// CHECK-NEXT: |-DeclRefExpr {{.*}} <col:13> 'T' lvalue ParmVar {{.*}} 'i' 'T'
// CHECK-NEXT: `-DeclRefExpr {{.*}} <col:16> 'T' lvalue ParmVar {{.*}} 'j' 'T'
namespace TestInvalidIf {
int g(int i) {
if (invalid_condition)
return 4;
else
return i;
}
}
// CHECK: NamespaceDecl {{.*}} <{{.*}}> {{.*}} TestInvalidIf
// CHECK-NEXT: `-FunctionDecl
// CHECK-NEXT: |-ParmVarDecl
// CHECK-NEXT: `-CompoundStmt
// CHECK-NEXT: `-IfStmt {{.*}} <line:25:3, line:28:12>
// CHECK-NEXT: |-OpaqueValueExpr {{.*}} <<invalid sloc>> 'bool'
// CHECK-NEXT: |-ReturnStmt {{.*}} <line:26:5, col:12>
// CHECK-NEXT: | `-IntegerLiteral {{.*}} <col:12> 'int' 4
// CHECK-NEXT: `-ReturnStmt {{.*}} <line:28:5, col:12>
// CHECK-NEXT: `-ImplicitCastExpr {{.*}} <col:12> 'int' <LValueToRValue>
// CHECK-NEXT: `-DeclRefExpr {{.*}} <col:12> 'int' lvalue ParmVar {{.*}} 'i' 'int'
namespace TestInvalidFunctionDecl {
struct Str {
double foo1(double, invalid_type);
};
double Str::foo1(double, invalid_type)
{ return 45; }
}
// CHECK: NamespaceDecl {{.*}} <{{.*}}> {{.*}} TestInvalidFunctionDecl
// CHECK-NEXT: |-CXXRecordDecl {{.*}} <line:44:1, line:46:1> line:44:8 struct Str definition
// CHECK: | |-CXXRecordDecl {{.*}} <col:1, col:8> col:8 implicit struct Str
// CHECK-NEXT: | `-CXXMethodDecl {{.*}} <line:45:4, col:36> col:11 invalid foo1 'double (double, int)'
// CHECK-NEXT: | |-ParmVarDecl {{.*}} <col:16> col:22 'double'
// CHECK-NEXT: | `-ParmVarDecl {{.*}} <col:24, <invalid sloc>> col:36 invalid 'int'
// CHECK-NEXT: `-CXXMethodDecl {{.*}} parent {{.*}} <line:47:1, line:48:14> line:47:13 invalid foo1 'double (double, int)'
// CHECK-NEXT: |-ParmVarDecl {{.*}} <col:18> col:24 'double'
// CHECK-NEXT: |-ParmVarDecl {{.*}} <col:26, <invalid sloc>> col:38 invalid 'int'
// CHECK-NEXT: `-CompoundStmt {{.*}} <line:48:1, col:14>
// CHECK-NEXT: `-ReturnStmt {{.*}} <col:3, col:10>
// CHECK-NEXT: `-ImplicitCastExpr {{.*}} <col:10> 'double' <IntegralToFloating>
// CHECK-NEXT: `-IntegerLiteral {{.*}} <col:10> 'int' 45

View File

@ -38,356 +38,356 @@ int TestOpaqueValueExpr = 0 ?: 1;
// CHECK-NEXT: IntegerLiteral
// CHECK-NEXT: OpaqueValueExpr
// CHECK-NEXT: IntegerLiteral
// CHECK-NEXT: OpaqueValueExpr
// CHECK-NEXT: IntegerLiteral
// CHECK-NEXT: IntegerLiteral
void TestUnaryOperatorExpr(void) {
char T1 = 1;
int T2 = 1;
T1++;
T2++;
// CHECK: UnaryOperator{{.*}}postfix '++' cannot overflow
// CHECK-NEXT: DeclRefExpr{{.*}}'T1' 'char'
// CHECK-NOT: UnaryOperator{{.*}}postfix '++' cannot overflow
// CHECK: DeclRefExpr{{.*}}'T2' 'int'
-T1;
-T2;
// CHECK: UnaryOperator{{.*}}prefix '-' cannot overflow
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr{{.*}}'T1' 'char'
// CHECK-NOT: UnaryOperator{{.*}}prefix '-' cannot overflow
// CHECK: ImplicitCastExpr
// CHECK: DeclRefExpr{{.*}}'T2' 'int'
~T1;
~T2;
// CHECK: UnaryOperator{{.*}}prefix '~' cannot overflow
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr{{.*}}'T1' 'char'
// CHECK: UnaryOperator{{.*}}prefix '~' cannot overflow
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr{{.*}}'T2' 'int'
}
void TestGenericSelectionExpressions(int i) {
_Generic(i, int : 12);
// CHECK: GenericSelectionExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:23> 'int'
// CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
// FIXME: note that the following test line has a spurious whitespace.
// CHECK-NEXT: case 'int' selected
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:21> 'int' 12
_Generic(i, int : 12, default : 0);
// CHECK: GenericSelectionExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:36> 'int'
// CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
// FIXME: note that the following test line has a spurious whitespace.
// CHECK-NEXT: case 'int' selected
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:21> 'int' 12
// CHECK-NEXT: default
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:35> 'int' 0
_Generic(i, default : 0, int : 12);
// CHECK: GenericSelectionExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:36> 'int'
// CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
// CHECK-NEXT: default
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:25> 'int' 0
// FIXME: note that the following test line has a spurious whitespace.
// CHECK-NEXT: case 'int' selected
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:34> 'int' 12
_Generic(i, int : 12, float : 10, default : 100);
// CHECK: GenericSelectionExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:50> 'int'
// CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
// FIXME: note that the following test line has a spurious whitespace.
// CHECK-NEXT: case 'int' selected
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:21> 'int' 12
// FIXME: note that the following test line has a spurious whitespace.
// CHECK-NEXT: case 'float'
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'float'
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:33> 'int' 10
// CHECK-NEXT: default
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:47> 'int' 100
int j = _Generic(i, int : 12);
// CHECK: DeclStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:32>
// CHECK-NEXT: VarDecl 0x{{[^ ]*}} <col:3, col:31> col:7 j 'int' cinit
// CHECK-NEXT: GenericSelectionExpr 0x{{[^ ]*}} <col:11, col:31> 'int'
// CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:20> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
// FIXME: note that the following test line has a spurious whitespace.
// CHECK-NEXT: case 'int' selected
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:29> 'int' 12
}
void TestLabelsAndGoto(void) {
// Note: case and default labels are handled by TestSwitch().
label1:
;
// CHECK: LabelStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:1, line:[[@LINE-1]]:3> 'label1'
// CHECK-NEXT: NullStmt 0x{{[^ ]*}} <col:3>
goto label2;
// CHECK-NEXT: GotoStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:8> 'label2' 0x{{[^ ]*}}
label2:
0;
// CHECK-NEXT: LabelStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:1, line:[[@LINE-1]]:3> 'label2'
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:3> 'int' 0
void *ptr = &&label1;
// CHECK-NEXT: DeclStmt
// CHECK-NEXT: VarDecl
// CHECK-NEXT: AddrLabelExpr 0x{{[^ ]*}} <col:15, col:17> 'void *' label1 0x{{[^ ]*}}
goto *ptr;
// CHECK-NEXT: IndirectGotoStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:9>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:9> 'void *' lvalue Var 0x{{[^ ]*}} 'ptr' 'void *'
}
void TestSwitch(int i) {
switch (i) {
// CHECK: SwitchStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, line:[[@LINE+32]]:3>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:11> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
// CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:14, line:[[@LINE+29]]:3>
case 0:
break;
// CHECK-NEXT: CaseStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: ConstantExpr
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:8> 'int' 0
// CHECK-NEXT: BreakStmt 0x{{[^ ]*}} <line:[[@LINE-4]]:5>
case 1:
case 2:
break;
// CHECK-NEXT: CaseStmt 0x{{[^ ]*}} <line:[[@LINE-3]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: ConstantExpr
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:8> 'int' 1
// CHECK-NEXT: CaseStmt 0x{{[^ ]*}} <line:[[@LINE-5]]:3, line:[[@LINE-4]]:5>
// CHECK-NEXT: ConstantExpr
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:8> 'int' 2
// CHECK-NEXT: BreakStmt 0x{{[^ ]*}} <line:[[@LINE-7]]:5>
default:
break;
// CHECK-NEXT: DefaultStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: BreakStmt 0x{{[^ ]*}} <col:5>
case 3 ... 5:
break;
// CHECK-NEXT: CaseStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5> gnu_range
// CHECK-NEXT: ConstantExpr
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:8> 'int' 3
// CHECK-NEXT: ConstantExpr
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:14> 'int' 5
// CHECK-NEXT: BreakStmt 0x{{[^ ]*}} <line:[[@LINE-6]]:5>
}
}
void TestIf(_Bool b) {
if (b)
;
// CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: NullStmt
if (b) {}
// CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:11>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: CompoundStmt
if (b)
;
else
;
// CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-4]]:3, line:[[@LINE-1]]:5> has_else
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-6]]:5>
// CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-5]]:5>
if (b) {}
else {}
// CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:9> has_else
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:10, col:11>
// CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <line:[[@LINE-5]]:8, col:9>
if (b)
;
else if (b)
;
// CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-4]]:3, line:[[@LINE-1]]:5> has_else
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-6]]:5>
// CHECK-NEXT: IfStmt 0x{{[^ ]*}} <line:[[@LINE-6]]:8, line:[[@LINE-5]]:5>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-8]]:5>
if (b)
;
else if (b)
;
else
;
// CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-6]]:3, line:[[@LINE-1]]:5> has_else
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-8]]:5>
// CHECK-NEXT: IfStmt 0x{{[^ ]*}} <line:[[@LINE-8]]:8, line:[[@LINE-5]]:5> has_else
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-10]]:5>
// CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-9]]:5>
}
void TestIteration(_Bool b) {
while (b)
;
// CHECK: WhileStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-4]]:5>
do
;
while (b);
// CHECK: DoStmt 0x{{[^ ]*}} <line:[[@LINE-3]]:3, line:[[@LINE-1]]:11>
// CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-3]]:5>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
for (int i = 0; i < 10; ++i)
;
// CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: DeclStmt
// CHECK-NEXT: VarDecl 0x{{[^ ]*}} <col:8, col:16> col:12 used i 'int' cinit
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:16> 'int' 0
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <col:19, col:23> 'int' '<'
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:19> 'int' lvalue Var 0x{{[^ ]*}} 'i' 'int'
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:23> 'int' 10
// CHECK-NEXT: UnaryOperator 0x{{[^ ]*}} <col:27, col:29> 'int' prefix '++'
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:29> 'int' lvalue Var 0x{{[^ ]*}} 'i' 'int'
// CHECK-NEXT: NullStmt
for (b; b; b)
;
// CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:8> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:11> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:14> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: NullStmt
for (; b; b = !b)
;
// CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <col:13, col:18> '_Bool' '='
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:13> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: UnaryOperator 0x{{[^ ]*}} <col:17, col:18> 'int' prefix '!' cannot overflow
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:18> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: NullStmt
for (; b;)
;
// CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: NullStmt
for (;; b = !b)
;
// CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <line:[[@LINE-6]]:11, col:16> '_Bool' '='
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:11> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: UnaryOperator 0x{{[^ ]*}} <col:15, col:16> 'int' prefix '!' cannot overflow
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:16> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: NullStmt
for (;;)
;
// CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: NullStmt
}
void TestJumps(void) {
// goto and computed goto was tested in TestLabelsAndGoto().
while (1) {
continue;
// CHECK: ContinueStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:5>
break;
// CHECK: BreakStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:5>
}
return;
// CHECK: ReturnStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3>
return TestSwitch(1);
// CHECK: ReturnStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:22>
// CHECK-NEXT: CallExpr 0x{{[^ ]*}} <col:10, col:22> 'void'
}
void TestMiscStmts(void) {
({int a = 10; a;});
// CHECK: StmtExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:20> 'int'
// CHECK-NEXT: CompoundStmt
// CHECK-NEXT: DeclStmt
// CHECK-NEXT: VarDecl 0x{{[^ ]*}} <col:5, col:13> col:9 used a 'int' cinit
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:13> 'int' 10
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:17> 'int' lvalue Var 0x{{[^ ]*}} 'a' 'int'
({int a = 10; a;;; });
// CHECK-NEXT: StmtExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:23> 'int'
// CHECK-NEXT: CompoundStmt
// CHECK-NEXT: DeclStmt
// CHECK-NEXT: VarDecl 0x{{[^ ]*}} <col:5, col:13> col:9 used a 'int' cinit
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:13> 'int' 10
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:17> 'int' lvalue Var 0x{{[^ ]*}} 'a' 'int'
// CHECK-NEXT: NullStmt
// CHECK-NEXT: NullStmt
}
// CHECK-NEXT: OpaqueValueExpr
// CHECK-NEXT: IntegerLiteral
// CHECK-NEXT: IntegerLiteral
void TestUnaryOperatorExpr(void) {
char T1 = 1;
int T2 = 1;
T1++;
T2++;
// CHECK: UnaryOperator{{.*}}postfix '++' cannot overflow
// CHECK-NEXT: DeclRefExpr{{.*}}'T1' 'char'
// CHECK-NOT: UnaryOperator{{.*}}postfix '++' cannot overflow
// CHECK: DeclRefExpr{{.*}}'T2' 'int'
-T1;
-T2;
// CHECK: UnaryOperator{{.*}}prefix '-' cannot overflow
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr{{.*}}'T1' 'char'
// CHECK-NOT: UnaryOperator{{.*}}prefix '-' cannot overflow
// CHECK: ImplicitCastExpr
// CHECK: DeclRefExpr{{.*}}'T2' 'int'
~T1;
~T2;
// CHECK: UnaryOperator{{.*}}prefix '~' cannot overflow
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr{{.*}}'T1' 'char'
// CHECK: UnaryOperator{{.*}}prefix '~' cannot overflow
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr{{.*}}'T2' 'int'
}
void TestGenericSelectionExpressions(int i) {
_Generic(i, int : 12);
// CHECK: GenericSelectionExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:23> 'int'
// CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
// FIXME: note that the following test line has a spurious whitespace.
// CHECK-NEXT: case 'int' selected
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:21> 'int' 12
_Generic(i, int : 12, default : 0);
// CHECK: GenericSelectionExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:36> 'int'
// CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
// FIXME: note that the following test line has a spurious whitespace.
// CHECK-NEXT: case 'int' selected
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:21> 'int' 12
// CHECK-NEXT: default
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:35> 'int' 0
_Generic(i, default : 0, int : 12);
// CHECK: GenericSelectionExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:36> 'int'
// CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
// CHECK-NEXT: default
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:25> 'int' 0
// FIXME: note that the following test line has a spurious whitespace.
// CHECK-NEXT: case 'int' selected
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:34> 'int' 12
_Generic(i, int : 12, float : 10, default : 100);
// CHECK: GenericSelectionExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:50> 'int'
// CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
// FIXME: note that the following test line has a spurious whitespace.
// CHECK-NEXT: case 'int' selected
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:21> 'int' 12
// FIXME: note that the following test line has a spurious whitespace.
// CHECK-NEXT: case 'float'
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'float'
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:33> 'int' 10
// CHECK-NEXT: default
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:47> 'int' 100
int j = _Generic(i, int : 12);
// CHECK: DeclStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:32>
// CHECK-NEXT: VarDecl 0x{{[^ ]*}} <col:3, col:31> col:7 j 'int' cinit
// CHECK-NEXT: GenericSelectionExpr 0x{{[^ ]*}} <col:11, col:31> 'int'
// CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:20> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
// FIXME: note that the following test line has a spurious whitespace.
// CHECK-NEXT: case 'int' selected
// CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:29> 'int' 12
}
void TestLabelsAndGoto(void) {
// Note: case and default labels are handled by TestSwitch().
label1:
;
// CHECK: LabelStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:1, line:[[@LINE-1]]:3> 'label1'
// CHECK-NEXT: NullStmt 0x{{[^ ]*}} <col:3>
goto label2;
// CHECK-NEXT: GotoStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:8> 'label2' 0x{{[^ ]*}}
label2:
0;
// CHECK-NEXT: LabelStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:1, line:[[@LINE-1]]:3> 'label2'
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:3> 'int' 0
void *ptr = &&label1;
// CHECK-NEXT: DeclStmt
// CHECK-NEXT: VarDecl
// CHECK-NEXT: AddrLabelExpr 0x{{[^ ]*}} <col:15, col:17> 'void *' label1 0x{{[^ ]*}}
goto *ptr;
// CHECK-NEXT: IndirectGotoStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:9>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:9> 'void *' lvalue Var 0x{{[^ ]*}} 'ptr' 'void *'
}
void TestSwitch(int i) {
switch (i) {
// CHECK: SwitchStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, line:[[@LINE+32]]:3>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:11> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
// CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:14, line:[[@LINE+29]]:3>
case 0:
break;
// CHECK-NEXT: CaseStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: ConstantExpr
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:8> 'int' 0
// CHECK-NEXT: BreakStmt 0x{{[^ ]*}} <line:[[@LINE-4]]:5>
case 1:
case 2:
break;
// CHECK-NEXT: CaseStmt 0x{{[^ ]*}} <line:[[@LINE-3]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: ConstantExpr
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:8> 'int' 1
// CHECK-NEXT: CaseStmt 0x{{[^ ]*}} <line:[[@LINE-5]]:3, line:[[@LINE-4]]:5>
// CHECK-NEXT: ConstantExpr
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:8> 'int' 2
// CHECK-NEXT: BreakStmt 0x{{[^ ]*}} <line:[[@LINE-7]]:5>
default:
break;
// CHECK-NEXT: DefaultStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: BreakStmt 0x{{[^ ]*}} <col:5>
case 3 ... 5:
break;
// CHECK-NEXT: CaseStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5> gnu_range
// CHECK-NEXT: ConstantExpr
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:8> 'int' 3
// CHECK-NEXT: ConstantExpr
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:14> 'int' 5
// CHECK-NEXT: BreakStmt 0x{{[^ ]*}} <line:[[@LINE-6]]:5>
}
}
void TestIf(_Bool b) {
if (b)
;
// CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: NullStmt
if (b) {}
// CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:11>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: CompoundStmt
if (b)
;
else
;
// CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-4]]:3, line:[[@LINE-1]]:5> has_else
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-6]]:5>
// CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-5]]:5>
if (b) {}
else {}
// CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:9> has_else
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:10, col:11>
// CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <line:[[@LINE-5]]:8, col:9>
if (b)
;
else if (b)
;
// CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-4]]:3, line:[[@LINE-1]]:5> has_else
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-6]]:5>
// CHECK-NEXT: IfStmt 0x{{[^ ]*}} <line:[[@LINE-6]]:8, line:[[@LINE-5]]:5>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-8]]:5>
if (b)
;
else if (b)
;
else
;
// CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-6]]:3, line:[[@LINE-1]]:5> has_else
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-8]]:5>
// CHECK-NEXT: IfStmt 0x{{[^ ]*}} <line:[[@LINE-8]]:8, line:[[@LINE-5]]:5> has_else
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-10]]:5>
// CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-9]]:5>
}
void TestIteration(_Bool b) {
while (b)
;
// CHECK: WhileStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-4]]:5>
do
;
while (b);
// CHECK: DoStmt 0x{{[^ ]*}} <line:[[@LINE-3]]:3, line:[[@LINE-1]]:11>
// CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-3]]:5>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
for (int i = 0; i < 10; ++i)
;
// CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: DeclStmt
// CHECK-NEXT: VarDecl 0x{{[^ ]*}} <col:8, col:16> col:12 used i 'int' cinit
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:16> 'int' 0
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <col:19, col:23> 'int' '<'
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:19> 'int' lvalue Var 0x{{[^ ]*}} 'i' 'int'
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:23> 'int' 10
// CHECK-NEXT: UnaryOperator 0x{{[^ ]*}} <col:27, col:29> 'int' prefix '++'
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:29> 'int' lvalue Var 0x{{[^ ]*}} 'i' 'int'
// CHECK-NEXT: NullStmt
for (b; b; b)
;
// CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:8> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:11> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:14> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: NullStmt
for (; b; b = !b)
;
// CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <col:13, col:18> '_Bool' '='
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:13> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: UnaryOperator 0x{{[^ ]*}} <col:17, col:18> 'int' prefix '!' cannot overflow
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:18> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: NullStmt
for (; b;)
;
// CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: NullStmt
for (;; b = !b)
;
// CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <line:[[@LINE-6]]:11, col:16> '_Bool' '='
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:11> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: UnaryOperator 0x{{[^ ]*}} <col:15, col:16> 'int' prefix '!' cannot overflow
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:16> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
// CHECK-NEXT: NullStmt
for (;;)
;
// CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: <<<NULL>>>
// CHECK-NEXT: NullStmt
}
void TestJumps(void) {
// goto and computed goto was tested in TestLabelsAndGoto().
while (1) {
continue;
// CHECK: ContinueStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:5>
break;
// CHECK: BreakStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:5>
}
return;
// CHECK: ReturnStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3>
return TestSwitch(1);
// CHECK: ReturnStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:22>
// CHECK-NEXT: CallExpr 0x{{[^ ]*}} <col:10, col:22> 'void'
}
void TestMiscStmts(void) {
({int a = 10; a;});
// CHECK: StmtExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:20> 'int'
// CHECK-NEXT: CompoundStmt
// CHECK-NEXT: DeclStmt
// CHECK-NEXT: VarDecl 0x{{[^ ]*}} <col:5, col:13> col:9 used a 'int' cinit
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:13> 'int' 10
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:17> 'int' lvalue Var 0x{{[^ ]*}} 'a' 'int'
({int a = 10; a;;; });
// CHECK-NEXT: StmtExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:23> 'int'
// CHECK-NEXT: CompoundStmt
// CHECK-NEXT: DeclStmt
// CHECK-NEXT: VarDecl 0x{{[^ ]*}} <col:5, col:13> col:9 used a 'int' cinit
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:13> 'int' 10
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:17> 'int' lvalue Var 0x{{[^ ]*}} 'a' 'int'
// CHECK-NEXT: NullStmt
// CHECK-NEXT: NullStmt
}

View File

@ -1,341 +1,341 @@
// Tests without serialization:
// RUN: %clang_cc1 -std=c++11 -ast-dump -triple aarch64-linux-gnu %s \
// RUN: | FileCheck %s --strict-whitespace
//
// RUN: %clang_cc1 -std=c++11 -ast-dump -triple aarch64-linux-gnu -fnative-half-type %s \
// RUN: | FileCheck %s --check-prefix=CHECK-NATIVE --strict-whitespace
//
// Tests with serialization:
// RUN: %clang_cc1 -std=c++11 -triple aarch64-linux-gnu -emit-pch -o %t %s
// RUN: %clang_cc1 -x c++ -std=c++11 -triple aarch64-linux-gnu -include-pch %t -ast-dump-all /dev/null \
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
// RUN: | FileCheck %s --strict-whitespace
//
// RUN: %clang_cc1 -std=c++11 -triple aarch64-linux-gnu -fnative-half-type -emit-pch -o %t %s
// RUN: %clang_cc1 -x c++ -std=c++11 -triple aarch64-linux-gnu -fnative-half-type -include-pch %t -ast-dump-all /dev/null \
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
// RUN: | FileCheck %s --check-prefix=CHECK-NATIVE --strict-whitespace
/* Various contexts where type _Float16 can appear. */
/* Namespace */
namespace {
_Float16 f1n;
_Float16 f2n = 33.f16;
_Float16 arr1n[10];
_Float16 arr2n[] = { 1.2, 3.0, 3.e4 };
const volatile _Float16 func1n(const _Float16 &arg) {
return arg + f2n + arr1n[4] - arr2n[1];
}
}
//CHECK: |-NamespaceDecl
//CHECK-NEXT: | |-VarDecl {{.*}} f1n '_Float16'
//CHECK-NEXT: | |-VarDecl {{.*}} f2n '_Float16' cinit
//CHECK-NEXT: | | `-FloatingLiteral {{.*}} '_Float16' 3.300000e+01
//CHECK-NEXT: | |-VarDecl {{.*}} arr1n '_Float16[10]'
//CHECK-NEXT: | |-VarDecl {{.*}} arr2n '_Float16[3]' cinit
//CHECK-NEXT: | | `-InitListExpr {{.*}} '_Float16[3]'
//CHECK-NEXT: | | |-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | | | `-FloatingLiteral {{.*}} 'double' 1.200000e+00
//CHECK-NEXT: | | |-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | | | `-FloatingLiteral {{.*}} 'double' 3.000000e+00
//CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | | `-FloatingLiteral {{.*}} 'double' 3.000000e+04
//CHECK-NEXT: | `-FunctionDecl {{.*}} func1n 'const volatile _Float16 (const _Float16 &)'
/* File */
_Float16 f1f;
_Float16 f2f = 32.4;
_Float16 arr1f[10];
_Float16 arr2f[] = { -1.2, -3.0, -3.e4 };
_Float16 func1f(_Float16 arg);
//CHECK: |-VarDecl {{.*}} f1f '_Float16'
//CHECK-NEXT: |-VarDecl {{.*}} f2f '_Float16' cinit
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | `-FloatingLiteral {{.*}} 'double' 3.240000e+01
//CHECK-NEXT: |-VarDecl {{.*}} arr1f '_Float16[10]'
//CHECK-NEXT: |-VarDecl {{.*}} arr2f '_Float16[3]' cinit
//CHECK-NEXT: | `-InitListExpr {{.*}} '_Float16[3]'
//CHECK-NEXT: | |-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | | `-UnaryOperator {{.*}} 'double' prefix '-'
//CHECK-NEXT: | | `-FloatingLiteral {{.*}} 'double' 1.200000e+00
//CHECK-NEXT: | |-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | | `-UnaryOperator {{.*}} 'double' prefix '-'
//CHECK-NEXT: | | `-FloatingLiteral {{.*}} 'double' 3.000000e+00
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | `-UnaryOperator {{.*}} 'double' prefix '-'
//CHECK-NEXT: | `-FloatingLiteral {{.*}} 'double' 3.000000e+04
//CHECK-NEXT: |-FunctionDecl {{.*}} func1f '_Float16 (_Float16)'
//CHECK-NEXT: | `-ParmVarDecl {{.*}} arg '_Float16'
// Mixing __fp16 and Float16 types:
// The _Float16 type is first converted to __fp16 type and then the operation
// is completed as if both operands were of __fp16 type.
__fp16 B = -0.1;
auto C = -1.0f16 + B;
// When we do *not* have native half types, we expect __fp16 to be promoted to
// float, and consequently also _Float16 promotions to float:
//CHECK: -VarDecl {{.*}} used B '__fp16' cinit
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__fp16' <FloatingCast>
//CHECK-NEXT: | `-UnaryOperator {{.*}} 'double' prefix '-'
//CHECK-NEXT: | `-FloatingLiteral {{.*}} 'double' 1.000000e-01
//CHECK-NEXT: |-VarDecl {{.*}} C 'float':'float' cinit
//CHECK-NEXT: | `-BinaryOperator {{.*}} 'float' '+'
//CHECK-NEXT: | |-ImplicitCastExpr {{.*}} 'float' <FloatingCast>
//CHECK-NEXT: | | `-UnaryOperator {{.*}} '_Float16' prefix '-'
//CHECK-NEXT: | | `-FloatingLiteral {{.*}} '_Float16' 1.000000e+00
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} 'float' <FloatingCast>
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__fp16' <LValueToRValue>
//CHECK-NEXT: | `-DeclRefExpr {{.*}} '__fp16' lvalue Var 0x{{.*}} 'B' '__fp16'
// When do have native half types, we expect to see promotions to fp16:
//CHECK-NATIVE: |-VarDecl {{.*}} used B '__fp16' cinit
//CHECK-NATIVE: | `-ImplicitCastExpr {{.*}} '__fp16' <FloatingCast>
//CHECK-NATIVE: | `-UnaryOperator {{.*}} 'double' prefix '-'
//CHECK-NATIVE: | `-FloatingLiteral {{.*}} 'double' 1.000000e-01
//CHECK-NATIVE: |-VarDecl {{.*}} C '__fp16':'__fp16' cinit
//CHECK-NATIVE: | `-BinaryOperator {{.*}} '__fp16' '+'
//CHECK-NATIVE: | |-ImplicitCastExpr {{.*}} '__fp16' <FloatingCast>
//CHECK-NATIVE: | | `-UnaryOperator {{.*}} '_Float16' prefix '-'
//CHECK-NATIVE: | | `-FloatingLiteral {{.*}} '_Float16' 1.000000e+00
//CHECK-NATIVE: | `-ImplicitCastExpr {{.*}} '__fp16' <LValueToRValue>
//CHECK-NATIVE: | `-DeclRefExpr {{.*}} '__fp16' lvalue Var 0x{{.*}} 'B' '__fp16'
/* Class */
class C1 {
_Float16 f1c;
static const _Float16 f2c;
volatile _Float16 f3c;
public:
C1(_Float16 arg) : f1c(arg), f3c(arg) { }
_Float16 func1c(_Float16 arg ) {
return f1c + arg;
}
static _Float16 func2c(_Float16 arg) {
return arg * C1::f2c;
}
};
//CHECK: |-CXXRecordDecl {{.*}} referenced class C1 definition
//CHECK: | |-CXXRecordDecl {{.*}} implicit referenced class C1
//CHECK-NEXT: | |-FieldDecl {{.*}} referenced f1c '_Float16'
//CHECK-NEXT: | |-VarDecl {{.*}} used f2c 'const _Float16' static
//CHECK-NEXT: | |-FieldDecl {{.*}} f3c 'volatile _Float16'
//CHECK-NEXT: | |-AccessSpecDecl
//CHECK-NEXT: | |-CXXConstructorDecl {{.*}} used C1 'void (_Float16)
//CHECK-NEXT: | | |-ParmVarDecl {{.*}} used arg '_Float16'
//CHECK-NEXT: | | |-CXXCtorInitializer Field {{.*}} 'f1c' '_Float16'
//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '_Float16' lvalue ParmVar 0x{{.*}} 'arg' '_Float16'
//CHECK-NEXT: | | |-CXXCtorInitializer Field {{.*}} 'f3c' 'volatile _Float16'
//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '_Float16' lvalue ParmVar 0x{{.*}} 'arg' '_Float16'
//CHECK-NEXT: | | `-CompoundStmt
//CHECK-NEXT: | |-CXXMethodDecl {{.*}} used func1c '_Float16 (_Float16)
//CHECK-NEXT: | | |-ParmVarDecl {{.*}} used arg '_Float16'
//CHECK-NEXT: | | `-CompoundStmt
//CHECK-NEXT: | | `-ReturnStmt
//CHECK-NEXT: | | `-BinaryOperator {{.*}} '_Float16' '+'
//CHECK-NEXT: | | |-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | `-MemberExpr {{.*}} '_Float16' lvalue ->f1c 0x{{.*}}
//CHECK-NEXT: | | | `-CXXThisExpr {{.*}} 'C1 *' implicit this
//CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | `-DeclRefExpr {{.*}} '_Float16' lvalue ParmVar 0x{{.*}} 'arg' '_Float16'
//CHECK-NEXT: | |-CXXMethodDecl {{.*}} used func2c '_Float16 (_Float16)' static
//CHECK-NEXT: | | |-ParmVarDecl {{.*}} used arg '_Float16'
//CHECK-NEXT: | | `-CompoundStmt
//CHECK-NEXT: | | `-ReturnStmt
//CHECK-NEXT: | | `-BinaryOperator {{.*}} '_Float16' '*'
//CHECK-NEXT: | | |-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '_Float16' lvalue ParmVar 0x{{.*}} 'arg' '_Float16'
//CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | `-DeclRefExpr {{.*}} 'const _Float16' lvalue Var 0x{{.*}} 'f2c' 'const _Float16'
/* Template */
template <class C> C func1t(C arg) {
return arg * 2.f16;
}
//CHECK: |-FunctionTemplateDecl {{.*}} func1t
//CHECK-NEXT: | |-TemplateTypeParmDecl {{.*}} C
//CHECK-NEXT: | |-FunctionDecl {{.*}} func1t 'C (C)'
//CHECK-NEXT: | | |-ParmVarDecl {{.*}} referenced arg 'C'
//CHECK-NEXT: | | `-CompoundStmt
//CHECK-NEXT: | | `-ReturnStmt
//CHECK-NEXT: | | `-BinaryOperator {{.*}} '<dependent type>' '*'
//CHECK-NEXT: | | |-DeclRefExpr {{.*}} 'C' lvalue ParmVar {{.*}} 'arg' 'C'
//CHECK-NEXT: | | `-FloatingLiteral {{.*}} '_Float16' 2.000000e+00
//CHECK-NEXT: | `-FunctionDecl {{.*}} used func1t '_Float16 (_Float16)'
//CHECK-NEXT: | |-TemplateArgument type '_Float16'
//CHECK: | |-ParmVarDecl {{.*}} used arg '_Float16':'_Float16'
//CHECK-NEXT: | `-CompoundStmt
//CHECK-NEXT: | `-ReturnStmt
//CHECK-NEXT: | `-BinaryOperator {{.*}} '_Float16' '*'
//CHECK-NEXT: | |-ImplicitCastExpr {{.*}} '_Float16':'_Float16' <LValueToRValue>
//CHECK-NEXT: | | `-DeclRefExpr {{.*}} '_Float16':'_Float16' lvalue ParmVar {{.*}} 'arg' '_Float16':'_Float16'
//CHECK-NEXT: | `-FloatingLiteral {{.*}} '_Float16' 2.000000e+00
template <class C> struct S1 {
C mem1;
};
//CHECK: |-ClassTemplateDecl {{.*}} S1
//CHECK-NEXT: | |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 C
//CHECK-NEXT: | |-CXXRecordDecl {{.*}} struct S1 definition
//CHECK: | | |-CXXRecordDecl {{.*}} implicit struct S1
//CHECK-NEXT: | | `-FieldDecl {{.*}} mem1 'C'
//CHECK-NEXT: | `-ClassTemplateSpecialization {{.*}} 'S1'
template <> struct S1<_Float16> {
_Float16 mem2;
};
/* Local */
extern int printf (const char *__restrict __format, ...);
int main(void) {
_Float16 f1l = 1e3f16;
//CHECK: | `-VarDecl {{.*}} used f1l '_Float16' cinit
//CHECK-NEXT: | `-FloatingLiteral {{.*}} '_Float16' 1.000000e+03
_Float16 f2l = -0.f16;
//CHECK: | `-VarDecl {{.*}} used f2l '_Float16' cinit
//CHECK-NEXT: | `-UnaryOperator {{.*}} '_Float16' prefix '-'
//CHECK-NEXT: | `-FloatingLiteral {{.*}} '_Float16' 0.000000e+00
_Float16 f3l = 1.000976562;
//CHECK: | `-VarDecl {{.*}} used f3l '_Float16' cinit
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | `-FloatingLiteral {{.*}} 'double' 1.000977e+00
C1 c1(f1l);
//CHECK: | `-VarDecl{{.*}} used c1 'C1' callinit
//CHECK-NEXT: | `-CXXConstructExpr {{.*}} 'C1' 'void (_Float16)
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | `-DeclRefExpr {{.*}} '_Float16' lvalue Var 0x{{.*}} 'f1l' '_Float16'
S1<_Float16> s1 = { 132.f16 };
//CHECK: | `-VarDecl {{.*}} used s1 'S1<_Float16>':'S1<_Float16>' cinit
//CHECK-NEXT: | `-InitListExpr {{.*}} 'S1<_Float16>':'S1<_Float16>'
//CHECK-NEXT: | `-FloatingLiteral {{.*}} '_Float16' 1.320000e+02
_Float16 f4l = func1n(f1l) + func1f(f2l) + c1.func1c(f3l) + c1.func2c(f1l) +
func1t(f1l) + s1.mem2 - f1n + f2n;
//CHECK: | `-VarDecl {{.*}} used f4l '_Float16' cinit
//CHECK-NEXT: | `-BinaryOperator {{.*}} '_Float16' '+'
//CHECK-NEXT: | |-BinaryOperator {{.*}} '_Float16' '-'
//CHECK-NEXT: | | |-BinaryOperator {{.*}} '_Float16' '+'
//CHECK-NEXT: | | | |-BinaryOperator {{.*}} '_Float16' '+'
//CHECK-NEXT: | | | | |-BinaryOperator {{.*}} '_Float16' '+'
//CHECK-NEXT: | | | | | |-BinaryOperator {{.*}} '_Float16' '+'
//CHECK-NEXT: | | | | | | |-BinaryOperator {{.*}} '_Float16' '+'
//CHECK-NEXT: | | | | | | | |-CallExpr {{.*}} '_Float16'
//CHECK-NEXT: | | | | | | | | |-ImplicitCastExpr {{.*}} 'const volatile _Float16 (*)(const _Float16 &)' <FunctionToPointerDecay>
//CHECK-NEXT: | | | | | | | | | `-DeclRefExpr {{.*}} 'const volatile _Float16 (const _Float16 &)' lvalue Function {{.*}} 'func1n' 'const volatile _Float16 (const _Float16 &)'
//CHECK-NEXT: | | | | | | | | `-ImplicitCastExpr {{.*}} 'const _Float16' lvalue <NoOp>
//CHECK-NEXT: | | | | | | | | `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f1l' '_Float16'
//CHECK-NEXT: | | | | | | | `-CallExpr {{.*}} '_Float16'
//CHECK-NEXT: | | | | | | | |-ImplicitCastExpr {{.*}} '_Float16 (*)(_Float16)' <FunctionToPointerDecay>
//CHECK-NEXT: | | | | | | | | `-DeclRefExpr {{.*}} '_Float16 (_Float16)' lvalue Function {{.*}} 'func1f' '_Float16 (_Float16)'
//CHECK-NEXT: | | | | | | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | | | | | `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f2l' '_Float16'
//CHECK-NEXT: | | | | | | `-CXXMemberCallExpr {{.*}} '_Float16'
//CHECK-NEXT: | | | | | | |-MemberExpr {{.*}} '<bound member function type>' .func1c {{.*}}
//CHECK-NEXT: | | | | | | | `-DeclRefExpr {{.*}} 'C1' lvalue Var {{.*}} 'c1' 'C1'
//CHECK-NEXT: | | | | | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | | | | `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f3l' '_Float16'
//CHECK-NEXT: | | | | | `-CallExpr {{.*}} '_Float16'
//CHECK-NEXT: | | | | | |-ImplicitCastExpr {{.*}} '_Float16 (*)(_Float16)' <FunctionToPointerDecay>
//CHECK-NEXT: | | | | | | `-MemberExpr {{.*}} '_Float16 (_Float16)' lvalue .func2c {{.*}}
//CHECK-NEXT: | | | | | | `-DeclRefExpr {{.*}} 'C1' lvalue Var {{.*}} 'c1' 'C1'
//CHECK-NEXT: | | | | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | | | `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f1l' '_Float16'
//CHECK-NEXT: | | | | `-CallExpr {{.*}} '_Float16':'_Float16'
//CHECK-NEXT: | | | | |-ImplicitCastExpr {{.*}} '_Float16 (*)(_Float16)' <FunctionToPointerDecay>
//CHECK-NEXT: | | | | | `-DeclRefExpr {{.*}} '_Float16 (_Float16)' lvalue Function {{.*}} 'func1t' '_Float16 (_Float16)' (FunctionTemplate {{.*}} 'func1t')
//CHECK-NEXT: | | | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | | `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f1l' '_Float16'
//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | `-MemberExpr {{.*}} '_Float16' lvalue .mem2 {{.*}}
//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} 'S1<_Float16>':'S1<_Float16>' lvalue Var {{.*}} 's1' 'S1<_Float16>':'S1<_Float16>'
//CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f1n' '_Float16'
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f2n' '_Float16'
auto f5l = -1.f16, *f6l = &f2l, f7l = func1t(f3l);
//CHECK: | |-VarDecl {{.*}} f5l '_Float16':'_Float16' cinit
//CHECK-NEXT: | | `-UnaryOperator {{.*}} '_Float16' prefix '-'
//CHECK-NEXT: | | `-FloatingLiteral {{.*}} '_Float16' 1.000000e+00
//CHECK-NEXT: | |-VarDecl {{.*}} f6l '_Float16 *' cinit
//CHECK-NEXT: | | `-UnaryOperator {{.*}} '_Float16 *' prefix '&'
//CHECK-NEXT: | | `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f2l' '_Float16'
//CHECK-NEXT: | `-VarDecl {{.*}} f7l '_Float16':'_Float16' cinit
//CHECK-NEXT: | `-CallExpr {{.*}} '_Float16':'_Float16'
//CHECK-NEXT: | |-ImplicitCastExpr {{.*}} '_Float16 (*)(_Float16)' <FunctionToPointerDecay>
//CHECK-NEXT: | | `-DeclRefExpr {{.*}} '_Float16 (_Float16)' lvalue Function {{.*}} 'func1t' '_Float16 (_Float16)' (FunctionTemplate {{.*}} 'func1t')
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f3l' '_Float16'
_Float16 f8l = f4l++;
//CHECK: | `-VarDecl {{.*}} f8l '_Float16' cinit
//CHECK-NEXT: | `-UnaryOperator {{.*}} '_Float16' postfix '++'
//CHECK-NEXT: | `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f4l' '_Float16'
_Float16 arr1l[] = { -1.f16, -0.f16, -11.f16 };
//CHECK: `-VarDecl {{.*}} arr1l '_Float16[3]' cinit
//CHECK-NEXT: `-InitListExpr {{.*}} '_Float16[3]'
//CHECK-NEXT: |-UnaryOperator {{.*}} '_Float16' prefix '-'
//CHECK-NEXT: | `-FloatingLiteral {{.*}} '_Float16' 1.000000e+00
//CHECK-NEXT: |-UnaryOperator {{.*}} '_Float16' prefix '-'
//CHECK-NEXT: | `-FloatingLiteral {{.*}} '_Float16' 0.000000e+00
//CHECK-NEXT: `-UnaryOperator {{.*}} '_Float16' prefix '-'
//CHECK-NEXT: `-FloatingLiteral {{.*}} '_Float16' 1.100000e+01
float cvtf = f2n;
//CHECK: `-VarDecl {{.*}} cvtf 'float' cinit
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} 'float' <FloatingCast>
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f2n' '_Float16'
double cvtd = f2n;
//CHECK: `-VarDecl {{.*}} cvtd 'double' cinit
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} 'double' <FloatingCast>
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f2n' '_Float16'
long double cvtld = f2n;
//CHECK: `-VarDecl {{.*}} cvtld 'long double' cinit
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} 'long double' <FloatingCast>
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f2n' '_Float16'
_Float16 f2h = 42.0f;
//CHECK: `-VarDecl {{.*}} f2h '_Float16' cinit
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: `-FloatingLiteral {{.*}} 'float' 4.200000e+01
_Float16 d2h = 42.0;
//CHECK: `-VarDecl {{.*}} d2h '_Float16' cinit
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: `-FloatingLiteral {{.*}} 'double' 4.200000e+01
_Float16 ld2h = 42.0l;
//CHECK: `-VarDecl {{.*}} ld2h '_Float16' cinit
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: `-FloatingLiteral {{.*}} 'long double' 4.200000e+01
}
// Tests without serialization:
// RUN: %clang_cc1 -std=c++11 -ast-dump -triple aarch64-linux-gnu %s \
// RUN: | FileCheck %s --strict-whitespace
//
// RUN: %clang_cc1 -std=c++11 -ast-dump -triple aarch64-linux-gnu -fnative-half-type %s \
// RUN: | FileCheck %s --check-prefix=CHECK-NATIVE --strict-whitespace
//
// Tests with serialization:
// RUN: %clang_cc1 -std=c++11 -triple aarch64-linux-gnu -emit-pch -o %t %s
// RUN: %clang_cc1 -x c++ -std=c++11 -triple aarch64-linux-gnu -include-pch %t -ast-dump-all /dev/null \
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
// RUN: | FileCheck %s --strict-whitespace
//
// RUN: %clang_cc1 -std=c++11 -triple aarch64-linux-gnu -fnative-half-type -emit-pch -o %t %s
// RUN: %clang_cc1 -x c++ -std=c++11 -triple aarch64-linux-gnu -fnative-half-type -include-pch %t -ast-dump-all /dev/null \
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
// RUN: | FileCheck %s --check-prefix=CHECK-NATIVE --strict-whitespace
/* Various contexts where type _Float16 can appear. */
/* Namespace */
namespace {
_Float16 f1n;
_Float16 f2n = 33.f16;
_Float16 arr1n[10];
_Float16 arr2n[] = { 1.2, 3.0, 3.e4 };
const volatile _Float16 func1n(const _Float16 &arg) {
return arg + f2n + arr1n[4] - arr2n[1];
}
}
//CHECK: |-NamespaceDecl
//CHECK-NEXT: | |-VarDecl {{.*}} f1n '_Float16'
//CHECK-NEXT: | |-VarDecl {{.*}} f2n '_Float16' cinit
//CHECK-NEXT: | | `-FloatingLiteral {{.*}} '_Float16' 3.300000e+01
//CHECK-NEXT: | |-VarDecl {{.*}} arr1n '_Float16[10]'
//CHECK-NEXT: | |-VarDecl {{.*}} arr2n '_Float16[3]' cinit
//CHECK-NEXT: | | `-InitListExpr {{.*}} '_Float16[3]'
//CHECK-NEXT: | | |-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | | | `-FloatingLiteral {{.*}} 'double' 1.200000e+00
//CHECK-NEXT: | | |-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | | | `-FloatingLiteral {{.*}} 'double' 3.000000e+00
//CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | | `-FloatingLiteral {{.*}} 'double' 3.000000e+04
//CHECK-NEXT: | `-FunctionDecl {{.*}} func1n 'const volatile _Float16 (const _Float16 &)'
/* File */
_Float16 f1f;
_Float16 f2f = 32.4;
_Float16 arr1f[10];
_Float16 arr2f[] = { -1.2, -3.0, -3.e4 };
_Float16 func1f(_Float16 arg);
//CHECK: |-VarDecl {{.*}} f1f '_Float16'
//CHECK-NEXT: |-VarDecl {{.*}} f2f '_Float16' cinit
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | `-FloatingLiteral {{.*}} 'double' 3.240000e+01
//CHECK-NEXT: |-VarDecl {{.*}} arr1f '_Float16[10]'
//CHECK-NEXT: |-VarDecl {{.*}} arr2f '_Float16[3]' cinit
//CHECK-NEXT: | `-InitListExpr {{.*}} '_Float16[3]'
//CHECK-NEXT: | |-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | | `-UnaryOperator {{.*}} 'double' prefix '-'
//CHECK-NEXT: | | `-FloatingLiteral {{.*}} 'double' 1.200000e+00
//CHECK-NEXT: | |-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | | `-UnaryOperator {{.*}} 'double' prefix '-'
//CHECK-NEXT: | | `-FloatingLiteral {{.*}} 'double' 3.000000e+00
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | `-UnaryOperator {{.*}} 'double' prefix '-'
//CHECK-NEXT: | `-FloatingLiteral {{.*}} 'double' 3.000000e+04
//CHECK-NEXT: |-FunctionDecl {{.*}} func1f '_Float16 (_Float16)'
//CHECK-NEXT: | `-ParmVarDecl {{.*}} arg '_Float16'
// Mixing __fp16 and Float16 types:
// The _Float16 type is first converted to __fp16 type and then the operation
// is completed as if both operands were of __fp16 type.
__fp16 B = -0.1;
auto C = -1.0f16 + B;
// When we do *not* have native half types, we expect __fp16 to be promoted to
// float, and consequently also _Float16 promotions to float:
//CHECK: -VarDecl {{.*}} used B '__fp16' cinit
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__fp16' <FloatingCast>
//CHECK-NEXT: | `-UnaryOperator {{.*}} 'double' prefix '-'
//CHECK-NEXT: | `-FloatingLiteral {{.*}} 'double' 1.000000e-01
//CHECK-NEXT: |-VarDecl {{.*}} C 'float':'float' cinit
//CHECK-NEXT: | `-BinaryOperator {{.*}} 'float' '+'
//CHECK-NEXT: | |-ImplicitCastExpr {{.*}} 'float' <FloatingCast>
//CHECK-NEXT: | | `-UnaryOperator {{.*}} '_Float16' prefix '-'
//CHECK-NEXT: | | `-FloatingLiteral {{.*}} '_Float16' 1.000000e+00
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} 'float' <FloatingCast>
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__fp16' <LValueToRValue>
//CHECK-NEXT: | `-DeclRefExpr {{.*}} '__fp16' lvalue Var 0x{{.*}} 'B' '__fp16'
// When do have native half types, we expect to see promotions to fp16:
//CHECK-NATIVE: |-VarDecl {{.*}} used B '__fp16' cinit
//CHECK-NATIVE: | `-ImplicitCastExpr {{.*}} '__fp16' <FloatingCast>
//CHECK-NATIVE: | `-UnaryOperator {{.*}} 'double' prefix '-'
//CHECK-NATIVE: | `-FloatingLiteral {{.*}} 'double' 1.000000e-01
//CHECK-NATIVE: |-VarDecl {{.*}} C '__fp16':'__fp16' cinit
//CHECK-NATIVE: | `-BinaryOperator {{.*}} '__fp16' '+'
//CHECK-NATIVE: | |-ImplicitCastExpr {{.*}} '__fp16' <FloatingCast>
//CHECK-NATIVE: | | `-UnaryOperator {{.*}} '_Float16' prefix '-'
//CHECK-NATIVE: | | `-FloatingLiteral {{.*}} '_Float16' 1.000000e+00
//CHECK-NATIVE: | `-ImplicitCastExpr {{.*}} '__fp16' <LValueToRValue>
//CHECK-NATIVE: | `-DeclRefExpr {{.*}} '__fp16' lvalue Var 0x{{.*}} 'B' '__fp16'
/* Class */
class C1 {
_Float16 f1c;
static const _Float16 f2c;
volatile _Float16 f3c;
public:
C1(_Float16 arg) : f1c(arg), f3c(arg) { }
_Float16 func1c(_Float16 arg ) {
return f1c + arg;
}
static _Float16 func2c(_Float16 arg) {
return arg * C1::f2c;
}
};
//CHECK: |-CXXRecordDecl {{.*}} referenced class C1 definition
//CHECK: | |-CXXRecordDecl {{.*}} implicit referenced class C1
//CHECK-NEXT: | |-FieldDecl {{.*}} referenced f1c '_Float16'
//CHECK-NEXT: | |-VarDecl {{.*}} used f2c 'const _Float16' static
//CHECK-NEXT: | |-FieldDecl {{.*}} f3c 'volatile _Float16'
//CHECK-NEXT: | |-AccessSpecDecl
//CHECK-NEXT: | |-CXXConstructorDecl {{.*}} used C1 'void (_Float16)
//CHECK-NEXT: | | |-ParmVarDecl {{.*}} used arg '_Float16'
//CHECK-NEXT: | | |-CXXCtorInitializer Field {{.*}} 'f1c' '_Float16'
//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '_Float16' lvalue ParmVar 0x{{.*}} 'arg' '_Float16'
//CHECK-NEXT: | | |-CXXCtorInitializer Field {{.*}} 'f3c' 'volatile _Float16'
//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '_Float16' lvalue ParmVar 0x{{.*}} 'arg' '_Float16'
//CHECK-NEXT: | | `-CompoundStmt
//CHECK-NEXT: | |-CXXMethodDecl {{.*}} used func1c '_Float16 (_Float16)
//CHECK-NEXT: | | |-ParmVarDecl {{.*}} used arg '_Float16'
//CHECK-NEXT: | | `-CompoundStmt
//CHECK-NEXT: | | `-ReturnStmt
//CHECK-NEXT: | | `-BinaryOperator {{.*}} '_Float16' '+'
//CHECK-NEXT: | | |-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | `-MemberExpr {{.*}} '_Float16' lvalue ->f1c 0x{{.*}}
//CHECK-NEXT: | | | `-CXXThisExpr {{.*}} 'C1 *' implicit this
//CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | `-DeclRefExpr {{.*}} '_Float16' lvalue ParmVar 0x{{.*}} 'arg' '_Float16'
//CHECK-NEXT: | |-CXXMethodDecl {{.*}} used func2c '_Float16 (_Float16)' static
//CHECK-NEXT: | | |-ParmVarDecl {{.*}} used arg '_Float16'
//CHECK-NEXT: | | `-CompoundStmt
//CHECK-NEXT: | | `-ReturnStmt
//CHECK-NEXT: | | `-BinaryOperator {{.*}} '_Float16' '*'
//CHECK-NEXT: | | |-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '_Float16' lvalue ParmVar 0x{{.*}} 'arg' '_Float16'
//CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | `-DeclRefExpr {{.*}} 'const _Float16' lvalue Var 0x{{.*}} 'f2c' 'const _Float16'
/* Template */
template <class C> C func1t(C arg) {
return arg * 2.f16;
}
//CHECK: |-FunctionTemplateDecl {{.*}} func1t
//CHECK-NEXT: | |-TemplateTypeParmDecl {{.*}} C
//CHECK-NEXT: | |-FunctionDecl {{.*}} func1t 'C (C)'
//CHECK-NEXT: | | |-ParmVarDecl {{.*}} referenced arg 'C'
//CHECK-NEXT: | | `-CompoundStmt
//CHECK-NEXT: | | `-ReturnStmt
//CHECK-NEXT: | | `-BinaryOperator {{.*}} '<dependent type>' '*'
//CHECK-NEXT: | | |-DeclRefExpr {{.*}} 'C' lvalue ParmVar {{.*}} 'arg' 'C'
//CHECK-NEXT: | | `-FloatingLiteral {{.*}} '_Float16' 2.000000e+00
//CHECK-NEXT: | `-FunctionDecl {{.*}} used func1t '_Float16 (_Float16)'
//CHECK-NEXT: | |-TemplateArgument type '_Float16'
//CHECK: | |-ParmVarDecl {{.*}} used arg '_Float16':'_Float16'
//CHECK-NEXT: | `-CompoundStmt
//CHECK-NEXT: | `-ReturnStmt
//CHECK-NEXT: | `-BinaryOperator {{.*}} '_Float16' '*'
//CHECK-NEXT: | |-ImplicitCastExpr {{.*}} '_Float16':'_Float16' <LValueToRValue>
//CHECK-NEXT: | | `-DeclRefExpr {{.*}} '_Float16':'_Float16' lvalue ParmVar {{.*}} 'arg' '_Float16':'_Float16'
//CHECK-NEXT: | `-FloatingLiteral {{.*}} '_Float16' 2.000000e+00
template <class C> struct S1 {
C mem1;
};
//CHECK: |-ClassTemplateDecl {{.*}} S1
//CHECK-NEXT: | |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 C
//CHECK-NEXT: | |-CXXRecordDecl {{.*}} struct S1 definition
//CHECK: | | |-CXXRecordDecl {{.*}} implicit struct S1
//CHECK-NEXT: | | `-FieldDecl {{.*}} mem1 'C'
//CHECK-NEXT: | `-ClassTemplateSpecialization {{.*}} 'S1'
template <> struct S1<_Float16> {
_Float16 mem2;
};
/* Local */
extern int printf (const char *__restrict __format, ...);
int main(void) {
_Float16 f1l = 1e3f16;
//CHECK: | `-VarDecl {{.*}} used f1l '_Float16' cinit
//CHECK-NEXT: | `-FloatingLiteral {{.*}} '_Float16' 1.000000e+03
_Float16 f2l = -0.f16;
//CHECK: | `-VarDecl {{.*}} used f2l '_Float16' cinit
//CHECK-NEXT: | `-UnaryOperator {{.*}} '_Float16' prefix '-'
//CHECK-NEXT: | `-FloatingLiteral {{.*}} '_Float16' 0.000000e+00
_Float16 f3l = 1.000976562;
//CHECK: | `-VarDecl {{.*}} used f3l '_Float16' cinit
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | `-FloatingLiteral {{.*}} 'double' 1.000977e+00
C1 c1(f1l);
//CHECK: | `-VarDecl{{.*}} used c1 'C1' callinit
//CHECK-NEXT: | `-CXXConstructExpr {{.*}} 'C1' 'void (_Float16)
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | `-DeclRefExpr {{.*}} '_Float16' lvalue Var 0x{{.*}} 'f1l' '_Float16'
S1<_Float16> s1 = { 132.f16 };
//CHECK: | `-VarDecl {{.*}} used s1 'S1<_Float16>':'S1<_Float16>' cinit
//CHECK-NEXT: | `-InitListExpr {{.*}} 'S1<_Float16>':'S1<_Float16>'
//CHECK-NEXT: | `-FloatingLiteral {{.*}} '_Float16' 1.320000e+02
_Float16 f4l = func1n(f1l) + func1f(f2l) + c1.func1c(f3l) + c1.func2c(f1l) +
func1t(f1l) + s1.mem2 - f1n + f2n;
//CHECK: | `-VarDecl {{.*}} used f4l '_Float16' cinit
//CHECK-NEXT: | `-BinaryOperator {{.*}} '_Float16' '+'
//CHECK-NEXT: | |-BinaryOperator {{.*}} '_Float16' '-'
//CHECK-NEXT: | | |-BinaryOperator {{.*}} '_Float16' '+'
//CHECK-NEXT: | | | |-BinaryOperator {{.*}} '_Float16' '+'
//CHECK-NEXT: | | | | |-BinaryOperator {{.*}} '_Float16' '+'
//CHECK-NEXT: | | | | | |-BinaryOperator {{.*}} '_Float16' '+'
//CHECK-NEXT: | | | | | | |-BinaryOperator {{.*}} '_Float16' '+'
//CHECK-NEXT: | | | | | | | |-CallExpr {{.*}} '_Float16'
//CHECK-NEXT: | | | | | | | | |-ImplicitCastExpr {{.*}} 'const volatile _Float16 (*)(const _Float16 &)' <FunctionToPointerDecay>
//CHECK-NEXT: | | | | | | | | | `-DeclRefExpr {{.*}} 'const volatile _Float16 (const _Float16 &)' lvalue Function {{.*}} 'func1n' 'const volatile _Float16 (const _Float16 &)'
//CHECK-NEXT: | | | | | | | | `-ImplicitCastExpr {{.*}} 'const _Float16' lvalue <NoOp>
//CHECK-NEXT: | | | | | | | | `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f1l' '_Float16'
//CHECK-NEXT: | | | | | | | `-CallExpr {{.*}} '_Float16'
//CHECK-NEXT: | | | | | | | |-ImplicitCastExpr {{.*}} '_Float16 (*)(_Float16)' <FunctionToPointerDecay>
//CHECK-NEXT: | | | | | | | | `-DeclRefExpr {{.*}} '_Float16 (_Float16)' lvalue Function {{.*}} 'func1f' '_Float16 (_Float16)'
//CHECK-NEXT: | | | | | | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | | | | | `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f2l' '_Float16'
//CHECK-NEXT: | | | | | | `-CXXMemberCallExpr {{.*}} '_Float16'
//CHECK-NEXT: | | | | | | |-MemberExpr {{.*}} '<bound member function type>' .func1c {{.*}}
//CHECK-NEXT: | | | | | | | `-DeclRefExpr {{.*}} 'C1' lvalue Var {{.*}} 'c1' 'C1'
//CHECK-NEXT: | | | | | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | | | | `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f3l' '_Float16'
//CHECK-NEXT: | | | | | `-CallExpr {{.*}} '_Float16'
//CHECK-NEXT: | | | | | |-ImplicitCastExpr {{.*}} '_Float16 (*)(_Float16)' <FunctionToPointerDecay>
//CHECK-NEXT: | | | | | | `-MemberExpr {{.*}} '_Float16 (_Float16)' lvalue .func2c {{.*}}
//CHECK-NEXT: | | | | | | `-DeclRefExpr {{.*}} 'C1' lvalue Var {{.*}} 'c1' 'C1'
//CHECK-NEXT: | | | | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | | | `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f1l' '_Float16'
//CHECK-NEXT: | | | | `-CallExpr {{.*}} '_Float16':'_Float16'
//CHECK-NEXT: | | | | |-ImplicitCastExpr {{.*}} '_Float16 (*)(_Float16)' <FunctionToPointerDecay>
//CHECK-NEXT: | | | | | `-DeclRefExpr {{.*}} '_Float16 (_Float16)' lvalue Function {{.*}} 'func1t' '_Float16 (_Float16)' (FunctionTemplate {{.*}} 'func1t')
//CHECK-NEXT: | | | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | | `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f1l' '_Float16'
//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | `-MemberExpr {{.*}} '_Float16' lvalue .mem2 {{.*}}
//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} 'S1<_Float16>':'S1<_Float16>' lvalue Var {{.*}} 's1' 'S1<_Float16>':'S1<_Float16>'
//CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f1n' '_Float16'
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f2n' '_Float16'
auto f5l = -1.f16, *f6l = &f2l, f7l = func1t(f3l);
//CHECK: | |-VarDecl {{.*}} f5l '_Float16':'_Float16' cinit
//CHECK-NEXT: | | `-UnaryOperator {{.*}} '_Float16' prefix '-'
//CHECK-NEXT: | | `-FloatingLiteral {{.*}} '_Float16' 1.000000e+00
//CHECK-NEXT: | |-VarDecl {{.*}} f6l '_Float16 *' cinit
//CHECK-NEXT: | | `-UnaryOperator {{.*}} '_Float16 *' prefix '&'
//CHECK-NEXT: | | `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f2l' '_Float16'
//CHECK-NEXT: | `-VarDecl {{.*}} f7l '_Float16':'_Float16' cinit
//CHECK-NEXT: | `-CallExpr {{.*}} '_Float16':'_Float16'
//CHECK-NEXT: | |-ImplicitCastExpr {{.*}} '_Float16 (*)(_Float16)' <FunctionToPointerDecay>
//CHECK-NEXT: | | `-DeclRefExpr {{.*}} '_Float16 (_Float16)' lvalue Function {{.*}} 'func1t' '_Float16 (_Float16)' (FunctionTemplate {{.*}} 'func1t')
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f3l' '_Float16'
_Float16 f8l = f4l++;
//CHECK: | `-VarDecl {{.*}} f8l '_Float16' cinit
//CHECK-NEXT: | `-UnaryOperator {{.*}} '_Float16' postfix '++'
//CHECK-NEXT: | `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f4l' '_Float16'
_Float16 arr1l[] = { -1.f16, -0.f16, -11.f16 };
//CHECK: `-VarDecl {{.*}} arr1l '_Float16[3]' cinit
//CHECK-NEXT: `-InitListExpr {{.*}} '_Float16[3]'
//CHECK-NEXT: |-UnaryOperator {{.*}} '_Float16' prefix '-'
//CHECK-NEXT: | `-FloatingLiteral {{.*}} '_Float16' 1.000000e+00
//CHECK-NEXT: |-UnaryOperator {{.*}} '_Float16' prefix '-'
//CHECK-NEXT: | `-FloatingLiteral {{.*}} '_Float16' 0.000000e+00
//CHECK-NEXT: `-UnaryOperator {{.*}} '_Float16' prefix '-'
//CHECK-NEXT: `-FloatingLiteral {{.*}} '_Float16' 1.100000e+01
float cvtf = f2n;
//CHECK: `-VarDecl {{.*}} cvtf 'float' cinit
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} 'float' <FloatingCast>
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f2n' '_Float16'
double cvtd = f2n;
//CHECK: `-VarDecl {{.*}} cvtd 'double' cinit
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} 'double' <FloatingCast>
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f2n' '_Float16'
long double cvtld = f2n;
//CHECK: `-VarDecl {{.*}} cvtld 'long double' cinit
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} 'long double' <FloatingCast>
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: `-DeclRefExpr {{.*}} '_Float16' lvalue Var {{.*}} 'f2n' '_Float16'
_Float16 f2h = 42.0f;
//CHECK: `-VarDecl {{.*}} f2h '_Float16' cinit
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: `-FloatingLiteral {{.*}} 'float' 4.200000e+01
_Float16 d2h = 42.0;
//CHECK: `-VarDecl {{.*}} d2h '_Float16' cinit
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: `-FloatingLiteral {{.*}} 'double' 4.200000e+01
_Float16 ld2h = 42.0l;
//CHECK: `-VarDecl {{.*}} ld2h '_Float16' cinit
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: `-FloatingLiteral {{.*}} 'long double' 4.200000e+01
}

View File

@ -1,210 +1,210 @@
// RUN: %clang_cc1 -triple i686-mingw32 -ast-dump %s | FileCheck %s
// RUN: %clang_cc1 -triple i686-mingw32 -std=c++1z -ast-dump %s | FileCheck %s -check-prefix=CHECK-1Z
template<class T>
class P {
public:
P(T* t) {}
};
namespace foo {
class A { public: A(int = 0) {} };
enum B {};
typedef int C;
}
// CHECK: VarDecl {{0x[0-9a-fA-F]+}} <line:[[@LINE+1]]:1, col:36> col:15 ImplicitConstrArray 'foo::A[2]'
static foo::A ImplicitConstrArray[2];
int main() {
// CHECK: CXXNewExpr {{0x[0-9a-fA-F]+}} <col:19, col:28> 'foo::A *'
P<foo::A> p14 = new foo::A;
// CHECK: CXXNewExpr {{0x[0-9a-fA-F]+}} <col:19, col:28> 'foo::B *'
P<foo::B> p24 = new foo::B;
// CHECK: CXXNewExpr {{0x[0-9a-fA-F]+}} <col:19, col:28> 'foo::C *'
P<foo::C> pr4 = new foo::C;
}
foo::A getName() {
// CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}} <col:10, col:17> 'foo::A'
return foo::A();
}
void destruct(foo::A *a1, foo::A *a2, P<int> *p1) {
// CHECK: MemberExpr {{0x[0-9a-fA-F]+}} <col:3, col:8> '<bound member function type>' ->~A
a1->~A();
// CHECK: MemberExpr {{0x[0-9a-fA-F]+}} <col:3, col:16> '<bound member function type>' ->~A
a2->foo::A::~A();
// CHECK: MemberExpr {{0x[0-9a-fA-F]+}} <col:3, col:13> '<bound member function type>' ->~P
p1->~P<int>();
}
struct D {
D(int);
~D();
};
void construct() {
using namespace foo;
A a = A(12);
// CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}} <col:9, col:13> 'foo::A' 'void (int){{( __attribute__\(\(thiscall\)\))?}}'
D d = D(12);
// CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}} <col:9, col:13> 'D' 'void (int){{( __attribute__\(\(thiscall\)\))?}}'
}
namespace PR38987 {
struct A { A(); };
template <class T> void f() { T{}; }
template void f<A>();
// CHECK: CXXTemporaryObjectExpr {{.*}} <col:31, col:33> 'PR38987::A':'PR38987::A'
}
void abort() __attribute__((noreturn));
namespace std {
typedef decltype(sizeof(int)) size_t;
template <typename E> struct initializer_list {
const E *p;
size_t n;
initializer_list(const E *p, size_t n) : p(p), n(n) {}
};
template <typename F, typename S> struct pair {
F f;
S s;
pair(const F &f, const S &s) : f(f), s(s) {}
};
struct string {
const char *str;
string() { abort(); }
string(const char *S) : str(S) {}
~string() { abort(); }
};
template<typename K, typename V>
struct map {
using T = pair<K, V>;
map(initializer_list<T> i, const string &s = string()) {}
~map() { abort(); }
};
}; // namespace std
// CHECK: NamespaceDecl {{.*}} attributed_decl
namespace attributed_decl {
void f() {
// CHECK: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:28>
[[maybe_unused]] int i1;
// CHECK: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:35>
__attribute__((unused)) int i2;
// CHECK: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:35>
int __attribute__((unused)) i3;
// CHECK: DeclStmt {{.*}} <<built-in>:{{.*}}, {{.*}}:[[@LINE+1]]:40>
__declspec(dllexport) extern int i4;
// CHECK: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:40>
extern int __declspec(dllexport) i5;
}
}
// CHECK-1Z: NamespaceDecl {{.*}} attributed_case
namespace attributed_case {
void f(int n) {
switch (n) {
case 0:
n--;
// CHECK: AttributedStmt {{.*}} <line:[[@LINE+2]]:5, line:[[@LINE+4]]:35>
// CHECK: FallThroughAttr {{.*}} <line:[[@LINE+1]]:20>
__attribute__((fallthrough))
// CHECK: FallThroughAttr {{.*}} <line:[[@LINE+1]]:22>
__attribute__((fallthrough));
case 1:
n++;
break;
}
}
} // namespace attributed_case
// CHECK: NamespaceDecl {{.*}} attributed_stmt
namespace attributed_stmt {
// In DO_PRAGMA and _Pragma cases, `LoopHintAttr` comes from <scratch space>
// file.
#define DO_PRAGMA(x) _Pragma (#x)
void f() {
// CHECK: AttributedStmt {{.*}} <line:[[@LINE-3]]:24, line:[[@LINE+2]]:33>
DO_PRAGMA (unroll(2))
for (int i = 0; i < 10; ++i);
// CHECK: AttributedStmt {{.*}} <line:[[@LINE+2]]:5, line:[[@LINE+3]]:33>
// CHECK: LoopHintAttr {{.*}} <line:[[@LINE+1]]:13, col:22>
#pragma unroll(2)
for (int i = 0; i < 10; ++i);
// CHECK: AttributedStmt {{.*}} <line:[[@LINE+2]]:5, line:[[@LINE+5]]:33>
// CHECK: LoopHintAttr {{.*}} <line:[[@LINE+1]]:19, col:41>
#pragma clang loop vectorize(enable)
// CHECK: LoopHintAttr {{.*}} <line:[[@LINE+1]]:19, col:42>
#pragma clang loop interleave(enable)
for (int i = 0; i < 10; ++i);
// CHECK: AttributedStmt {{.*}} <line:[[@LINE+1]]:5, line:[[@LINE+2]]:33>
_Pragma("unroll(2)")
for (int i = 0; i < 10; ++i);
}
}
#if __cplusplus >= 201703L
// CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list
std::map<int, int> construct_with_init_list() {
// CHECK-1Z-NEXT: CompoundStmt
// CHECK-1Z-NEXT: ReturnStmt {{.*}} <line:[[@LINE+5]]:3, col:35
// CHECK-1Z-NEXT: ExprWithCleanups {{.*}} <col:10, col:35
// CHECK-1Z-NEXT: CXXBindTemporaryExpr {{.*}} <col:10, col:35
// CHECK-1Z-NEXT: CXXTemporaryObjectExpr {{.*}} <col:10, col:35
// CHECK-1Z-NEXT: CXXStdInitializerListExpr {{.*}} <col:28, col:35
return std::map<int, int>{{0, 0}};
}
// CHECK-1Z: NamespaceDecl {{.*}} in_class_init
namespace in_class_init {
struct A {};
// CHECK-1Z: CXXRecordDecl {{.*}} struct B definition
struct B {
// CHECK-1Z: FieldDecl {{.*}} a 'in_class_init::A'
// CHECK-1Z-NEXT: InitListExpr {{.*}} <col:11, col:12
A a = {};
};
}
// CHECK-1Z: NamespaceDecl {{.*}} delegating_constructor_init
namespace delegating_constructor_init {
struct A {};
struct B : A {
A a;
B(A a) : a(a) {}
};
// CHECK-1Z: CXXRecordDecl {{.*}} struct C definition
struct C : B {
// CHECK-1Z: CXXConstructorDecl {{.*}} C
// CHECK-1Z-NEXT: CXXCtorInitializer 'delegating_constructor_init::B'
// CHECK-1Z-NEXT: CXXConstructExpr {{.*}} <col:11, col:15
// CHECK-1Z-NEXT: InitListExpr {{.*}} <col:13, col:14
C() : B({}) {};
};
}
// CHECK-1Z: NamespaceDecl {{.*}} new_init
namespace new_init {
void A() {
// CHECK-1Z: CXXNewExpr {{.*}} <line:[[@LINE+2]]:5, col:14
// CHECK-1Z-NEXT: InitListExpr {{.*}} <col:12, col:14
new int{0};
}
}
#endif
// RUN: %clang_cc1 -triple i686-mingw32 -ast-dump %s | FileCheck %s
// RUN: %clang_cc1 -triple i686-mingw32 -std=c++1z -ast-dump %s | FileCheck %s -check-prefix=CHECK-1Z
template<class T>
class P {
public:
P(T* t) {}
};
namespace foo {
class A { public: A(int = 0) {} };
enum B {};
typedef int C;
}
// CHECK: VarDecl {{0x[0-9a-fA-F]+}} <line:[[@LINE+1]]:1, col:36> col:15 ImplicitConstrArray 'foo::A[2]'
static foo::A ImplicitConstrArray[2];
int main() {
// CHECK: CXXNewExpr {{0x[0-9a-fA-F]+}} <col:19, col:28> 'foo::A *'
P<foo::A> p14 = new foo::A;
// CHECK: CXXNewExpr {{0x[0-9a-fA-F]+}} <col:19, col:28> 'foo::B *'
P<foo::B> p24 = new foo::B;
// CHECK: CXXNewExpr {{0x[0-9a-fA-F]+}} <col:19, col:28> 'foo::C *'
P<foo::C> pr4 = new foo::C;
}
foo::A getName() {
// CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}} <col:10, col:17> 'foo::A'
return foo::A();
}
void destruct(foo::A *a1, foo::A *a2, P<int> *p1) {
// CHECK: MemberExpr {{0x[0-9a-fA-F]+}} <col:3, col:8> '<bound member function type>' ->~A
a1->~A();
// CHECK: MemberExpr {{0x[0-9a-fA-F]+}} <col:3, col:16> '<bound member function type>' ->~A
a2->foo::A::~A();
// CHECK: MemberExpr {{0x[0-9a-fA-F]+}} <col:3, col:13> '<bound member function type>' ->~P
p1->~P<int>();
}
struct D {
D(int);
~D();
};
void construct() {
using namespace foo;
A a = A(12);
// CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}} <col:9, col:13> 'foo::A' 'void (int){{( __attribute__\(\(thiscall\)\))?}}'
D d = D(12);
// CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}} <col:9, col:13> 'D' 'void (int){{( __attribute__\(\(thiscall\)\))?}}'
}
namespace PR38987 {
struct A { A(); };
template <class T> void f() { T{}; }
template void f<A>();
// CHECK: CXXTemporaryObjectExpr {{.*}} <col:31, col:33> 'PR38987::A':'PR38987::A'
}
void abort() __attribute__((noreturn));
namespace std {
typedef decltype(sizeof(int)) size_t;
template <typename E> struct initializer_list {
const E *p;
size_t n;
initializer_list(const E *p, size_t n) : p(p), n(n) {}
};
template <typename F, typename S> struct pair {
F f;
S s;
pair(const F &f, const S &s) : f(f), s(s) {}
};
struct string {
const char *str;
string() { abort(); }
string(const char *S) : str(S) {}
~string() { abort(); }
};
template<typename K, typename V>
struct map {
using T = pair<K, V>;
map(initializer_list<T> i, const string &s = string()) {}
~map() { abort(); }
};
}; // namespace std
// CHECK: NamespaceDecl {{.*}} attributed_decl
namespace attributed_decl {
void f() {
// CHECK: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:28>
[[maybe_unused]] int i1;
// CHECK: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:35>
__attribute__((unused)) int i2;
// CHECK: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:35>
int __attribute__((unused)) i3;
// CHECK: DeclStmt {{.*}} <<built-in>:{{.*}}, {{.*}}:[[@LINE+1]]:40>
__declspec(dllexport) extern int i4;
// CHECK: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:40>
extern int __declspec(dllexport) i5;
}
}
// CHECK-1Z: NamespaceDecl {{.*}} attributed_case
namespace attributed_case {
void f(int n) {
switch (n) {
case 0:
n--;
// CHECK: AttributedStmt {{.*}} <line:[[@LINE+2]]:5, line:[[@LINE+4]]:35>
// CHECK: FallThroughAttr {{.*}} <line:[[@LINE+1]]:20>
__attribute__((fallthrough))
// CHECK: FallThroughAttr {{.*}} <line:[[@LINE+1]]:22>
__attribute__((fallthrough));
case 1:
n++;
break;
}
}
} // namespace attributed_case
// CHECK: NamespaceDecl {{.*}} attributed_stmt
namespace attributed_stmt {
// In DO_PRAGMA and _Pragma cases, `LoopHintAttr` comes from <scratch space>
// file.
#define DO_PRAGMA(x) _Pragma (#x)
void f() {
// CHECK: AttributedStmt {{.*}} <line:[[@LINE-3]]:24, line:[[@LINE+2]]:33>
DO_PRAGMA (unroll(2))
for (int i = 0; i < 10; ++i);
// CHECK: AttributedStmt {{.*}} <line:[[@LINE+2]]:5, line:[[@LINE+3]]:33>
// CHECK: LoopHintAttr {{.*}} <line:[[@LINE+1]]:13, col:22>
#pragma unroll(2)
for (int i = 0; i < 10; ++i);
// CHECK: AttributedStmt {{.*}} <line:[[@LINE+2]]:5, line:[[@LINE+5]]:33>
// CHECK: LoopHintAttr {{.*}} <line:[[@LINE+1]]:19, col:41>
#pragma clang loop vectorize(enable)
// CHECK: LoopHintAttr {{.*}} <line:[[@LINE+1]]:19, col:42>
#pragma clang loop interleave(enable)
for (int i = 0; i < 10; ++i);
// CHECK: AttributedStmt {{.*}} <line:[[@LINE+1]]:5, line:[[@LINE+2]]:33>
_Pragma("unroll(2)")
for (int i = 0; i < 10; ++i);
}
}
#if __cplusplus >= 201703L
// CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list
std::map<int, int> construct_with_init_list() {
// CHECK-1Z-NEXT: CompoundStmt
// CHECK-1Z-NEXT: ReturnStmt {{.*}} <line:[[@LINE+5]]:3, col:35
// CHECK-1Z-NEXT: ExprWithCleanups {{.*}} <col:10, col:35
// CHECK-1Z-NEXT: CXXBindTemporaryExpr {{.*}} <col:10, col:35
// CHECK-1Z-NEXT: CXXTemporaryObjectExpr {{.*}} <col:10, col:35
// CHECK-1Z-NEXT: CXXStdInitializerListExpr {{.*}} <col:28, col:35
return std::map<int, int>{{0, 0}};
}
// CHECK-1Z: NamespaceDecl {{.*}} in_class_init
namespace in_class_init {
struct A {};
// CHECK-1Z: CXXRecordDecl {{.*}} struct B definition
struct B {
// CHECK-1Z: FieldDecl {{.*}} a 'in_class_init::A'
// CHECK-1Z-NEXT: InitListExpr {{.*}} <col:11, col:12
A a = {};
};
}
// CHECK-1Z: NamespaceDecl {{.*}} delegating_constructor_init
namespace delegating_constructor_init {
struct A {};
struct B : A {
A a;
B(A a) : a(a) {}
};
// CHECK-1Z: CXXRecordDecl {{.*}} struct C definition
struct C : B {
// CHECK-1Z: CXXConstructorDecl {{.*}} C
// CHECK-1Z-NEXT: CXXCtorInitializer 'delegating_constructor_init::B'
// CHECK-1Z-NEXT: CXXConstructExpr {{.*}} <col:11, col:15
// CHECK-1Z-NEXT: InitListExpr {{.*}} <col:13, col:14
C() : B({}) {};
};
}
// CHECK-1Z: NamespaceDecl {{.*}} new_init
namespace new_init {
void A() {
// CHECK-1Z: CXXNewExpr {{.*}} <line:[[@LINE+2]]:5, col:14
// CHECK-1Z-NEXT: InitListExpr {{.*}} <col:12, col:14
new int{0};
}
}
#endif