| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,55 +1,55 @@ | ||
| // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -emit-llvm -disable-llvm-passes -o - -std=hlsl202x %s | FileCheck %s | ||
|
|
||
| struct Pair { | ||
| int First; | ||
| int Second; | ||
| int getFirst() { | ||
| Pair Another = {5, 10}; | ||
| this = Another; | ||
| return this.First; | ||
| } | ||
| int getSecond() { | ||
| this = Pair(); | ||
| return Second; | ||
| } | ||
| void operator=(Pair P) { | ||
| First = P.First; | ||
| Second = 2; | ||
| } | ||
| }; | ||
| [numthreads(1, 1, 1)] | ||
| void main() { | ||
| Pair Vals = {1, 2}; | ||
| Vals.First = Vals.getFirst(); | ||
| Vals.Second = Vals.getSecond(); | ||
| } | ||
|
|
||
| // This test makes a probably safe assumption that HLSL 202x includes operator overloading for assignment operators. | ||
| // CHECK: define linkonce_odr noundef i32 @"?getFirst@Pair@@QAAHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %this) #2 align 2 { | ||
| // CHECK-NEXT:entry: | ||
| // CHECK-NEXT:%this.addr = alloca ptr, align 4 | ||
| // CHECK-NEXT:%Another = alloca %struct.Pair, align 4 | ||
| // CHECK-NEXT:%agg.tmp = alloca %struct.Pair, align 4 | ||
| // CHECK-NEXT:store ptr %this, ptr %this.addr, align 4 | ||
| // CHECK-NEXT:%this1 = load ptr, ptr %this.addr, align 4 | ||
| // CHECK-NEXT:%First = getelementptr inbounds %struct.Pair, ptr %Another, i32 0, i32 0 | ||
| // CHECK-NEXT:store i32 5, ptr %First, align 4 | ||
| // CHECK-NEXT:%Second = getelementptr inbounds %struct.Pair, ptr %Another, i32 0, i32 1 | ||
| // CHECK-NEXT:store i32 10, ptr %Second, align 4 | ||
| // CHECK-NEXT:call void @llvm.memcpy.p0.p0.i32(ptr align 4 %agg.tmp, ptr align 4 %Another, i32 8, i1 false) | ||
| // CHECK-NEXT:call void @"??4Pair@@QAAXU0@@Z"(ptr noundef nonnull align 4 dereferenceable(8) %this1, ptr noundef byval(%struct.Pair) align 4 %agg.tmp) | ||
| // CHECK-NEXT:%First2 = getelementptr inbounds %struct.Pair, ptr %this1, i32 0, i32 0 | ||
| // CHECK-NEXT:%0 = load i32, ptr %First2, align 4 | ||
| // CHECK-NEXT:ret i32 %0 | ||
|
|
||
| // CHECK: define linkonce_odr noundef i32 @"?getSecond@Pair@@QAAHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %this) #2 align 2 { | ||
| // CHECK-NEXT:entry: | ||
| // CHECK-NEXT:%this.addr = alloca ptr, align 4 | ||
| // CHECK-NEXT:%agg.tmp = alloca %struct.Pair, align 4 | ||
| // CHECK-NEXT:store ptr %this, ptr %this.addr, align 4 | ||
| // CHECK-NEXT:%this1 = load ptr, ptr %this.addr, align 4 | ||
| // CHECK-NEXT:call void @llvm.memset.p0.i32(ptr align 4 %agg.tmp, i8 0, i32 8, i1 false) | ||
| // CHECK-NEXT:call void @"??4Pair@@QAAXU0@@Z"(ptr noundef nonnull align 4 dereferenceable(8) %this1, ptr noundef byval(%struct.Pair) align 4 %agg.tmp) | ||
| // CHECK-NEXT:%Second = getelementptr inbounds %struct.Pair, ptr %this1, i32 0, i32 1 | ||
| // CHECK-NEXT:%0 = load i32, ptr %Second, align 4 | ||
| // CHECK-NEXT:ret i32 %0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,45 @@ | ||
| // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -emit-llvm -disable-llvm-passes -o - -hlsl-entry main %s | FileCheck %s | ||
|
|
||
| struct Pair { | ||
| int First; | ||
| int Second; | ||
|
|
||
| int getFirst() { | ||
| Pair Another = {5, 10}; | ||
| this = Another; | ||
| return this.First; | ||
| } | ||
|
|
||
| int getSecond() { | ||
| this = Pair(); | ||
| return Second; | ||
| } | ||
| }; | ||
|
|
||
| [numthreads(1, 1, 1)] | ||
| void main() { | ||
| Pair Vals = {1, 2.0}; | ||
| Vals.First = Vals.getFirst(); | ||
| Vals.Second = Vals.getSecond(); | ||
| } | ||
|
|
||
| // This tests reference like implicit this in HLSL | ||
| // CHECK: define linkonce_odr noundef i32 @"?getFirst@Pair@@QAAHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %this) #3 align 2 { | ||
| // CHECK-NEXT:entry: | ||
| // CHECK-NEXT:%this.addr = alloca ptr, align 4 | ||
| // CHECK-NEXT:%Another = alloca %struct.Pair, align 4 | ||
| // CHECK-NEXT:store ptr %this, ptr %this.addr, align 4 | ||
| // CHECK-NEXT:%this1 = load ptr, ptr %this.addr, align 4 | ||
| // CHECK-NEXT:call void @llvm.memcpy.p0.p0.i32(ptr align 4 %Another, ptr align 4 @"__const.?getFirst@Pair@@QAAHXZ.Another", i32 8, i1 false) | ||
| // CHECK-NEXT:call void @llvm.memcpy.p0.p0.i32(ptr align 4 %this1, ptr align 4 %Another, i32 8, i1 false) | ||
| // CHECK-NEXT:%First = getelementptr inbounds %struct.Pair, ptr %this1, i32 0, i32 0 | ||
|
|
||
| // CHECK: define linkonce_odr noundef i32 @"?getSecond@Pair@@QAAHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %this) #3 align 2 { | ||
| // CHECK-NEXT:entry: | ||
| // CHECK-NEXT:%this.addr = alloca ptr, align 4 | ||
| // CHECK-NEXT:%ref.tmp = alloca %struct.Pair, align 4 | ||
| // CHECK-NEXT:store ptr %this, ptr %this.addr, align 4 | ||
| // CHECK-NEXT:%this1 = load ptr, ptr %this.addr, align 4 | ||
| // CHECK-NEXT:call void @llvm.memset.p0.i32(ptr align 4 %ref.tmp, i8 0, i32 8, i1 false) | ||
| // CHECK-NEXT:call void @llvm.memcpy.p0.p0.i32(ptr align 4 %this1, ptr align 4 %ref.tmp, i32 8, i1 false) | ||
| // CHECK-NEXT:%Second = getelementptr inbounds %struct.Pair, ptr %this1, i32 0, i32 1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,34 @@ | ||
| // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -emit-llvm -disable-llvm-passes -o - -hlsl-entry main %s -debug-info-kind=standalone -dwarf-version=4 | FileCheck %s | ||
|
|
||
| struct Pair { | ||
| int First; | ||
| float Second; | ||
|
|
||
| int getFirst() { | ||
| return this.First; | ||
| } | ||
|
|
||
| float getSecond() { | ||
| return Second; | ||
| } | ||
| }; | ||
|
|
||
| [numthreads(1, 1, 1)] | ||
| void main() { | ||
| Pair Vals = {1, 2.0}; | ||
| Vals.First = Vals.getFirst(); | ||
| Vals.Second = Vals.getSecond(); | ||
| } | ||
|
|
||
| // This tests reference like `this` in HLSL | ||
| // CHECK: %call = call noundef i32 @"?getFirst@Pair@@QAAHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %Vals) | ||
| // CHECK-NEXT: %First = getelementptr inbounds %struct.Pair, ptr %Vals, i32 0, i32 0 | ||
| // CHECK-NEXT: store i32 %call, ptr %First, align 4 | ||
| // CHECK-NEXT: %call1 = call noundef float @"?getSecond@Pair@@QAAMXZ"(ptr noundef nonnull align 4 dereferenceable(8) %Vals) | ||
| // CHECK-NEXT: %Second = getelementptr inbounds %struct.Pair, ptr %Vals, i32 0, i32 1 | ||
|
|
||
| // CHECK: [[Pair:![0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Pair" | ||
| // CHECK: [[getFirst:![0-9]+]] = distinct !DISubprogram(name: "getFirst" | ||
| // CHECK-SAME: scope: [[Pair]] | ||
| // CHECK: [[FirstThis:![0-9]+]] = !DILocalVariable(name: "this", arg: 1, scope: [[getFirst]], type: [[thisType:![0-9]+]] | ||
| // CHECK: [[thisType]] = !DIDerivedType(tag: DW_TAG_reference_type, baseType: [[Pair]], size: 32) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,53 +1,53 @@ | ||
| // RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -emit-llvm -fobjc-runtime=gnustep-2.0 -fexceptions -fobjc-exceptions -o %t %s | ||
| // RUN: FileCheck --check-prefixes=CHECK-MINGW-OBJC2 < %t %s | ||
|
|
||
| // RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -emit-llvm -fobjc-runtime=gcc -fexceptions -fobjc-exceptions -o %t %s | ||
| // RUN: FileCheck --check-prefixes=CHECK-MINGW-GCC < %t %s | ||
|
|
||
| // RUN: %clang_cc1 -triple x86_64-w64-windows-msvc -emit-llvm -fobjc-runtime=gnustep-2.0 -fexceptions -fobjc-exceptions -o %t %s | ||
| // RUN: FileCheck --check-prefixes=CHECK-MSVC-OBJC2 < %t %s | ||
|
|
||
| // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -fobjc-runtime=gnustep-2.0 -fexceptions -fobjc-exceptions -o %t %s | ||
| // RUN: FileCheck --check-prefixes=CHECK-LINUX-OBJC2 < %t %s | ||
|
|
||
| // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -fobjc-runtime=gcc -fexceptions -fobjc-exceptions -o %t %s | ||
| // RUN: FileCheck --check-prefixes=CHECK-LINUX-GCC < %t %s | ||
| @interface Foo @end | ||
|
|
||
| void throwing(void) { | ||
| @try | ||
| { | ||
| // CHECK-MINGW-OBJC2: personality ptr @__gxx_personality_seh0 | ||
| // CHECK-MINGW-OBJC2: invoke void @objc_exception_throw | ||
|
|
||
| // CHECK-MINGW-GCC: personality ptr @__gnu_objc_personality_v0 | ||
| // CHECK-MINGW-GCC: invoke void @objc_exception_throw | ||
|
|
||
| // CHECK-MSVC-OBJC2: personality ptr @__CxxFrameHandler3 | ||
| // CHECK-MSVC-OBJC2: invoke void @objc_exception_throw | ||
|
|
||
| // CHECK-LINUX-OBJC2: personality ptr @__gnustep_objc_personality_v0 | ||
| // CHECK-LINUX-OBJC2: invoke void @objc_exception_throw | ||
|
|
||
| // CHECK-LINUX-GCC: personality ptr @__gnu_objc_personality_v0 | ||
| @throw(@"error!"); | ||
| } | ||
| @catch(...) | ||
| { | ||
| // CHECK-MINGW-OBJC2: call ptr @__cxa_begin_catch | ||
| // CHECK-MINGW-OBJC2: invoke ptr @__cxa_rethrow | ||
| // CHECK-MINGW-OBJC2: invoke void @__cxa_end_catch | ||
|
|
||
| // CHECK-MINGW-GCC: call void @objc_exception_throw | ||
|
|
||
| // CHECK-MSVC-OBJC2: call void @objc_exception_rethrow | ||
|
|
||
| // CHECK-LINUX-OBJC2: call ptr @objc_begin_catch | ||
| // CHECK-LINUX-OBJC2: invoke void @objc_exception_throw | ||
| // CHECK-LINUX-OBJC2: invoke void @objc_end_catch() | ||
|
|
||
| // CHECK-LINUX-GCC: invoke void @objc_exception_throw | ||
|
|
||
| @throw; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,29 @@ | ||
| // RUN: %clang -### -target x86_64-scei-ps4 %s -o - 2>&1 | \ | ||
| // RUN: FileCheck %s | ||
| // RUN: %clang -### -target x86_64-scei-ps4 -Wa,-mrelax-relocations=yes %s -o - 2>&1 | \ | ||
| // RUN: FileCheck %s | ||
| // RUN: %clang -### -target x86_64-scei-ps4 -Wa,-mrelax-relocations=no %s -o - 2>&1 | \ | ||
| // RUN: FileCheck -check-prefix=UNSET %s | ||
| // RUN: %clang -### -x assembler -target x86_64-scei-ps4 %s -o - 2>&1 | \ | ||
| // RUN: FileCheck %s | ||
| // RUN: %clang -### -x assembler -target x86_64-scei-ps4 -Wa,-mrelax-relocations=yes %s -o - 2>&1 | \ | ||
| // RUN: FileCheck %s | ||
| // RUN: %clang -### -x assembler -target x86_64-scei-ps4 -Wa,-mrelax-relocations=no %s -o - 2>&1 | \ | ||
| // RUN: FileCheck -check-prefix=UNSET %s | ||
|
|
||
| // RUN: %clang -### -target x86_64-sie-ps5 %s -o - 2>&1 | \ | ||
| // RUN: FileCheck %s | ||
| // RUN: %clang -### -target x86_64-sie-ps5 -Wa,-mrelax-relocations=yes %s -o - 2>&1 | \ | ||
| // RUN: FileCheck %s | ||
| // RUN: %clang -### -target x86_64-sie-ps5 -Wa,-mrelax-relocations=no %s -o - 2>&1 | \ | ||
| // RUN: FileCheck -check-prefix=UNSET %s | ||
| // RUN: %clang -### -x assembler -target x86_64-sie-ps5 %s -o - 2>&1 | \ | ||
| // RUN: FileCheck %s | ||
| // RUN: %clang -### -x assembler -target x86_64-sie-ps5 -Wa,-mrelax-relocations=yes %s -o - 2>&1 | \ | ||
| // RUN: FileCheck %s | ||
| // RUN: %clang -### -x assembler -target x86_64-sie-ps5 -Wa,-mrelax-relocations=no %s -o - 2>&1 | \ | ||
| // RUN: FileCheck -check-prefix=UNSET %s | ||
|
|
||
| // CHECK-NOT: "-mrelax-relocations | ||
|
|
||
| // UNSET: "-mrelax-relocations=no" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,15 @@ | ||
| // RUN: %clang_cl /E -Xclang -frewrite-includes -- %s | %clang_cl /c -Xclang -verify /Tp - | ||
| // expected-no-diagnostics | ||
|
|
||
| // This test uses dos-style \r\n line endings. | ||
| // Make sure your editor doesn't rewrite them to unix-style \n line endings. | ||
| int foo(); | ||
| int bar(); | ||
| #define HELLO \ | ||
| foo(); \ | ||
| bar(); | ||
|
|
||
| int main() { | ||
| HELLO | ||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| // Test double slashes in #include directive along with angle brackets. Previously, this was interpreted as comments. | ||
| // RUN: %clang_cc1 -DTEST -print-dependency-directives-minimized-source %s 2>&1 | FileCheck %s | ||
|
|
||
| #include "a//b.h" | ||
| #include <a//b.h> | ||
|
|
||
| // CHECK: #include "a//b.h" | ||
| // CHECK: #include <a//b.h> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| // Test UTF8 BOM at start of file | ||
| // RUN: printf '\xef\xbb\xbf' > %t.c | ||
| // RUN: echo '#ifdef TEST\n' >> %t.c | ||
| // RUN: echo '#include <string>' >> %t.c | ||
| // RUN: echo '#endif' >> %t.c | ||
| // RUN: %clang_cc1 -DTEST -print-dependency-directives-minimized-source %t.c 2>&1 | FileCheck %s | ||
|
|
||
| // CHECK: #ifdef TEST | ||
| // CHECK-NEXT: #include <string> | ||
| // CHECK-NEXT: #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,20 @@ | ||
| // RUN: %clang_dxc -T lib_6_4 -HV 2016 %s 2>&1 -### | FileCheck -check-prefix=2016 %s | ||
| // RUN: %clang_dxc -T lib_6_4 -HV 2017 %s 2>&1 -### | FileCheck -check-prefix=2017 %s | ||
| // RUN: %clang_dxc -T lib_6_4 /HV 2018 %s 2>&1 -### | FileCheck -check-prefix=2018 %s | ||
| // RUN: %clang_dxc -T lib_6_4 /HV 2021 %s 2>&1 -### | FileCheck -check-prefix=2021 %s | ||
| // RUN: %clang_dxc -T lib_6_4 /HV 202x %s 2>&1 -### | FileCheck -check-prefix=202x %s | ||
| // RUN: %clang_dxc -T lib_6_4 %s 2>&1 -### | FileCheck -check-prefix=NO_HV %s | ||
| // RUN: not %clang_dxc -T lib_6_4 /HV gibberish -### %s 2>&1 | FileCheck -check-prefix=CHECK-ERR %s | ||
|
|
||
| // 2016: "-std=hlsl2016" | ||
| // 2017: "-std=hlsl2017" | ||
| // 2018: "-std=hlsl2018" | ||
| // 2021: "-std=hlsl2021" | ||
| // 202x: "-std=hlsl202x" | ||
| // NO_HV-NOT: "-std=" | ||
| // CHECK-ERR: error: invalid value 'gibberish' in 'HV' | ||
| float4 main(float4 a : A) : SV_TARGET | ||
| { | ||
| return -a.yxxx; | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,25 @@ | ||
| // RUN: not %clang_dxc -enable-16bit-types -T cs_6_0 -HV 2016 %s 2>&1 | FileCheck -check-prefix=both_invalid %s | ||
| // RUN: not %clang_dxc -enable-16bit-types -T lib_6_4 -HV 2017 %s 2>&1 | FileCheck -check-prefix=HV_invalid_2017 %s | ||
| // RUN: not %clang_dxc -enable-16bit-types -T cs_6_0 /HV 2021 %s 2>&1 | FileCheck -check-prefix=TP_invalid %s | ||
| // RUN: %clang_dxc -enable-16bit-types -T lib_6_4 /HV 2018 %s 2>&1 -### | FileCheck -check-prefix=valid_2018 %s | ||
| // RUN: %clang_dxc -enable-16bit-types -T lib_6_4 /HV 2021 %s 2>&1 -### | FileCheck -check-prefix=valid_2021 %s | ||
|
|
||
|
|
||
| // both_invalid: error: '-enable-16bit-types' option requires target HLSL Version >= 2018 and shader model >= 6.2, but HLSL Version is 'hlsl2016' and shader model is '6.0' | ||
| // HV_invalid_2017: error: '-enable-16bit-types' option requires target HLSL Version >= 2018 and shader model >= 6.2, but HLSL Version is 'hlsl2017' and shader model is '6.4' | ||
| // TP_invalid: error: '-enable-16bit-types' option requires target HLSL Version >= 2018 and shader model >= 6.2, but HLSL Version is 'hlsl2021' and shader model is '6.0' | ||
|
|
||
| // valid_2021: "dxil-unknown-shadermodel6.4-library" | ||
| // valid_2021-SAME: "-std=hlsl2021" | ||
| // valid_2021-SAME: "-fnative-half-type" | ||
|
|
||
| // valid_2018: "dxil-unknown-shadermodel6.4-library" | ||
| // valid_2018-SAME: "-std=hlsl2018" | ||
| // valid_2018-SAME: "-fnative-half-type" | ||
|
|
||
| [numthreads(1,1,1)] | ||
| void main() | ||
| { | ||
| return; | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,14 @@ | ||
| // RUN: not %clang_cc1 -internal-isystem D:\llvm-project\build\x64-Release\lib\clang\19\include -nostdsysteminc -triple spirv-vulkan-library -x hlsl -std=hlsl2016 -fnative-half-type -emit-llvm -disable-llvm-passes -o - %s 2>&1 | FileCheck %s --check-prefix=SPIRV | ||
| // RUN: %clang_cc1 -internal-isystem D:\llvm-project\build\x64-Release\lib\clang\19\include -nostdsysteminc -triple spirv-vulkan-library -x hlsl -std=hlsl2021 -fnative-half-type -emit-llvm -disable-llvm-passes -o - %s 2>&1 | FileCheck %s --check-prefix=valid | ||
|
|
||
| // SPIRV: error: '-fnative-half-type' option requires target HLSL Version >= 2018, but HLSL Version is 'hlsl2016' | ||
|
|
||
| // valid: "spirv-unknown-vulkan-library" | ||
| // valid: define spir_func void @main() #0 { | ||
|
|
||
| [numthreads(1,1,1)] | ||
| void main() | ||
| { | ||
| return; | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,28 @@ | ||
| // RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.10.0 -verify %s | ||
| // expected-no-diagnostics | ||
|
|
||
| @interface NSObject | ||
| @end | ||
|
|
||
| [[clang::objc_exception]] | ||
| @interface Foo { | ||
| [[clang::iboutlet]] NSObject *h; | ||
| } | ||
| @property (readonly) [[clang::objc_returns_inner_pointer]] void *i, *j; | ||
| @property (readonly) [[clang::iboutlet]] NSObject *k; | ||
| @end | ||
|
|
||
| [[clang::objc_runtime_name("name")]] @protocol Bar; | ||
|
|
||
| [[clang::objc_protocol_requires_explicit_implementation]] | ||
| @protocol Baz | ||
| @end | ||
|
|
||
| @interface Quux | ||
| -(void)g1 [[clang::ns_consumes_self]]; | ||
| -(void)g2 __attribute__((ns_consumes_self)); | ||
| -(void)h1: (int)x [[clang::ns_consumes_self]]; | ||
| -(void)h2: (int)x __attribute__((ns_consumes_self)); | ||
| -(void) [[clang::ns_consumes_self]] i1; | ||
| -(void) __attribute__((ns_consumes_self)) i2; | ||
| @end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,76 +1,76 @@ | ||
| // RUN: %clang_cc1 %s -Eonly -verify -Wno-all -Wno-c++23-extensions -pedantic -std=c++20 | ||
| // RUN: %clang_cc1 %s -Eonly -verify -Wno-all -Wno-c++23-extensions -pedantic -std=c++11 | ||
| // RUN: %clang_cc1 -x c %s -Eonly -verify -Wno-all -Wno-c2x-extensions -pedantic -std=c99 | ||
|
|
||
| //expected-error@+1{{missing '('}} | ||
| #define V1(...) __VA_OPT__ | ||
| #undef V1 | ||
| // OK | ||
| #define V1(...) __VA_OPT__ () | ||
| #undef V1 | ||
|
|
||
| //expected-warning@+1{{can only appear in the expansion of a variadic macro}} | ||
| #define V2() __VA_OPT__(x) | ||
| #undef V2 | ||
|
|
||
| //expected-error@+2{{missing ')' after}} | ||
| //expected-note@+1{{to match this '('}} | ||
| #define V3(...) __VA_OPT__( | ||
| #undef V3 | ||
|
|
||
| #define V4(...) __VA_OPT__(__VA_ARGS__) | ||
| #undef V4 | ||
|
|
||
| //expected-error@+1{{nested}} | ||
| #define V5(...) __VA_OPT__(__VA_OPT__()) | ||
| #undef V5 | ||
|
|
||
| //expected-error@+1{{not followed by}} | ||
| #define V1(...) __VA_OPT__ (#) | ||
| #undef V1 | ||
|
|
||
| //expected-error@+1{{cannot appear at start}} | ||
| #define V1(...) __VA_OPT__ (##) | ||
| #undef V1 | ||
|
|
||
| //expected-error@+1{{cannot appear at start}} | ||
| #define V1(...) __VA_OPT__ (## X) x | ||
| #undef V1 | ||
|
|
||
| //expected-error@+1{{cannot appear at end}} | ||
| #define V1(...) y __VA_OPT__ (X ##) | ||
| #undef V1 | ||
|
|
||
|
|
||
| #define FOO(x,...) # __VA_OPT__(x) #x #__VA_OPT__(__VA_ARGS__) //OK | ||
|
|
||
| //expected-error@+1{{not followed by a macro parameter}} | ||
| #define V1(...) __VA_OPT__(#) | ||
| #undef V1 | ||
|
|
||
| //expected-error@+1{{cannot appear at start}} | ||
| #define V1(...) a __VA_OPT__(##) b | ||
| #undef V1 | ||
|
|
||
| //expected-error@+1{{cannot appear at start}} | ||
| #define V1(...) a __VA_OPT__(a ## b) b __VA_OPT__(##) | ||
| #undef V1 | ||
|
|
||
| #define V1(x,...) # __VA_OPT__(b x) // OK | ||
| #undef V1 | ||
|
|
||
| //expected-error@+2{{missing ')' after}} | ||
| //expected-note@+1{{to match this '('}} | ||
| #define V1(...) __VA_OPT__ ((()) | ||
| #undef V1 | ||
|
|
||
| // __VA_OPT__ can't appear anywhere else. | ||
| #if __VA_OPT__ // expected-warning {{__VA_OPT__ can only appear in the expansion of a variadic macro}} | ||
| #endif | ||
|
|
||
| // expected-warning@+2 {{__VA_OPT__ can only appear in the expansion of a variadic macro}} | ||
| #ifdef __VA_OPT__ // expected-warning {{__VA_OPT__ can only appear in the expansion of a variadic macro}} | ||
| #elifdef __VA_OPT__ | ||
| #endif | ||
|
|
||
| #define BAD __VA_OPT__ // expected-warning {{__VA_OPT__ can only appear in the expansion of a variadic macro}} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,150 +1,150 @@ | ||
| // RUN: %clang_cc1 -E %s -pedantic -std=c++20 | FileCheck -strict-whitespace %s | ||
| // RUN: %clang_cc1 -E %s -pedantic -std=c++11 | FileCheck -strict-whitespace %s | ||
| // RUN: %clang_cc1 -E -x c %s -pedantic -std=c99 | FileCheck -strict-whitespace %s | ||
|
|
||
| #define LPAREN ( | ||
| #define RPAREN ) | ||
|
|
||
| #define A0 expandedA0 | ||
| #define A1 expandedA1 A0 | ||
| #define A2 expandedA2 A1 | ||
| #define A3 expandedA3 A2 | ||
|
|
||
| #define A() B LPAREN ) | ||
| #define B() C LPAREN ) | ||
| #define C() D LPAREN ) | ||
|
|
||
|
|
||
| #define F(x, y) x + y | ||
| #define ELLIP_FUNC(...) __VA_OPT__(__VA_ARGS__) | ||
|
|
||
| 1: ELLIP_FUNC(F, LPAREN, 'a', 'b', RPAREN); | ||
| 2: ELLIP_FUNC(F LPAREN 'a', 'b' RPAREN); | ||
| #undef F | ||
| #undef ELLIP_FUNC | ||
|
|
||
| // CHECK: 1: F, (, 'a', 'b', ); | ||
| // CHECK: 2: 'a' + 'b'; | ||
|
|
||
| #define F(...) f(0 __VA_OPT__(,) __VA_ARGS__) | ||
| 3: F(a, b, c) // replaced by f(0, a, b, c) | ||
| 4: F() // replaced by f(0) | ||
|
|
||
| // CHECK: 3: f(0 , a, b, c) | ||
| // CHECK: 4: f(0 ) | ||
| #undef F | ||
|
|
||
| #define G(X, ...) f(0, X __VA_OPT__(,) __VA_ARGS__) | ||
|
|
||
| 5: G(a, b, c) // replaced by f(0, a , b, c) | ||
| 6: G(a) // replaced by f(0, a) | ||
| 7: G(a,) // replaced by f(0, a) | ||
| 7.1: G(a,,) | ||
|
|
||
|
|
||
| // CHECK: 5: f(0, a , b, c) | ||
| // CHECK: 6: f(0, a ) | ||
| // CHECK: 7: f(0, a ) | ||
| // CHECK: 7.1: f(0, a , ,) | ||
| #undef G | ||
|
|
||
| #define HT_B() TONG | ||
|
|
||
| #define F(x, ...) HT_ ## __VA_OPT__(x x A() #x) | ||
|
|
||
| 8: F(1) | ||
| 9: F(A(),1) | ||
|
|
||
| // CHECK: 8: HT_ | ||
| // CHECK: 9: TONG C ( ) B ( ) "A()" | ||
| #undef HT_B | ||
| #undef F | ||
|
|
||
| #define F(a,...) #__VA_OPT__(A1 a) | ||
|
|
||
| 10: F(A()) | ||
| 11: F(A1 A(), 1) | ||
| // CHECK: 10: "" | ||
| // CHECK: 11: "A1 expandedA1 expandedA0 B ( )" | ||
| #undef F | ||
|
|
||
|
|
||
| #define F(a,...) a ## __VA_OPT__(A1 a) ## __VA_ARGS__ ## a | ||
| 12.0: F() | ||
| 12: F(,) | ||
| 13: F(B,) | ||
| // CHECK: 12.0: | ||
| // CHECK: 12: | ||
| // CHECK: 13: BB | ||
| #undef F | ||
|
|
||
| #define F(...) #__VA_OPT__() X ## __VA_OPT__() #__VA_OPT__( ) | ||
|
|
||
| 14: F() | ||
| 15: F(1) | ||
|
|
||
| // CHECK: 14: "" X "" | ||
| // CHECK: 15: "" X "" | ||
|
|
||
| #undef F | ||
|
|
||
| #define SDEF(sname, ...) S sname __VA_OPT__(= { __VA_ARGS__ }) | ||
|
|
||
| 16: SDEF(foo); // replaced by S foo; | ||
| 17: SDEF(bar, 1, 2); // replaced by S bar = { 1, 2 }; | ||
|
|
||
| // CHECK: 16: S foo ; | ||
| // CHECK: 17: S bar = { 1, 2 }; | ||
| #undef SDEF | ||
|
|
||
| #define F(a,...) A() #__VA_OPT__(A3 __VA_ARGS__ a ## __VA_ARGS__ ## a ## C A3) A() | ||
|
|
||
| 18: F() | ||
| 19: F(,) | ||
| 20: F(,A3) | ||
| 21: F(A3, A(),A0) | ||
|
|
||
|
|
||
| // CHECK: 18: B ( ) "" B ( ) | ||
| // CHECK: 19: B ( ) "" B ( ) | ||
| // CHECK: 20: B ( ) "A3 expandedA3 expandedA2 expandedA1 expandedA0 A3C A3" B ( ) | ||
| // CHECK: 21: B ( ) "A3 B ( ),expandedA0 A3A(),A0A3C A3" B ( ) | ||
|
|
||
| #undef F | ||
|
|
||
| #define F(a,...) A() #__VA_OPT__(A3 __VA_ARGS__ a ## __VA_ARGS__ ## a ## C A3) a __VA_OPT__(A0 __VA_ARGS__ a ## __VA_ARGS__ ## a ## C A0) A() | ||
|
|
||
| 22: F() | ||
| 23: F(,) | ||
| 24: F(,A0) | ||
| 25: F(A0, A(),A0) | ||
|
|
||
|
|
||
| // CHECK: 22: B ( ) "" B ( ) | ||
| // CHECK: 23: B ( ) "" B ( ) | ||
| // CHECK: 24: B ( ) "A3 expandedA0 A0C A3" expandedA0 expandedA0 A0C expandedA0 B ( ) | ||
| // CHECK: 25: B ( ) "A3 B ( ),expandedA0 A0A(),A0A0C A3" expandedA0 expandedA0 C ( ),expandedA0 A0A(),A0A0C expandedA0 B ( ) | ||
|
|
||
| #undef F | ||
|
|
||
| #define F(a,...) __VA_OPT__(B a ## a) ## 1 | ||
| #define G(a,...) __VA_OPT__(B a) ## 1 | ||
| 26: F(,1) | ||
| 26_1: G(,1) | ||
| // CHECK: 26: B 1 | ||
| // CHECK: 26_1: B 1 | ||
| #undef F | ||
| #undef G | ||
|
|
||
| #define F(a,...) B ## __VA_OPT__(a 1) ## 1 | ||
| #define G(a,...) B ## __VA_OPT__(a ## a 1) ## 1 | ||
|
|
||
| 27: F(,1) | ||
| 27_1: F(A0,1) | ||
| 28: G(,1) | ||
| // CHECK: 27: B 11 | ||
| // CHECK: 27_1: BexpandedA0 11 | ||
| // CHECK: 28: B 11 | ||
|
|
||
| #undef F | ||
| #undef G |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,23 @@ | ||
| // RUN: %clang_cc1 -triple aarch64 -target-feature +sve \ | ||
| // RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify | ||
| // REQUIRES: aarch64-registered-target | ||
|
|
||
| #include <arm_sve.h> | ||
|
|
||
| svfloat32_t test_log_vv_i8mf8(svfloat32_t v) { | ||
|
|
||
| return __builtin_elementwise_log(v); | ||
| // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} | ||
| } | ||
|
|
||
| svfloat32_t test_log10_vv_i8mf8(svfloat32_t v) { | ||
|
|
||
| return __builtin_elementwise_log10(v); | ||
| // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} | ||
| } | ||
|
|
||
| svfloat32_t test_log2_vv_i8mf8(svfloat32_t v) { | ||
|
|
||
| return __builtin_elementwise_log2(v); | ||
| // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,18 @@ | ||
| // RUN: %clang_cc1 -triple aarch64 -target-feature +sve \ | ||
| // RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify | ||
| // REQUIRES: aarch64-registered-target | ||
|
|
||
| #include <arm_sve.h> | ||
|
|
||
|
|
||
| svfloat32_t test_sin_vv_i8mf8(svfloat32_t v) { | ||
|
|
||
| return __builtin_elementwise_sin(v); | ||
| // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} | ||
| } | ||
|
|
||
| svfloat32_t test_cos_vv_i8mf8(svfloat32_t v) { | ||
|
|
||
| return __builtin_elementwise_cos(v); | ||
| // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,14 @@ | ||
| // RUN: %clang_cc1 -fsyntax-only -verify %s | ||
|
|
||
| [[gnu::pure]] void foo(); // expected-warning{{'pure' attribute on function returning 'void'; attribute ignored}} | ||
|
|
||
| [[gnu::const]] void bar(); // expected-warning{{'const' attribute on function returning 'void'; attribute ignored}} | ||
|
|
||
| struct A { | ||
| [[gnu::pure]] A(); // expected-warning{{'pure' attribute on function returning 'void'; attribute ignored}} | ||
|
|
||
| [[gnu::const]] A(int); // expected-warning{{'const' attribute on function returning 'void'; attribute ignored}} | ||
| [[gnu::pure]] ~A(); // expected-warning{{'pure' attribute on function returning 'void'; attribute ignored}} | ||
|
|
||
| [[gnu::const]] [[gnu::pure]] int m(); // expected-warning{{'const' attribute imposes more restrictions; 'pure' attribute ignored}} | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,25 @@ | ||
| // RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ | ||
| // RUN: -target-feature +v -target-feature +zfh -target-feature +zvfh \ | ||
| // RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify | ||
| // REQUIRES: riscv-registered-target | ||
|
|
||
| #include <riscv_vector.h> | ||
|
|
||
|
|
||
| vfloat32mf2_t test_log_vv_i8mf8(vfloat32mf2_t v) { | ||
|
|
||
| return __builtin_elementwise_log(v); | ||
| // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} | ||
| } | ||
|
|
||
| vfloat32mf2_t test_log10_vv_i8mf8(vfloat32mf2_t v) { | ||
|
|
||
| return __builtin_elementwise_log10(v); | ||
| // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} | ||
| } | ||
|
|
||
| vfloat32mf2_t test_log2_vv_i8mf8(vfloat32mf2_t v) { | ||
|
|
||
| return __builtin_elementwise_log2(v); | ||
| // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,19 @@ | ||
| // RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ | ||
| // RUN: -target-feature +v -target-feature +zfh -target-feature +zvfh \ | ||
| // RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify | ||
| // REQUIRES: riscv-registered-target | ||
|
|
||
| #include <riscv_vector.h> | ||
|
|
||
|
|
||
| vfloat32mf2_t test_sin_vv_i8mf8(vfloat32mf2_t v) { | ||
|
|
||
| return __builtin_elementwise_sin(v); | ||
| // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} | ||
| } | ||
|
|
||
| vfloat32mf2_t test_cos_vv_i8mf8(vfloat32mf2_t v) { | ||
|
|
||
| return __builtin_elementwise_cos(v); | ||
| // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,29 @@ | ||
| // RUN: %clang_cc1 -std=c++11 -triple armv7-unknown-linux-gnueabi -fsyntax-only -verify %s | ||
|
|
||
| struct a { | ||
| int __attribute__((no_caller_saved_registers)) b; // expected-warning {{unknown attribute 'no_caller_saved_registers' ignored}} | ||
| static void foo(int *a) __attribute__((no_caller_saved_registers)) {} // expected-warning {{unknown attribute 'no_caller_saved_registers' ignored}} | ||
| }; | ||
|
|
||
| struct a test __attribute__((no_caller_saved_registers)); // expected-warning {{unknown attribute 'no_caller_saved_registers' ignored}} | ||
|
|
||
| __attribute__((no_caller_saved_registers(999))) void bar(int *) {} // expected-warning {{unknown attribute 'no_caller_saved_registers' ignored}} | ||
|
|
||
| __attribute__((no_caller_saved_registers)) void foo(int *){} // expected-warning {{unknown attribute 'no_caller_saved_registers' ignored}} | ||
|
|
||
| [[gnu::no_caller_saved_registers]] void foo2(int *) {} // expected-warning {{unknown attribute 'no_caller_saved_registers' ignored}} | ||
|
|
||
| typedef __attribute__((no_caller_saved_registers)) void (*foo3)(int *); // expected-warning {{unknown attribute 'no_caller_saved_registers' ignored}} | ||
|
|
||
| typedef void (*foo5)(int *); | ||
|
|
||
| int (*foo4)(double a, __attribute__((no_caller_saved_registers)) float b); // expected-warning {{unknown attribute 'no_caller_saved_registers' ignored}} | ||
|
|
||
| int main(int argc, char **argv) { | ||
| void (*fp)(int *) = foo; | ||
| a::foo(&argc); | ||
| foo3 func = foo2; | ||
| func(&argc); | ||
| foo5 __attribute__((no_caller_saved_registers)) func2 = foo2; // expected-warning {{unknown attribute 'no_caller_saved_registers' ignored}} | ||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +1,33 @@ | ||
| // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s | ||
|
|
||
| struct a { | ||
| int b __attribute__((no_caller_saved_registers)); // expected-warning {{'no_caller_saved_registers' only applies to function types; type here is 'int'}} | ||
| static void foo(int *a) __attribute__((no_caller_saved_registers)) {} | ||
| }; | ||
|
|
||
| struct a test __attribute__((no_caller_saved_registers)); // expected-warning {{'no_caller_saved_registers' only applies to function types; type here is 'struct a'}} | ||
|
|
||
| __attribute__((no_caller_saved_registers(999))) void bar(int *) {} // expected-error {{'no_caller_saved_registers' attribute takes no arguments}} | ||
|
|
||
| void __attribute__((no_caller_saved_registers)) foo(int *){} | ||
|
|
||
| [[gnu::no_caller_saved_registers]] void foo2(int *) {} | ||
|
|
||
| typedef __attribute__((no_caller_saved_registers)) void (*foo3)(int *); | ||
|
|
||
| int (*foo4)(double a, __attribute__((no_caller_saved_registers)) float b); // expected-warning {{'no_caller_saved_registers' only applies to function types; type here is 'float'}} | ||
|
|
||
| typedef void (*foo5)(int *); | ||
|
|
||
| void foo6(){} // expected-note {{previous declaration is here}} | ||
|
|
||
| void __attribute__((no_caller_saved_registers)) foo6(); // expected-error {{function declared with 'no_caller_saved_registers' attribute was previously declared without the 'no_caller_saved_registers' attribute}} | ||
|
|
||
| int main(int argc, char **argv) { | ||
| void (*fp)(int *) = foo; // expected-error {{cannot initialize a variable of type 'void (*)(int *)' with an lvalue of type 'void (int *) __attribute__((no_caller_saved_registers))'}} | ||
| a::foo(&argc); | ||
| foo3 func = foo2; | ||
| func(&argc); | ||
| foo5 __attribute__((no_caller_saved_registers)) func2 = foo2; | ||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,131 +1,131 @@ | ||
| // RUN: %clang_cc1 -fsyntax-only -std=c++03 -verify -ast-dump %s > %t-03 | ||
| // RUN: FileCheck --input-file=%t-03 %s | ||
| // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify -ast-dump %s > %t-11 | ||
| // RUN: FileCheck --input-file=%t-11 %s | ||
| // RUN: FileCheck --input-file=%t-11 %s --check-prefix=CHECK-CXX11 | ||
| // RUN: %clang_cc1 -verify -std=c++17 %s | ||
|
|
||
| // http://llvm.org/PR7905 | ||
| namespace PR7905 { | ||
| struct S; // expected-note {{forward declaration}} | ||
| void foo1() { | ||
| (void)(S[]) {{3}}; // expected-error {{array has incomplete element type}} | ||
| } | ||
|
|
||
| template <typename T> struct M { T m; }; | ||
| void foo2() { | ||
| (void)(M<short> []) {{3}}; | ||
| } | ||
| } | ||
|
|
||
| // Check compound literals mixed with C++11 list-initialization. | ||
| namespace brace_initializers { | ||
| struct POD { | ||
| int x, y; | ||
| }; | ||
| struct HasCtor { | ||
| HasCtor(int x, int y); | ||
| }; | ||
| struct HasDtor { | ||
| int x, y; | ||
| ~HasDtor(); | ||
| }; | ||
| struct HasCtorDtor { | ||
| HasCtorDtor(int x, int y); | ||
| ~HasCtorDtor(); | ||
| }; | ||
|
|
||
| POD p = (POD){1, 2}; | ||
| // CHECK-NOT: CXXBindTemporaryExpr {{.*}} 'brace_initializers::POD' | ||
| // CHECK: CompoundLiteralExpr {{.*}} 'POD':'brace_initializers::POD' | ||
| // CHECK-NEXT: InitListExpr {{.*}} 'POD':'brace_initializers::POD' | ||
| // CHECK-NEXT: ConstantExpr {{.*}} | ||
| // CHECK-NEXT: IntegerLiteral {{.*}} 1{{$}} | ||
| // CHECK-NEXT: ConstantExpr {{.*}} | ||
| // CHECK-NEXT: IntegerLiteral {{.*}} 2{{$}} | ||
|
|
||
| void test() { | ||
| (void)(POD){1, 2}; | ||
| // CHECK-NOT: CXXBindTemporaryExpr {{.*}} 'POD':'brace_initializers::POD' | ||
| // CHECK-NOT: ConstantExpr {{.*}} 'POD':'brace_initializers::POD' | ||
| // CHECK: CompoundLiteralExpr {{.*}} 'POD':'brace_initializers::POD' | ||
| // CHECK-NEXT: InitListExpr {{.*}} 'POD':'brace_initializers::POD' | ||
| // CHECK-NEXT: IntegerLiteral {{.*}} 1{{$}} | ||
| // CHECK-NEXT: IntegerLiteral {{.*}} 2{{$}} | ||
|
|
||
| (void)(HasDtor){1, 2}; | ||
| // CHECK: CXXBindTemporaryExpr {{.*}} 'HasDtor':'brace_initializers::HasDtor' | ||
| // CHECK-NEXT: CompoundLiteralExpr {{.*}} 'HasDtor':'brace_initializers::HasDtor' | ||
| // CHECK-NEXT: InitListExpr {{.*}} 'HasDtor':'brace_initializers::HasDtor' | ||
| // CHECK-NEXT: IntegerLiteral {{.*}} 1{{$}} | ||
| // CHECK-NEXT: IntegerLiteral {{.*}} 2{{$}} | ||
|
|
||
| #if __cplusplus >= 201103L | ||
| (void)(HasCtor){1, 2}; | ||
| // CHECK-CXX11-NOT: CXXBindTemporaryExpr {{.*}} 'HasCtor':'brace_initializers::HasCtor' | ||
| // CHECK-CXX11-NOT: ConstantExpr {{.*}} 'HasCtor':'brace_initializers::HasCtor' | ||
| // CHECK-CXX11: CompoundLiteralExpr {{.*}} 'HasCtor':'brace_initializers::HasCtor' | ||
| // CHECK-CXX11-NEXT: CXXTemporaryObjectExpr {{.*}} 'HasCtor':'brace_initializers::HasCtor' | ||
| // CHECK-CXX11-NEXT: IntegerLiteral {{.*}} 1{{$}} | ||
| // CHECK-CXX11-NEXT: IntegerLiteral {{.*}} 2{{$}} | ||
|
|
||
| (void)(HasCtorDtor){1, 2}; | ||
| // CHECK-CXX11: CXXBindTemporaryExpr {{.*}} 'HasCtorDtor':'brace_initializers::HasCtorDtor' | ||
| // CHECK-CXX11-NOT: ConstantExpr {{.*}} 'HasCtorDtor':'brace_initializers::HasCtorDtor' | ||
| // CHECK-CXX11: CompoundLiteralExpr {{.*}} 'HasCtorDtor':'brace_initializers::HasCtorDtor' | ||
| // CHECK-CXX11-NEXT: CXXTemporaryObjectExpr {{.*}} 'HasCtorDtor':'brace_initializers::HasCtorDtor' | ||
| // CHECK-CXX11-NEXT: IntegerLiteral {{.*}} 1{{$}} | ||
| // CHECK-CXX11-NEXT: IntegerLiteral {{.*}} 2{{$}} | ||
| #endif | ||
| } | ||
|
|
||
| struct PrivateDtor { | ||
| int x, y; | ||
| private: | ||
| ~PrivateDtor(); // expected-note {{declared private here}} | ||
| }; | ||
|
|
||
| void testPrivateDtor() { | ||
| (void)(PrivateDtor){1, 2}; // expected-error {{temporary of type 'PrivateDtor' has private destructor}} | ||
| } | ||
| } | ||
|
|
||
| // This doesn't necessarily need to be an error, but CodeGen can't handle it | ||
| // at the moment. | ||
| int PR17415 = (int){PR17415}; // expected-error {{initializer element is not a compile-time constant}} | ||
|
|
||
| // Make sure we accept this. (Not sure if we actually should... but we do | ||
| // at the moment.) | ||
| template<unsigned> struct Value { }; | ||
| template<typename T> | ||
| int &check_narrowed(Value<sizeof((T){1.1})>); | ||
|
|
||
| #if __cplusplus >= 201103L | ||
| // Compound literals in global lambdas have automatic storage duration | ||
| // and are not subject to the constant-initialization rules. | ||
| int computed_with_lambda = [] { | ||
| int x = 5; | ||
| int result = ((int[]) { x, x + 2, x + 4, x + 6 })[0]; | ||
| return result; | ||
| }(); | ||
| #endif | ||
|
|
||
| namespace DynamicFileScopeLiteral { | ||
| // This covers the case where we have a file-scope compound literal with a | ||
| // non-constant initializer in C++. Previously, we had a bug where Clang forgot | ||
| // to consider initializer list elements for bases. | ||
| struct Empty {}; | ||
| struct Foo : Empty { // expected-note 0+ {{candidate constructor}} | ||
| int x; | ||
| int y; | ||
| }; | ||
| int f(); | ||
| #if __cplusplus < 201103L | ||
| // expected-error@+6 {{non-aggregate type 'Foo' cannot be initialized with an initializer list}} | ||
| #elif __cplusplus < 201703L | ||
| // expected-error@+4 {{no matching constructor}} | ||
| #else | ||
| // expected-error@+2 {{initializer element is not a compile-time constant}} | ||
| #endif | ||
| Foo o = (Foo){ {}, 1, f() }; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +1,33 @@ | ||
| // RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s | ||
| // RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s -fexperimental-new-constant-interpreter | ||
|
|
||
| namespace ns1 { | ||
| auto lstatic = []() static { return 3; }; | ||
| int (*f2)(void) = lstatic; | ||
|
|
||
| } | ||
|
|
||
| namespace ns1_1 { | ||
|
|
||
| auto lstatic = []() static consteval //expected-error{{cannot take address of consteval call}} \ | ||
| expected-note {{declared here}} | ||
| { return 3; }; | ||
|
|
||
| // FIXME: the above error should indicate that it was triggered below. | ||
| int (*f2)(void) = lstatic; | ||
|
|
||
| } | ||
|
|
||
|
|
||
| namespace ns2 { | ||
| auto lstatic = []() static { return 3; }; | ||
| constexpr int (*f2)(void) = lstatic; | ||
| static_assert(lstatic() == f2()); | ||
| } | ||
|
|
||
| namespace ns3 { | ||
| void main() { | ||
| static int x = 10; | ||
| auto L = []() static { return x; }; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,40 @@ | ||
| // RUN: %clang_cc1 -verify=gnu -std=gnu++11 %s | ||
| // RUN: %clang_cc1 -verify=expected,cxx11 -Wvla -std=gnu++11 %s | ||
| // RUN: %clang_cc1 -verify=expected,cxx11 -std=c++11 %s | ||
| // RUN: %clang_cc1 -verify=expected,cxx98 -std=c++98 %s | ||
| // RUN: %clang_cc1 -verify=expected,off -std=c++11 -Wno-vla-extension-static-assert %s | ||
| // gnu-no-diagnostics | ||
|
|
||
| // Demonstrate that we do not diagnose use of VLAs by default in GNU mode, but | ||
| // we do diagnose them in C++ mode. Also note that we suggest use of | ||
| // static_assert, but only in C++11 and later and only if the warning group is | ||
| // not disabled. | ||
|
|
||
| // C++98 mode does not emit the same notes as C++11 mode because in C++98, | ||
| // we're looking for an integer constant expression, whereas in C++11 and later, | ||
| // we're looking for a constant expression that is of integer type (these are | ||
| // different operations; ICE looks at the syntactic form of the expression, but | ||
| // C++11 constant expressions require calculating the expression value). | ||
| void func(int n) { // cxx11-note {{declared here}} off-note {{declared here}} | ||
| int vla[n]; // expected-warning {{variable length arrays in C++ are a Clang extension}} \ | ||
| cxx11-note {{function parameter 'n' with unknown value cannot be used in a constant expression}} \ | ||
| off-note {{function parameter 'n' with unknown value cannot be used in a constant expression}} | ||
| } | ||
|
|
||
| void old_style_static_assert(int n) { // cxx11-note 5 {{declared here}} off-note 2 {{declared here}} | ||
| int array1[n != 12 ? 1 : -1]; // cxx11-warning {{variable length arrays in C++ are a Clang extension; did you mean to use 'static_assert'?}} \ | ||
| cxx98-warning {{variable length arrays in C++ are a Clang extension}} \ | ||
| cxx11-note {{function parameter 'n' with unknown value cannot be used in a constant expression}} | ||
| int array2[n != 12 ? -1 : 1]; // cxx11-warning {{variable length arrays in C++ are a Clang extension; did you mean to use 'static_assert'?}} \ | ||
| cxx98-warning {{variable length arrays in C++ are a Clang extension}} \ | ||
| cxx11-note {{function parameter 'n' with unknown value cannot be used in a constant expression}} | ||
| int array3[n != 12 ? 1 : n]; // expected-warning {{variable length arrays in C++ are a Clang extension}} \ | ||
| cxx11-note {{function parameter 'n' with unknown value cannot be used in a constant expression}} \ | ||
| off-note {{function parameter 'n' with unknown value cannot be used in a constant expression}} | ||
| int array4[(n ? 1 : -1)]; // cxx11-warning {{variable length arrays in C++ are a Clang extension; did you mean to use 'static_assert'?}} \ | ||
| cxx98-warning {{variable length arrays in C++ are a Clang extension}} \ | ||
| cxx11-note {{function parameter 'n' with unknown value cannot be used in a constant expression}} | ||
| int array5[n ? 1 : 0]; // expected-warning {{variable length arrays in C++ are a Clang extension}} \ | ||
| cxx11-note {{function parameter 'n' with unknown value cannot be used in a constant expression}} \ | ||
| off-note {{function parameter 'n' with unknown value cannot be used in a constant expression}} | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,116 +1,116 @@ | ||
| // RUN: %clang_cc1 -fsyntax-only -Wredundant-move -std=c++11 -verify %s | ||
| // RUN: %clang_cc1 -fsyntax-only -Wredundant-move -std=c++11 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s | ||
| // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -ast-dump | FileCheck %s --check-prefix=CHECK-AST | ||
|
|
||
| // definitions for std::move | ||
| namespace std { | ||
| inline namespace foo { | ||
| template <class T> struct remove_reference { typedef T type; }; | ||
| template <class T> struct remove_reference<T&> { typedef T type; }; | ||
| template <class T> struct remove_reference<T&&> { typedef T type; }; | ||
|
|
||
| template <class T> typename remove_reference<T>::type &&move(T &&t); | ||
| } | ||
| } | ||
|
|
||
| // test1 and test2 should not warn until after implementation of DR1579. | ||
| struct A {}; | ||
| struct B : public A {}; | ||
|
|
||
| A test1(B b1) { | ||
| B b2; | ||
| return b1; | ||
| return b2; | ||
| return std::move(b1); | ||
| return std::move(b2); | ||
| } | ||
|
|
||
| struct C { | ||
| C() {} | ||
| C(A) {} | ||
| }; | ||
|
|
||
| C test2(A a1, B b1) { | ||
| A a2; | ||
| B b2; | ||
|
|
||
| return a1; | ||
| return a2; | ||
| return b1; | ||
| return b2; | ||
|
|
||
| return std::move(a1); | ||
| return std::move(a2); | ||
| return std::move(b1); | ||
| return std::move(b2); | ||
| } | ||
|
|
||
| // Copy of tests above with types changed to reference types. | ||
| A test3(B& b1) { | ||
| B& b2 = b1; | ||
| return b1; | ||
| return b2; | ||
| return std::move(b1); | ||
| return std::move(b2); | ||
| } | ||
|
|
||
| C test4(A& a1, B& b1) { | ||
| A& a2 = a1; | ||
| B& b2 = b1; | ||
|
|
||
| return a1; | ||
| return a2; | ||
| return b1; | ||
| return b2; | ||
|
|
||
| return std::move(a1); | ||
| return std::move(a2); | ||
| return std::move(b1); | ||
| return std::move(b2); | ||
| } | ||
|
|
||
| // PR23819, case 2 | ||
| struct D {}; | ||
| D test5(D d) { | ||
| return d; | ||
| // Verify the implicit move from the AST dump | ||
| // CHECK-AST: ReturnStmt{{.*}}line:[[@LINE-2]] | ||
| // CHECK-AST-NEXT: CXXConstructExpr{{.*}}D{{.*}}void (D &&) | ||
| // CHECK-AST-NEXT: ImplicitCastExpr | ||
| // CHECK-AST-NEXT: DeclRefExpr{{.*}}ParmVar{{.*}}'d' | ||
|
|
||
| return std::move(d); | ||
| // expected-warning@-1{{redundant move in return statement}} | ||
| // expected-note@-2{{remove std::move call here}} | ||
| // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:20}:"" | ||
| // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:21-[[@LINE-4]]:22}:"" | ||
| } | ||
|
|
||
| namespace templates { | ||
| struct A {}; | ||
| struct B { B(A); }; | ||
|
|
||
| // Warn once here since the type is not dependent. | ||
| template <typename T> | ||
| A test1(A a) { | ||
| return std::move(a); | ||
| // expected-warning@-1{{redundant move in return statement}} | ||
| // expected-note@-2{{remove std::move call here}} | ||
| // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:22}:"" | ||
| // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:23-[[@LINE-4]]:24}:"" | ||
| } | ||
| void run_test1() { | ||
| test1<A>(A()); | ||
| test1<B>(A()); | ||
| } | ||
|
|
||
| // T1 and T2 may not be the same, the warning may not always apply. | ||
| template <typename T1, typename T2> | ||
| T1 test2(T2 t) { | ||
| return std::move(t); | ||
| } | ||
| void run_test2() { | ||
| test2<A, A>(A()); | ||
| test2<B, A>(A()); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,91 +1,91 @@ | ||
| // RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -verify-ignore-unexpected | ||
|
|
||
| float2 test_no_second_arg(float2 p0) { | ||
| return __builtin_hlsl_elementwise_clamp(p0); | ||
| // expected-error@-1 {{too few arguments to function call, expected 3, have 1}} | ||
| } | ||
|
|
||
| float2 test_no_third_arg(float2 p0) { | ||
| return __builtin_hlsl_elementwise_clamp(p0, p0); | ||
| // expected-error@-1 {{too few arguments to function call, expected 3, have 2}} | ||
| } | ||
|
|
||
| float2 test_too_many_arg(float2 p0) { | ||
| return __builtin_hlsl_elementwise_clamp(p0, p0, p0, p0); | ||
| // expected-error@-1 {{too many arguments to function call, expected 3, have 4}} | ||
| } | ||
|
|
||
| float2 test_clamp_no_second_arg(float2 p0) { | ||
| return clamp(p0); | ||
| // expected-error@-1 {{no matching function for call to 'clamp'}} | ||
| } | ||
|
|
||
| float2 test_clamp_vector_size_mismatch(float3 p0, float2 p1) { | ||
| return clamp(p0, p0, p1); | ||
| // expected-warning@-1 {{implicit conversion truncates vector: 'float3' (aka 'vector<float, 3>') to 'float __attribute__((ext_vector_type(2)))' (vector of 2 'float' values)}} | ||
| } | ||
|
|
||
| float2 test_clamp_builtin_vector_size_mismatch(float3 p0, float2 p1) { | ||
| return __builtin_hlsl_elementwise_clamp(p0, p1, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must have the same type}} | ||
| } | ||
|
|
||
| float test_clamp_scalar_mismatch(float p0, half p1) { | ||
| return clamp(p1, p0, p1); | ||
| // expected-error@-1 {{call to 'clamp' is ambiguous}} | ||
| } | ||
|
|
||
| float2 test_clamp_element_type_mismatch(half2 p0, float2 p1) { | ||
| return clamp(p1, p0, p1); | ||
| // expected-error@-1 {{call to 'clamp' is ambiguous}} | ||
| } | ||
|
|
||
| float2 test_builtin_clamp_float2_splat(float p0, float2 p1) { | ||
| return __builtin_hlsl_elementwise_clamp(p0, p1, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must be vectors}} | ||
| } | ||
|
|
||
| float3 test_builtin_clamp_float3_splat(float p0, float3 p1) { | ||
| return __builtin_hlsl_elementwise_clamp(p0, p1, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must be vectors}} | ||
| } | ||
|
|
||
| float4 test_builtin_clamp_float4_splat(float p0, float4 p1) { | ||
| return __builtin_hlsl_elementwise_clamp(p0, p1, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must be vectors}} | ||
| } | ||
|
|
||
| float2 test_clamp_float2_int_splat(float2 p0, int p1) { | ||
| return __builtin_hlsl_elementwise_clamp(p0, p1, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must be vectors}} | ||
| } | ||
|
|
||
| float3 test_clamp_float3_int_splat(float3 p0, int p1) { | ||
| return __builtin_hlsl_elementwise_clamp(p0, p1, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must be vectors}} | ||
| } | ||
|
|
||
| float2 test_builtin_clamp_int_vect_to_float_vec_promotion(int2 p0, float p1) { | ||
| return __builtin_hlsl_elementwise_clamp(p0, p1, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must be vectors}} | ||
| } | ||
|
|
||
| float test_builtin_clamp_bool_type_promotion(bool p0) { | ||
| return __builtin_hlsl_elementwise_clamp(p0, p0, p0); | ||
| // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was 'bool')}} | ||
| } | ||
|
|
||
| float builtin_bool_to_float_type_promotion(float p0, bool p1) { | ||
| return __builtin_hlsl_elementwise_clamp(p0, p0, p1); | ||
| // expected-error@-1 {{3rd argument must be a floating point type (was 'bool')}} | ||
| } | ||
|
|
||
| float builtin_bool_to_float_type_promotion2(bool p0, float p1) { | ||
| return __builtin_hlsl_elementwise_clamp(p1, p0, p1); | ||
| // expected-error@-1 {{2nd argument must be a floating point type (was 'bool')}} | ||
| } | ||
|
|
||
| float builtin_clamp_int_to_float_promotion(float p0, int p1) { | ||
| return __builtin_hlsl_elementwise_clamp(p0, p0, p1); | ||
| // expected-error@-1 {{3rd argument must be a floating point type (was 'int')}} | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,119 +1,119 @@ | ||
| // RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -verify-ignore-unexpected | ||
|
|
||
| float test_no_second_arg(float2 p0) { | ||
| return __builtin_hlsl_dot(p0); | ||
| // expected-error@-1 {{too few arguments to function call, expected 2, have 1}} | ||
| } | ||
|
|
||
| float test_too_many_arg(float2 p0) { | ||
| return __builtin_hlsl_dot(p0, p0, p0); | ||
| // expected-error@-1 {{too many arguments to function call, expected 2, have 3}} | ||
| } | ||
|
|
||
| float test_dot_no_second_arg(float2 p0) { | ||
| return dot(p0); | ||
| // expected-error@-1 {{no matching function for call to 'dot'}} | ||
| } | ||
|
|
||
| float test_dot_vector_size_mismatch(float3 p0, float2 p1) { | ||
| return dot(p0, p1); | ||
| // expected-warning@-1 {{implicit conversion truncates vector: 'float3' (aka 'vector<float, 3>') to 'float __attribute__((ext_vector_type(2)))' (vector of 2 'float' values)}} | ||
| } | ||
|
|
||
| float test_dot_builtin_vector_size_mismatch(float3 p0, float2 p1) { | ||
| return __builtin_hlsl_dot(p0, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must have the same type}} | ||
| } | ||
|
|
||
| float test_dot_scalar_mismatch(float p0, int p1) { | ||
| return dot(p0, p1); | ||
| // expected-error@-1 {{call to 'dot' is ambiguous}} | ||
| } | ||
|
|
||
| float test_dot_element_type_mismatch(int2 p0, float2 p1) { | ||
| return dot(p0, p1); | ||
| // expected-error@-1 {{call to 'dot' is ambiguous}} | ||
| } | ||
|
|
||
| //NOTE: for all the *_promotion we are intentionally not handling type promotion in builtins | ||
| float test_builtin_dot_vec_int_to_float_promotion(int2 p0, float2 p1) { | ||
| return __builtin_hlsl_dot(p0, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must have the same type}} | ||
| } | ||
|
|
||
| int64_t test_builtin_dot_vec_int_to_int64_promotion(int64_t2 p0, int2 p1) { | ||
| return __builtin_hlsl_dot(p0, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must have the same type}} | ||
| } | ||
|
|
||
| float test_builtin_dot_vec_half_to_float_promotion(float2 p0, half2 p1) { | ||
| return __builtin_hlsl_dot(p0, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must have the same type}} | ||
| } | ||
|
|
||
| #ifdef __HLSL_ENABLE_16_BIT | ||
| float test_builtin_dot_vec_int16_to_float_promotion(float2 p0, int16_t2 p1) { | ||
| return __builtin_hlsl_dot(p0, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must have the same type}} | ||
| } | ||
|
|
||
| half test_builtin_dot_vec_int16_to_half_promotion(half2 p0, int16_t2 p1) { | ||
| return __builtin_hlsl_dot(p0, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must have the same type}} | ||
| } | ||
|
|
||
| int test_builtin_dot_vec_int16_to_int_promotion(int2 p0, int16_t2 p1) { | ||
| return __builtin_hlsl_dot(p0, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must have the same type}} | ||
| } | ||
|
|
||
| int64_t test_builtin_dot_vec_int16_to_int64_promotion(int64_t2 p0, | ||
| int16_t2 p1) { | ||
| return __builtin_hlsl_dot(p0, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must have the same type}} | ||
| } | ||
| #endif | ||
|
|
||
| float test_builtin_dot_float2_splat(float p0, float2 p1) { | ||
| return __builtin_hlsl_dot(p0, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must be vectors}} | ||
| } | ||
|
|
||
| float test_builtin_dot_float3_splat(float p0, float3 p1) { | ||
| return __builtin_hlsl_dot(p0, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must be vectors}} | ||
| } | ||
|
|
||
| float test_builtin_dot_float4_splat(float p0, float4 p1) { | ||
| return __builtin_hlsl_dot(p0, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must be vectors}} | ||
| } | ||
|
|
||
| float test_dot_float2_int_splat(float2 p0, int p1) { | ||
| return __builtin_hlsl_dot(p0, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must be vectors}} | ||
| } | ||
|
|
||
| float test_dot_float3_int_splat(float3 p0, int p1) { | ||
| return __builtin_hlsl_dot(p0, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must be vectors}} | ||
| } | ||
|
|
||
| float test_builtin_dot_int_vect_to_float_vec_promotion(int2 p0, float p1) { | ||
| return __builtin_hlsl_dot(p0, p1); | ||
| // expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must be vectors}} | ||
| } | ||
|
|
||
| int test_builtin_dot_bool_type_promotion(bool p0, bool p1) { | ||
| return __builtin_hlsl_dot(p0, p1); | ||
| // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was 'bool')}} | ||
| } | ||
|
|
||
| double test_dot_double(double2 p0, double2 p1) { | ||
| return dot(p0, p1); | ||
| // expected-error@-1 {{call to 'dot' is ambiguous}} | ||
| } | ||
| double test_dot_double_builtin(double2 p0, double2 p1) { | ||
| return __builtin_hlsl_dot(p0, p1); | ||
| // expected-error@-1 {{passing 'double2' (aka 'vector<double, 2>') to parameter of incompatible type '__attribute__((__vector_size__(2 * sizeof(float)))) float' (vector of 2 'float' values)}} | ||
| } |