| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| --- | ||
| Name: Fields | ||
| Tags: | ||
| - Name: IntWrapper | ||
| Fields: | ||
| - Name: value | ||
| Availability: none | ||
| AvailabilityMsg: "oh no" | ||
| - Name: Outer | ||
| Tags: | ||
| - Name: Inner | ||
| Fields: | ||
| - Name: value | ||
| Availability: none | ||
| AvailabilityMsg: "oh no 2" | ||
| Methods: | ||
| - Name: value | ||
| Availability: none | ||
| AvailabilityMsg: "this should have no effect" | ||
| Functions: | ||
| - Name: value | ||
| Availability: none | ||
| AvailabilityMsg: "this should have no effect" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| struct IntWrapper { | ||
| int value; | ||
|
|
||
| bool : 1; | ||
|
|
||
| enum { | ||
| one, | ||
| two, | ||
| three | ||
| }; | ||
| union { | ||
| int a; | ||
| char b; | ||
| }; | ||
| }; | ||
|
|
||
| struct Outer { | ||
| struct Inner { | ||
| int value; | ||
| }; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // RUN: rm -rf %t && mkdir -p %t | ||
| // RUN: %clang_cc1 -fmodules -fblocks -fimplicit-module-maps -fmodules-cache-path=%t/ModulesCache/Fields -fdisable-module-hash -fapinotes-modules -fsyntax-only -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s -x c++ | ||
| // RUN: %clang_cc1 -fmodules -fblocks -fimplicit-module-maps -fmodules-cache-path=%t/ModulesCache/Fields -fdisable-module-hash -fapinotes-modules -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s -ast-dump -ast-dump-filter IntWrapper::value -x c++ | FileCheck --check-prefix=CHECK-FIELD %s | ||
| // RUN: %clang_cc1 -fmodules -fblocks -fimplicit-module-maps -fmodules-cache-path=%t/ModulesCache/Fields -fdisable-module-hash -fapinotes-modules -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s -ast-dump -ast-dump-filter Outer::Inner::value -x c++ | FileCheck --check-prefix=CHECK-DEEP-FIELD %s | ||
|
|
||
| #include "Fields.h" | ||
|
|
||
| // CHECK-FIELD: Dumping IntWrapper::value: | ||
| // CHECK-FIELD-NEXT: FieldDecl {{.+}} value | ||
| // CHECK-FIELD: UnavailableAttr {{.+}} <<invalid sloc>> "oh no" | ||
|
|
||
| // CHECK-DEEP-FIELD: Dumping Outer::Inner::value: | ||
| // CHECK-DEEP-FIELD-NEXT: FieldDecl {{.+}} value | ||
| // CHECK-DEEP-FIELD: UnavailableAttr {{.+}} <<invalid sloc>> "oh no 2" | ||
|
|
||
| // CHECK-FIELD-NOT: this should have no effect | ||
| // CHECK-DEEP-FIELD-NOT: this should have no effect |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // RUN: %clang_cc1 -fsyntax-only -ast-dump -std=c++2c %s | FileCheck %s | ||
| // RUN: %clang_cc1 -ast-print -std=c++2c %s | FileCheck %s --check-prefix=PRINT | ||
| // RUN: %clang_cc1 -emit-pch -std=c++2c -o %t %s | ||
| // RUN: %clang_cc1 -x c++ -std=c++2c -include-pch %t -ast-dump-all /dev/null | ||
|
|
||
| struct S; | ||
| template <typename> struct TS; // #template | ||
|
|
||
| // CHECK-LABEL: CXXRecordDecl {{.*}} struct Friends | ||
| // PRINT-LABEL: struct Friends { | ||
| struct Friends { | ||
| // CHECK: FriendDecl {{.*}} 'int' | ||
| // CHECK-NEXT: FriendDecl {{.*}} 'long' | ||
| // PRINT-NEXT: friend int; | ||
| // PRINT-NEXT: friend long; | ||
| friend int, long; | ||
|
|
||
| // CHECK-NEXT: FriendDecl {{.*}} 'int' | ||
| // CHECK-NEXT: FriendDecl {{.*}} 'long' | ||
| // CHECK-NEXT: FriendDecl {{.*}} 'char' | ||
| // PRINT-NEXT: friend int; | ||
| // PRINT-NEXT: friend long; | ||
| // PRINT-NEXT: friend char; | ||
| friend int, long, char; | ||
|
|
||
| // CHECK-NEXT: FriendDecl {{.*}} 'S' | ||
| // PRINT-NEXT: friend S; | ||
| friend S; | ||
|
|
||
| // CHECK-NEXT: FriendDecl {{.*}} 'S' | ||
| // CHECK-NEXT: FriendDecl {{.*}} 'S' | ||
| // CHECK-NEXT: FriendDecl {{.*}} 'S' | ||
| // PRINT-NEXT: friend S; | ||
| // PRINT-NEXT: friend S; | ||
| // PRINT-NEXT: friend S; | ||
| friend S, S, S; | ||
|
|
||
| // CHECK-NEXT: FriendDecl | ||
| // CHECK-NEXT: ClassTemplateDecl {{.*}} friend TS | ||
| // PRINT-NEXT: friend template <typename> struct TS; | ||
| template <typename> friend struct TS; | ||
| }; | ||
|
|
||
| namespace specialisations { | ||
| template<class T> | ||
| struct C { | ||
| template<class U> struct Nested; | ||
| }; | ||
|
|
||
| struct N { | ||
| template<class U> class C; | ||
| }; | ||
|
|
||
| // CHECK-LABEL: ClassTemplateDecl {{.*}} Variadic | ||
| // PRINT-LABEL: template <typename ...Pack> struct Variadic { | ||
| template <typename ...Pack> struct Variadic { | ||
| // CHECK: FriendDecl {{.*}} 'Pack'... | ||
| // CHECK-NEXT: FriendDecl {{.*}} 'long' | ||
| // CHECK-NEXT: FriendDecl {{.*}} 'Pack'... | ||
| // PRINT-NEXT: friend Pack...; | ||
| // PRINT-NEXT: friend long; | ||
| // PRINT-NEXT: friend Pack...; | ||
| friend Pack..., long, Pack...; | ||
|
|
||
| // CHECK-NEXT: FriendDecl {{.*}} 'TS<Pack>'... | ||
| // PRINT-NEXT: friend TS<Pack>...; | ||
| friend TS<Pack>...; | ||
| }; | ||
|
|
||
| // CHECK-LABEL: ClassTemplateDecl {{.*}} S2 | ||
| // PRINT-LABEL: template <class ...Ts> struct S2 { | ||
| template<class ...Ts> struct S2 { | ||
| // CHECK: FriendDecl {{.*}} 'class C<Ts>':'C<Ts>'... | ||
| // PRINT-NEXT: friend class C<Ts>...; | ||
| friend class C<Ts>...; | ||
|
|
||
| // CHECK-NEXT: FriendDecl {{.*}} 'class N::C<Ts>':'C<Ts>'... | ||
| // PRINT-NEXT: friend class N::C<Ts>... | ||
| friend class N::C<Ts>...; | ||
| }; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // RUN: %clang_cc1 -std=c++98 -pedantic-errors -verify=expected,cxx98 %s | ||
| // RUN: %clang_cc1 -std=c++11 -pedantic-errors -verify=expected %s | ||
| // RUN: %clang_cc1 -std=c++14 -pedantic-errors -verify=expected %s | ||
| // RUN: %clang_cc1 -std=c++17 -pedantic-errors -verify=expected %s | ||
| // RUN: %clang_cc1 -std=c++20 -pedantic-errors -verify=expected %s | ||
| // RUN: %clang_cc1 -std=c++23 -pedantic-errors -verify=expected %s | ||
| // RUN: %clang_cc1 -std=c++2c -pedantic-errors -verify=expected %s | ||
|
|
||
| namespace cwg2917 { // cwg2917: 20 open 2024-07-30 | ||
| template <typename> | ||
| class Foo; | ||
|
|
||
| template<class ...> // cxx98-error {{variadic templates are a C++11 extension}} | ||
| struct C { | ||
| struct Nested { }; | ||
| }; | ||
|
|
||
| struct S { | ||
| template <typename> | ||
| friend class Foo, int; // expected-error {{a friend declaration that befriends a template must contain exactly one type-specifier}} | ||
|
|
||
| template <typename ...Ts> // cxx98-error {{variadic templates are a C++11 extension}} | ||
| friend class C<Ts>::Nested...; // expected-error {{friend declaration expands pack 'Ts' that is declared it its own template parameter list}} | ||
| }; | ||
| } // namespace cwg2917 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // REQUIRES: x86-registered-target | ||
| // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -Wno-constant-conversion -Wno-array-bounds -Wno-division-by-zero -Wno-shift-negative-value -Wno-shift-count-negative -Wno-int-to-pointer-cast -fsanitize=array-bounds,enum,float-cast-overflow,integer-divide-by-zero,implicit-unsigned-integer-truncation,implicit-signed-integer-truncation,implicit-integer-sign-change,unsigned-integer-overflow,signed-integer-overflow,shift-base,shift-exponent -O0 -emit-llvm -o - %s | FileCheck %s | ||
|
|
||
| // The runtime test checking the _BitInt ubsan feature is located in compiler-rt/test/ubsan/TestCases/Integer/bit-int.c | ||
|
|
||
| typedef unsigned int uint32_t; | ||
| uint32_t float_divide_by_zero() { | ||
| float f = 1.0f / 0.0f; | ||
| // CHECK: constant { i16, i16, [8 x i8] } { i16 1, i16 32, [8 x i8] c"'float'\00" } | ||
| _BitInt(37) r = (_BitInt(37))f; | ||
| // CHECK: constant { i16, i16, [20 x i8] } { i16 2, i16 13, [20 x i8] c"'_BitInt(37)'\00%\00\00\00\00\00" } | ||
| return r; | ||
| } | ||
|
|
||
| uint32_t integer_divide_by_zero() __attribute__((no_sanitize("memory"))) { | ||
| _BitInt(37) x = 1 / 0; | ||
| // CHECK: constant { i16, i16, [32 x i8] } { i16 0, i16 10, [32 x i8] c"'uint32_t' (aka 'unsigned int')\00" } | ||
| return x; | ||
| } | ||
|
|
||
| uint32_t implicit_unsigned_integer_truncation() { | ||
| unsigned _BitInt(37) x = 2U; | ||
| x += float_divide_by_zero(); | ||
| x += integer_divide_by_zero(); | ||
| x = x + 0xFFFFFFFFFFFFFFFFULL; | ||
| // CHECK: constant { i16, i16, [23 x i8] } { i16 0, i16 12, [23 x i8] c"'unsigned _BitInt(37)'\00" } | ||
| uint32_t r = x & 0xFFFFFFFF; | ||
| return r; | ||
| } | ||
|
|
||
| uint32_t array_bounds() { | ||
| _BitInt(37) x[4]; | ||
| _BitInt(37) y = x[10]; | ||
| // CHECK: constant { i16, i16, [17 x i8] } { i16 -1, i16 0, [17 x i8] c"'_BitInt(37)[4]'\00" } | ||
| return (uint32_t)y; | ||
| } | ||
|
|
||
| uint32_t float_cast_overflow() { | ||
| float a = 100000000.0f; | ||
| _BitInt(7) b = (_BitInt(7))a; | ||
| // CHECK: constant { i16, i16, [19 x i8] } { i16 2, i16 7, [19 x i8] c"'_BitInt(7)'\00\07\00\00\00\00\00" } | ||
| return b; | ||
| } | ||
|
|
||
| _BitInt(13) implicit_signed_integer_truncation() { | ||
| _BitInt(73) x = (_BitInt(73)) ~((~0UL) >> 1); | ||
| return x; | ||
| // CHECK: constant { i16, i16, [20 x i8] } { i16 2, i16 {{([[:xdigit:]]{2})}}, [20 x i8] c"'_BitInt(73)'\00I\00\00\00\00\00" } | ||
| // CHECK: constant { i16, i16, [20 x i8] } { i16 2, i16 9, [20 x i8] c"'_BitInt(13)'\00\0D\00\00\00\00\00" } | ||
| } | ||
|
|
||
| uint32_t negative_shift1(unsigned _BitInt(37) x) | ||
| __attribute__((no_sanitize("memory"))) { | ||
| _BitInt(9) c = -2; | ||
| return x >> c; | ||
| // CHECK: constant { i16, i16, [19 x i8] } { i16 2, i16 9, [19 x i8] c"'_BitInt(9)'\00\09\00\00\00\00\00" } | ||
| } | ||
|
|
||
| uint32_t negative_shift2(unsigned _BitInt(37) x) | ||
| __attribute__((no_sanitize("memory"))) { | ||
| _BitInt(17) c = -2; | ||
| return x >> c; | ||
| // CHECK: constant { i16, i16, [20 x i8] } { i16 2, i16 11, [20 x i8] c"'_BitInt(17)'\00\11\00\00\00\00\00" } | ||
| } | ||
|
|
||
| uint32_t negative_shift3(unsigned _BitInt(37) x) | ||
| __attribute__((no_sanitize("memory"))) { | ||
| _BitInt(34) c = -2; | ||
| return x >> c; | ||
| // CHECK: constant { i16, i16, [20 x i8] } { i16 2, i16 13, [20 x i8] c"'_BitInt(34)'\00\22\00\00\00\00\00" } | ||
| } | ||
|
|
||
| uint32_t negative_shift5(unsigned _BitInt(37) x) | ||
| __attribute__((no_sanitize("memory"))) { | ||
| _BitInt(68) c = -2; | ||
| return x >> c; | ||
| // CHECK: constant { i16, i16, [20 x i8] } { i16 2, i16 {{([[:xdigit:]]{2})}}, [20 x i8] c"'_BitInt(68)'\00D\00\00\00\00\00" } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -emit-llvm -xhlsl -o - %s | FileCheck %s | ||
|
|
||
| // CHECK:!dx.valver = !{![[valver:[0-9]+]]} | ||
| // CHECK:![[valver]] = !{i32 1, i32 8} | ||
|
|
||
| float bar(float a, float b); | ||
|
|
||
| float foo(float a, float b) { | ||
| return bar(a, b); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| // RUN: %clang -### -c --target=x86_64 -march=x86-64 -Wa,-msse2avx %s 2>&1 | FileCheck %s | ||
| // RUN: %clang -### -c --target=x86_64 -march=x86-64 -x assembler -Xassembler -msse2avx %s 2>&1 | FileCheck %s | ||
|
|
||
| // CHECK: "-msse2avx" | ||
|
|
||
| // RUN: not %clang -### -c --target=aarch64 -march=armv8a -Wa,-msse2avx %s 2>&1 | FileCheck --check-prefix=ERR %s | ||
| // ERR: error: unsupported argument '-msse2avx' to option '-Wa,' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,13 @@ | ||
| // RUN: %clang -### --target=x86_64 -c -Wa,--mrelax-relocations=no %s 2>&1 | FileCheck %s | ||
|
|
||
| // CHECK: "-cc1" | ||
| // CHECK: "-mrelax-relocations=no" | ||
|
|
||
| // RUN: not %clang -### --target=x86_64 -c -Wa,-mrelax-relocations=x %s 2>&1 | FileCheck %s --check-prefix=ERR | ||
| // ERR: error: unsupported argument 'x' to option '-Wa,-mrelax-relocations=' | ||
|
|
||
| // RUN: not %clang -### --target=aarch64 -c -Wa,-mrelax-relocations=no %s 2>&1 | FileCheck %s --check-prefix=ERR2 | ||
| // ERR2: error: unsupported argument '-mrelax-relocations=no' to option '-Wa,' | ||
|
|
||
| // RUN: not %clang -### --target=x86_64-apple-darwin -c -Wa,-mrelax-relocations=no %s 2>&1 | FileCheck %s --check-prefix=ERR3 | ||
| // ERR3: error: unsupported option '-Wa,-mrelax-relocations=' for target 'x86_64-apple-darwin' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,175 @@ | ||
| // RUN: rm -rf %t | ||
| // RUN: %clang_cc1 -extract-api --pretty-sgf --emit-sgf-symbol-labels-for-testing -triple arm64-apple-macosx \ | ||
| // RUN: -x objective-c-header %s -o %t/output.symbols.json -verify | ||
|
|
||
|
|
||
| // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix A | ||
| __attribute__((availability(macos, introduced=9.0, deprecated=12.0, obsoleted=20.0))) | ||
| @interface A | ||
| // A-LABEL: "!testLabel": "c:objc(cs)A" | ||
| // A: "availability": [ | ||
| // A-NEXT: { | ||
| // A-NEXT: "deprecated": { | ||
| // A-NEXT: "major": 12, | ||
| // A-NEXT: "minor": 0, | ||
| // A-NEXT: "patch": 0 | ||
| // A-NEXT: } | ||
| // A-NEXT: "domain": "macos" | ||
| // A-NEXT: "introduced": { | ||
| // A-NEXT: "major": 9, | ||
| // A-NEXT: "minor": 0, | ||
| // A-NEXT: "patch": 0 | ||
| // A-NEXT: } | ||
| // A-NEXT: "obsoleted": { | ||
| // A-NEXT: "major": 20, | ||
| // A-NEXT: "minor": 0, | ||
| // A-NEXT: "patch": 0 | ||
| // A-NEXT: } | ||
| // A-NEXT: } | ||
| // A-NEXT: ] | ||
|
|
||
| // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix CP | ||
| @property(class) int CP; | ||
| // CP-LABEL: "!testLabel": "c:objc(cs)A(cpy)CP" | ||
| // CP: "availability": [ | ||
| // CP-NEXT: { | ||
| // CP-NEXT: "deprecated": { | ||
| // CP-NEXT: "major": 12, | ||
| // CP-NEXT: "minor": 0, | ||
| // CP-NEXT: "patch": 0 | ||
| // CP-NEXT: } | ||
| // CP-NEXT: "domain": "macos" | ||
| // CP-NEXT: "introduced": { | ||
| // CP-NEXT: "major": 9, | ||
| // CP-NEXT: "minor": 0, | ||
| // CP-NEXT: "patch": 0 | ||
| // CP-NEXT: } | ||
| // CP-NEXT: "obsoleted": { | ||
| // CP-NEXT: "major": 20, | ||
| // CP-NEXT: "minor": 0, | ||
| // CP-NEXT: "patch": 0 | ||
| // CP-NEXT: } | ||
| // CP-NEXT: } | ||
| // CP-NEXT: ] | ||
|
|
||
| // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix IP | ||
| @property int IP; | ||
| // IP-LABEL: "!testLabel": "c:objc(cs)A(py)IP" | ||
| // IP: "availability": [ | ||
| // IP-NEXT: { | ||
| // IP-NEXT: "deprecated": { | ||
| // IP-NEXT: "major": 12, | ||
| // IP-NEXT: "minor": 0, | ||
| // IP-NEXT: "patch": 0 | ||
| // IP-NEXT: } | ||
| // IP-NEXT: "domain": "macos" | ||
| // IP-NEXT: "introduced": { | ||
| // IP-NEXT: "major": 9, | ||
| // IP-NEXT: "minor": 0, | ||
| // IP-NEXT: "patch": 0 | ||
| // IP-NEXT: } | ||
| // IP-NEXT: "obsoleted": { | ||
| // IP-NEXT: "major": 20, | ||
| // IP-NEXT: "minor": 0, | ||
| // IP-NEXT: "patch": 0 | ||
| // IP-NEXT: } | ||
| // IP-NEXT: } | ||
| // IP-NEXT: ] | ||
|
|
||
| // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix MR | ||
| @property int moreRestrictive __attribute__((availability(macos, introduced=10.0, deprecated=11.0, obsoleted=19.0))); | ||
| // MR-LABEL: "!testLabel": "c:objc(cs)A(py)moreRestrictive" | ||
| // MR: "availability": [ | ||
| // MR-NEXT: { | ||
| // MR-NEXT: "deprecated": { | ||
| // MR-NEXT: "major": 11, | ||
| // MR-NEXT: "minor": 0, | ||
| // MR-NEXT: "patch": 0 | ||
| // MR-NEXT: } | ||
| // MR-NEXT: "domain": "macos" | ||
| // MR-NEXT: "introduced": { | ||
| // MR-NEXT: "major": 10, | ||
| // MR-NEXT: "minor": 0, | ||
| // MR-NEXT: "patch": 0 | ||
| // MR-NEXT: } | ||
| // MR-NEXT: "obsoleted": { | ||
| // MR-NEXT: "major": 19, | ||
| // MR-NEXT: "minor": 0, | ||
| // MR-NEXT: "patch": 0 | ||
| // MR-NEXT: } | ||
| // MR-NEXT: } | ||
| // MR-NEXT: ] | ||
|
|
||
| @end | ||
|
|
||
| // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix B | ||
| __attribute__((deprecated("B is deprecated"))) | ||
| @interface B | ||
| // B-LABEL: "!testLabel": "c:objc(cs)B" | ||
| // B: "availability": [ | ||
| // B-NEXT: { | ||
| // B-NEXT: "domain": "*" | ||
| // B-NEXT: "isUnconditionallyDeprecated": true | ||
| // B-NEXT: } | ||
| // B-NEXT: ] | ||
|
|
||
| // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix BIP | ||
| @property int BIP; | ||
| // BIP-LABEL: "!testLabel": "c:objc(cs)B(py)BIP" | ||
| // BIP: "availability": [ | ||
| // BIP-NEXT: { | ||
| // BIP-NEXT: "domain": "*" | ||
| // BIP-NEXT: "isUnconditionallyDeprecated": true | ||
| // BIP-NEXT: } | ||
| // BIP-NEXT: ] | ||
| @end | ||
|
|
||
| // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix C | ||
| __attribute__((availability(macos, unavailable))) | ||
| @interface C | ||
| // C-LABEL: "!testLabel": "c:objc(cs)C" | ||
| // C: "availability": [ | ||
| // C-NEXT: { | ||
| // C-NEXT: "domain": "macos" | ||
| // C-NEXT: "isUnconditionallyUnavailable": true | ||
| // C-NEXT: } | ||
| // C-NEXT: ] | ||
|
|
||
| // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix CIP | ||
| @property int CIP; | ||
| // CIP-LABEL: "!testLabel": "c:objc(cs)C(py)CIP" | ||
| // CIP: "availability": [ | ||
| // CIP-NEXT: { | ||
| // CIP-NEXT: "domain": "macos" | ||
| // CIP-NEXT: "isUnconditionallyUnavailable": true | ||
| // CIP-NEXT: } | ||
| // CIP-NEXT: ] | ||
| @end | ||
|
|
||
| @interface D | ||
| // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix DIP | ||
| @property int DIP __attribute__((availability(macos, introduced=10.0, deprecated=11.0, obsoleted=19.0))); | ||
| // DIP-LABEL: "!testLabel": "c:objc(cs)D(py)DIP" | ||
| // DIP: "availability": [ | ||
| // DIP-NEXT: { | ||
| // DIP-NEXT: "deprecated": { | ||
| // DIP-NEXT: "major": 11, | ||
| // DIP-NEXT: "minor": 0, | ||
| // DIP-NEXT: "patch": 0 | ||
| // DIP-NEXT: } | ||
| // DIP-NEXT: "domain": "macos" | ||
| // DIP-NEXT: "introduced": { | ||
| // DIP-NEXT: "major": 10, | ||
| // DIP-NEXT: "minor": 0, | ||
| // DIP-NEXT: "patch": 0 | ||
| // DIP-NEXT: } | ||
| // DIP-NEXT: "obsoleted": { | ||
| // DIP-NEXT: "major": 19, | ||
| // DIP-NEXT: "minor": 0, | ||
| // DIP-NEXT: "patch": 0 | ||
| // DIP-NEXT: } | ||
| // DIP-NEXT: } | ||
| // DIP-NEXT: ] | ||
| @end | ||
|
|
||
| // expected-no-diagnostics |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // RUN: %clang_cc1 -extract-api --pretty-sgf -triple arm64-apple-ios17.1-macabi \ | ||
| // RUN: -x c-header %s -verify -o - | FileCheck %s | ||
|
|
||
| int a; | ||
|
|
||
| // CHECK: "platform": { | ||
| // CHECK-NEXT: "architecture": "arm64", | ||
| // CHECK-NEXT: "environment": "macabi", | ||
| // CHECK-NEXT: "operatingSystem": { | ||
| // CHECK-NEXT: "minimumVersion": { | ||
| // CHECK-NEXT: "major": 14, | ||
| // CHECK-NEXT: "minor": 0, | ||
| // CHECK-NEXT: "patch": 0 | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "name": "ios" | ||
| // CHECK-NEXT: }, | ||
| // CHECK-NEXT: "vendor": "apple" | ||
| // CHECK-NEXT: } | ||
|
|
||
| // expected-no-diagnostics |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 | ||
| // RUN: %clang_cc1 -include __clang_hip_runtime_wrapper.h \ | ||
| // RUN: -internal-isystem %S/../../lib/Headers/cuda_wrappers \ | ||
| // RUN: -internal-isystem %S/Inputs/include \ | ||
| // RUN: -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown \ | ||
| // RUN: -target-cpu gfx906 -emit-llvm %s -fcuda-is-device -o - \ | ||
| // RUN: -D __CLANG_GPU_DISABLE_MATH_WRAPPERS | FileCheck -check-prefix=AMDGPU %s | ||
|
|
||
| // RUN: %clang_cc1 -include __clang_cuda_runtime_wrapper.h \ | ||
| // RUN: -internal-isystem %S/../../lib/Headers/cuda_wrappers \ | ||
| // RUN: -internal-isystem %S/Inputs/include \ | ||
| // RUN: -triple nvptx64-nvidia-cuda -aux-triple x86_64-unknown-unknown \ | ||
| // RUN: -target-cpu sm_90 -emit-llvm %s -fcuda-is-device -o - \ | ||
| // RUN: -D __CLANG_GPU_DISABLE_MATH_WRAPPERS | FileCheck -check-prefix=NVPTX %s | ||
|
|
||
| extern "C" double sin(double x); | ||
|
|
||
| // AMDGPU-LABEL: define dso_local noundef double @_Z3food( | ||
| // AMDGPU-SAME: double noundef [[X:%.*]]) #[[ATTR0:[0-9]+]] { | ||
| // AMDGPU-NEXT: [[ENTRY:.*:]] | ||
| // AMDGPU-NEXT: [[RETVAL:%.*]] = alloca double, align 8, addrspace(5) | ||
| // AMDGPU-NEXT: [[X_ADDR:%.*]] = alloca double, align 8, addrspace(5) | ||
| // AMDGPU-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr | ||
| // AMDGPU-NEXT: [[X_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[X_ADDR]] to ptr | ||
| // AMDGPU-NEXT: store double [[X]], ptr [[X_ADDR_ASCAST]], align 8 | ||
| // AMDGPU-NEXT: [[TMP0:%.*]] = load double, ptr [[X_ADDR_ASCAST]], align 8 | ||
| // AMDGPU-NEXT: [[TMP1:%.*]] = call double @llvm.sin.f64(double [[TMP0]]) | ||
| // AMDGPU-NEXT: ret double [[TMP1]] | ||
| // | ||
| // NVPTX-LABEL: define dso_local noundef double @_Z3food( | ||
| // NVPTX-SAME: double noundef [[X:%.*]]) #[[ATTR0:[0-9]+]] { | ||
| // NVPTX-NEXT: [[ENTRY:.*:]] | ||
| // NVPTX-NEXT: [[X_ADDR:%.*]] = alloca double, align 8 | ||
| // NVPTX-NEXT: store double [[X]], ptr [[X_ADDR]], align 8 | ||
| // NVPTX-NEXT: [[TMP0:%.*]] = load double, ptr [[X_ADDR]], align 8 | ||
| // NVPTX-NEXT: [[TMP1:%.*]] = call double @llvm.sin.f64(double [[TMP0]]) | ||
| // NVPTX-NEXT: ret double [[TMP1]] | ||
| // | ||
| double foo(double x) { | ||
| return sin(x); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // RUN: %clang_cc1 -std=c++2c -verify=compat -fsyntax-only -Wpre-c++26-compat %s | ||
| // RUN: %clang_cc1 -std=c++11 -verify=pre2c -fsyntax-only -Wc++26-extensions %s | ||
|
|
||
| struct S { | ||
| friend int, long, char; // compat-warning {{variadic 'friend' declarations are incompatible with C++ standards before C++2c}} \ | ||
| // pre2c-warning {{variadic 'friend' declarations are a C++2c extension}} | ||
| }; | ||
|
|
||
| template <typename ...Types> | ||
| struct TS { | ||
| friend Types...; // compat-warning {{variadic 'friend' declarations are incompatible with C++ standards before C++2c}} \ | ||
| // pre2c-warning {{variadic 'friend' declarations are a C++2c extension}} | ||
|
|
||
| friend int, Types..., Types...; // compat-warning {{variadic 'friend' declarations are incompatible with C++ standards before C++2c}} \ | ||
| // pre2c-warning {{variadic 'friend' declarations are a C++2c extension}} | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| // RUN: %clang_cc1 -fsyntax-only -verify -std=c++2c %s | ||
|
|
||
| template <typename> struct TS; // #template | ||
|
|
||
| struct Errors { | ||
| friend int, int; | ||
| friend int, long, char; | ||
|
|
||
| // We simply diagnose and ignore the '...' here. | ||
| friend float...; // expected-error {{pack expansion does not contain any unexpanded parameter packs}} | ||
|
|
||
| friend short..., unsigned, unsigned short...; // expected-error 2 {{pack expansion does not contain any unexpanded parameter packs}} | ||
|
|
||
| template <typename> | ||
| friend struct TS, int; // expected-error {{a friend declaration that befriends a template must contain exactly one type-specifier}} | ||
|
|
||
| double friend; // expected-error {{'friend' must appear first in a non-function declaration}} | ||
| double friend, double; // expected-error {{expected member name or ';' after declaration specifiers}} | ||
| }; | ||
|
|
||
| template <typename> | ||
| struct C { template<class T> class Nested; }; | ||
|
|
||
| template <typename, typename> | ||
| struct D { template<class T> class Nested; }; | ||
|
|
||
| template <bool> | ||
| struct E { template<class T> class Nested; }; | ||
|
|
||
| template<class... Ts> // expected-note {{template parameter is declared here}} | ||
| struct VS { | ||
| friend Ts...; | ||
|
|
||
| friend class Ts...; // expected-error {{declaration of 'Ts' shadows template parameter}} | ||
| // expected-error@-1 {{pack expansion does not contain any unexpanded parameter packs}} | ||
|
|
||
| // TODO: Fix-it hint to insert '...'. | ||
| friend Ts; // expected-error {{friend declaration contains unexpanded parameter pack}} | ||
|
|
||
| template<class... Us> | ||
| friend Us...; // expected-error {{friend type templates must use an elaborated type}} | ||
|
|
||
| template<class... Us> // expected-note {{is declared here}} | ||
| friend class Us...; // expected-error {{declaration of 'Us' shadows template parameter}} | ||
|
|
||
| template<class U> | ||
| friend class C<Ts>::template Nested<U>...; // expected-error {{cannot specialize a dependent template}} | ||
|
|
||
| template<class... Us> | ||
| friend class C<Ts...>::template Nested<Us>...; // expected-error {{cannot specialize a dependent template}} | ||
|
|
||
| // Nonsense (see CWG 2917). | ||
| template<class... Us> | ||
| friend class C<Us>::Nested...; // expected-error {{friend declaration expands pack 'Us' that is declared it its own template parameter list}} | ||
|
|
||
| template<bool... Bs> | ||
| friend class E<Bs>::Nested...; // expected-error {{friend declaration expands pack 'Bs' that is declared it its own template parameter list}} | ||
|
|
||
| // FIXME: Both of these should be valid, but we can't handle these at | ||
| // the moment because the NNS is dependent. | ||
| template<class ...T> | ||
| friend class TS<Ts>::Nested...; // expected-warning {{dependent nested name specifier 'TS<Ts>::' for friend template declaration is not supported; ignoring this friend declaration}} | ||
|
|
||
| template<class T> | ||
| friend class D<T, Ts>::Nested...; // expected-warning {{dependent nested name specifier 'D<T, Ts>::' for friend class declaration is not supported; turning off access control for 'VS'}} | ||
| }; | ||
|
|
||
| namespace length_mismatch { | ||
| struct A { | ||
| template <typename...> | ||
| struct Nested { | ||
| struct Foo{}; | ||
| }; | ||
| }; | ||
| template <typename ...Ts> | ||
| struct S { | ||
| template <typename ...Us> | ||
| struct T { | ||
| // expected-error@+2 {{pack expansion contains parameter packs 'Ts' and 'Us' that have different lengths (1 vs. 2)}} | ||
| // expected-error@+1 {{pack expansion contains parameter packs 'Ts' and 'Us' that have different lengths (2 vs. 1)}} | ||
| friend class Ts::template Nested<Us>::Foo...; | ||
| }; | ||
| }; | ||
|
|
||
| void f() { | ||
| S<A>::T<int> s; | ||
| S<A, A>::T<int, long> s2; | ||
| S<A>::T<int, long> s3; // expected-note {{in instantiation of}} | ||
| S<A, A>::T<int> s4; // expected-note {{in instantiation of}} | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| // RUN: %clang_cc1 -fsyntax-only -verify -std=c++2c %s | ||
|
|
||
| struct A; | ||
| struct B; | ||
| struct C; | ||
|
|
||
| struct S {}; | ||
| template <typename> struct TS {}; | ||
|
|
||
| template <typename ...Pack> | ||
| class X { | ||
| friend Pack...; | ||
| static void f() { } // expected-note {{declared private here}} | ||
| }; | ||
|
|
||
| class Y { | ||
| friend A, B, C; | ||
| static void g() { } // expected-note {{declared private here}} | ||
| }; | ||
|
|
||
| struct A { | ||
| A() { | ||
| X<A>::f(); | ||
| Y::g(); | ||
| }; | ||
| }; | ||
|
|
||
| struct B { | ||
| B() { | ||
| X<B, C>::f(); | ||
| Y::g(); | ||
| }; | ||
| }; | ||
|
|
||
| struct C { | ||
| C() { | ||
| X<A, B, C>::f(); | ||
| Y::g(); | ||
| }; | ||
| }; | ||
|
|
||
| struct D { | ||
| D() { | ||
| X<A, B, C>::f(); // expected-error {{'f' is a private member of 'X<A, B, C>'}} | ||
| Y::g(); // expected-error {{'g' is a private member of 'Y'}} | ||
| }; | ||
| }; | ||
|
|
||
| void f1() { | ||
| A a; | ||
| B b; | ||
| C c; | ||
| D d; | ||
| } | ||
|
|
||
| template <typename ...Pack> | ||
| struct Z { | ||
| template <template <typename> class Template> | ||
| struct Inner { | ||
| friend Template<Pack>...; | ||
| }; | ||
| }; | ||
|
|
||
| void f2() { | ||
| Z<int, long, char> z; | ||
| Z<int, long, char>::Inner<TS> inner; | ||
| } | ||
|
|
||
| namespace p2893r3_examples { | ||
| template<class... Ts> | ||
| class Passkey { | ||
| friend Ts...; | ||
| Passkey() {} // expected-note {{declared private here}} | ||
| }; | ||
|
|
||
| class Foo; | ||
| class Bar; | ||
| class Baz; | ||
|
|
||
| class C { | ||
| public: | ||
| void f(Passkey<Foo, Bar, Baz>); | ||
| }; | ||
|
|
||
| class Foo { | ||
| Foo() { C c; c.f({}); } | ||
| }; | ||
|
|
||
| class Bar { | ||
| Bar() { C c; c.f({}); } | ||
| }; | ||
|
|
||
| class Baz { | ||
| Baz() { C c; c.f({}); } | ||
| }; | ||
|
|
||
| class Quux { | ||
| Quux() { C c; c.f({}); } // expected-error {{calling a private constructor of class 'p2893r3_examples::Passkey<p2893r3_examples::Foo, p2893r3_examples::Bar, p2893r3_examples::Baz>'}} | ||
| }; | ||
|
|
||
| template<class Derived, class MsgT> | ||
| struct Receiver { | ||
| void receive(MsgT) { | ||
| static_cast<Derived*>(this)->private_ += 1; | ||
| } | ||
| }; | ||
|
|
||
| template<class... MsgTs> | ||
| struct Dispatcher : Receiver<Dispatcher<MsgTs...>, MsgTs>... { | ||
| using Receiver<Dispatcher, MsgTs>::receive...; | ||
| friend Receiver<Dispatcher, MsgTs>...; | ||
|
|
||
| private: | ||
| int private_; | ||
| }; | ||
|
|
||
| void f() { | ||
| Dispatcher<int, float> d; | ||
| d.receive(0); | ||
| d.receive(0.0f); | ||
| } | ||
| } // namespace p2893r3_examples | ||
|
|
||
| namespace p2893r3_note { | ||
| template <class... Ts> class R { | ||
| friend Ts...; | ||
| }; | ||
|
|
||
| template <class... Ts, class... Us> | ||
| class R<R<Ts...>, R<Us...>> { | ||
| friend Ts::Nested..., Us...; | ||
| }; | ||
|
|
||
| struct E { struct Nested; }; | ||
| R<R<E>, R<C, int>> rr; | ||
| } // namespace p2893r3_note | ||
|
|
||
| namespace template_template { | ||
| template <typename U, template <typename> typename... Friend> | ||
| class S { | ||
| friend class Friend<U>...; | ||
| static constexpr int a = 42; | ||
| }; | ||
|
|
||
| template <typename U> | ||
| struct T { | ||
| static_assert(S<U, T>::a == 42); | ||
| static_assert(S<U, T>::a == 43); // expected-error {{static assertion failed due to requirement 'S<int, template_template::T>::a == 43'}} \ | ||
| // expected-note {{expression evaluates to '42 == 43'}} | ||
| }; | ||
|
|
||
| void f() { | ||
| T<int> t; // expected-note {{in instantiation of}} | ||
| } | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.4-library -finclude-default-header -verify -fnative-half-type %s | ||
| // RUN: %clang_cc1 -triple spirv-linux-vulkan-library -finclude-default-header -verify -fnative-half-type %s | ||
|
|
||
| // expected-no-diagnostics | ||
| #define SizeCheck(Ty, SizeInBits) \ | ||
| _Static_assert(sizeof(Ty) == SizeInBits / 8, #Ty " is " #SizeInBits "-bit"); \ | ||
| _Static_assert(sizeof(Ty##1) == (SizeInBits * 1) / 8, #Ty "1 is 1x" #SizeInBits "-bit"); \ | ||
| _Static_assert(__builtin_vectorelements(Ty##1) == 1, #Ty "1 is has 1 " #SizeInBits "-bit element"); \ | ||
| _Static_assert(sizeof(Ty##2) == (SizeInBits * 2) / 8, #Ty "2 is 2x" #SizeInBits "-bit"); \ | ||
| _Static_assert(__builtin_vectorelements(Ty##2) == 2, #Ty "2 is has 2 " #SizeInBits "-bit element"); \ | ||
| _Static_assert(__builtin_vectorelements(Ty##3) == 3, #Ty "3 is has 3 " #SizeInBits "-bit element"); \ | ||
| _Static_assert(sizeof(Ty##4) == (SizeInBits * 4) / 8, #Ty "4 is 4x" #SizeInBits "-bit"); \ | ||
| _Static_assert(__builtin_vectorelements(Ty##4) == 4, #Ty "4 is has 4 " #SizeInBits "-bit element"); | ||
|
|
||
| // FIXME: https://github.com/llvm/llvm-project/issues/104503 - 3 element vectors | ||
| // should be the size of 3 elements not padded to 4. | ||
| // _Static_assert(sizeof(Ty##3) == (SizeInBits * 3) / 8, #Ty "3 is 3x" #SizeInBits "-bit"); | ||
|
|
||
| SizeCheck(int16_t, 16); | ||
| SizeCheck(uint16_t, 16); | ||
| SizeCheck(half, 16); | ||
| SizeCheck(float16_t, 16); | ||
|
|
||
| SizeCheck(int, 32); | ||
| SizeCheck(uint, 32); | ||
| SizeCheck(int32_t, 32); | ||
| SizeCheck(uint32_t, 32); | ||
| SizeCheck(float, 32); | ||
| SizeCheck(float32_t, 32); | ||
|
|
||
| SizeCheck(int64_t, 64); | ||
| SizeCheck(uint64_t, 64); | ||
| SizeCheck(double, 64); | ||
| SizeCheck(float64_t, 64); |