| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,237 @@ | ||
| // RUN: %clang_cc1 -std=c++23 -Wno-unused %s -verify | ||
|
|
||
| namespace FoundNothing { | ||
| template<typename T> | ||
| void f0(T &t) { | ||
| t.x<0; | ||
| t.x<0>; // expected-error {{expected expression}} | ||
| t.x<0>1; | ||
| } | ||
|
|
||
| template<typename T> | ||
| struct A { | ||
| void f1() { | ||
| this->x<0; // expected-error {{no member named 'x' in 'A<T>'}} | ||
| this->x<0>; // expected-error {{no member named 'x' in 'A<T>'}} | ||
| // expected-error@-1 {{expected expression}} | ||
| this->x<0>1; // expected-error {{no member named 'x' in 'A<T>'}} | ||
| } | ||
| }; | ||
| } // namespace FoundNothing | ||
|
|
||
| namespace FoundSingleNonTemplate { | ||
| void f0(); | ||
|
|
||
| struct A0; | ||
|
|
||
| template<typename T> | ||
| void g0(T &t) { | ||
| t.f0<0; | ||
| t.f0<0>; // expected-error {{expected expression}} | ||
| t.f0<0>1; | ||
|
|
||
| t.A0<0; | ||
| t.A0<0>; // expected-error {{expected expression}} | ||
| t.A0<0>1; | ||
| } | ||
|
|
||
| template<typename T> | ||
| struct B { | ||
| void f1(); | ||
|
|
||
| struct A1; // expected-note 3{{member 'A1' declared here}} | ||
|
|
||
| void g1() { | ||
| this->f0<0; // expected-error {{no member named 'f0' in 'B<T>'}} | ||
| this->f0<0>; // expected-error {{no member named 'f0' in 'B<T>'}} | ||
| // expected-error@-1 {{expected expression}} | ||
| this->f0<0>1; // expected-error {{no member named 'f0' in 'B<T>'}} | ||
|
|
||
| this->A0<0; // expected-error {{no member named 'A0' in 'B<T>'}} | ||
| this->A0<0>; // expected-error {{no member named 'A0' in 'B<T>'}} | ||
| // expected-error@-1 {{expected expression}} | ||
| this->A0<0>1; // expected-error {{no member named 'A0' in 'B<T>'}} | ||
|
|
||
| this->f1<0; // expected-error {{reference to non-static member function must be called}} | ||
| this->f1<0>; // expected-error {{reference to non-static member function must be called}} | ||
| // expected-error@-1 {{expected expression}} | ||
| this->f1<0>1; // expected-error {{reference to non-static member function must be called}} | ||
|
|
||
| this->A1<0; // expected-error {{cannot refer to type member 'A1' in 'B<T>' with '->'}} | ||
| this->A1<0>; // expected-error {{cannot refer to type member 'A1' in 'B<T>' with '->'}} | ||
| // expected-error@-1 {{expected expression}} | ||
| this->A1<0>1; // expected-error {{cannot refer to type member 'A1' in 'B<T>' with '->'}} | ||
| } | ||
| }; | ||
| } // namespace FoundSingleNonTemplate | ||
|
|
||
| namespace FoundSingleTemplate { | ||
| template<int I> | ||
| void f0(); | ||
|
|
||
| template<int I> | ||
| struct A0; | ||
|
|
||
| template<typename T> | ||
| void g0(T &t) { | ||
| t.f0<0; | ||
| t.f0<0>; // expected-error {{expected expression}} | ||
| t.f0<0>1; | ||
|
|
||
| t.A0<0; | ||
| t.A0<0>; // expected-error {{expected expression}} | ||
| t.A0<0>1; | ||
| } | ||
|
|
||
| template<typename T> | ||
| struct B { | ||
| template<int I> | ||
| void f1(); // expected-note 2{{possible target for call}} | ||
|
|
||
| template<int I> | ||
| struct A1; // expected-note 2{{member 'A1' declared here}} | ||
|
|
||
| void g1() { | ||
| this->f0<0; // expected-error {{no member named 'f0' in 'B<T>'}} | ||
| this->f0<0>; // expected-error {{no member named 'f0' in 'B<T>'}} | ||
| this->f0<0>1; // expected-error {{no member named 'f0' in 'B<T>'}} | ||
| // expected-error@-1 {{expected ';' after expression}} | ||
|
|
||
| this->A0<0; // expected-error {{no member named 'A0' in 'B<T>'}} | ||
| this->A0<0>; // expected-error {{no member named 'A0' in 'B<T>'}} | ||
| this->A0<0>1; // expected-error {{no member named 'A0' in 'B<T>'}} | ||
| // expected-error@-1 {{expected ';' after expression}} | ||
|
|
||
|
|
||
| this->f1<0; // expected-error {{expected '>'}} | ||
| // expected-note@-1 {{to match this '<'}} | ||
| this->f1<0>; // expected-error {{reference to non-static member function must be called}} | ||
| this->f1<0>1; // expected-error {{reference to non-static member function must be called}} | ||
| // expected-error@-1 {{expected ';' after expression}} | ||
|
|
||
| this->A1<0; // expected-error {{expected '>'}} | ||
| // expected-note@-1 {{to match this '<'}} | ||
| this->A1<0>; // expected-error {{cannot refer to member 'A1' in 'B<T>' with '->'}} | ||
| this->A1<0>1; // expected-error {{cannot refer to member 'A1' in 'B<T>' with '->'}} | ||
| // expected-error@-1 {{expected ';' after expression}} | ||
| } | ||
| }; | ||
| } // namespace FoundSingleTemplate | ||
|
|
||
| namespace FoundAmbiguousNonTemplate { | ||
| inline namespace N { | ||
| int f0; | ||
|
|
||
| struct A0; | ||
| } // namespace N | ||
|
|
||
| void f0(); | ||
|
|
||
| struct A0; | ||
|
|
||
| template<typename T> | ||
| void g0(T &t) { | ||
| t.f0<0; | ||
| t.f0<0>; // expected-error {{expected expression}} | ||
| t.f0<0>1; | ||
|
|
||
| t.A0<0; | ||
| t.A0<0>; // expected-error {{expected expression}} | ||
| t.A0<0>1; | ||
| } | ||
|
|
||
| template<typename T> | ||
| struct B { | ||
| void f1(); | ||
|
|
||
| struct A1; // expected-note 3{{member 'A1' declared here}} | ||
|
|
||
| void g1() { | ||
| this->f0<0; // expected-error {{no member named 'f0' in 'B<T>'}} | ||
| this->f0<0>; // expected-error {{no member named 'f0' in 'B<T>'}} | ||
| // expected-error@-1 {{expected expression}} | ||
| this->f0<0>1; // expected-error {{no member named 'f0' in 'B<T>'}} | ||
|
|
||
| this->A0<0; // expected-error {{no member named 'A0' in 'B<T>'}} | ||
| this->A0<0>; // expected-error {{no member named 'A0' in 'B<T>'}} | ||
| // expected-error@-1 {{expected expression}} | ||
| this->A0<0>1; // expected-error {{no member named 'A0' in 'B<T>'}} | ||
|
|
||
| this->f1<0; // expected-error {{reference to non-static member function must be called}} | ||
| this->f1<0>; // expected-error {{reference to non-static member function must be called}} | ||
| // expected-error@-1 {{expected expression}} | ||
| this->f1<0>1; // expected-error {{reference to non-static member function must be called}} | ||
|
|
||
| this->A1<0; // expected-error {{cannot refer to type member 'A1' in 'B<T>' with '->'}} | ||
| this->A1<0>; // expected-error {{cannot refer to type member 'A1' in 'B<T>' with '->'}} | ||
| // expected-error@-1 {{expected expression}} | ||
| this->A1<0>1; // expected-error {{cannot refer to type member 'A1' in 'B<T>' with '->'}} | ||
| } | ||
| }; | ||
| } // namespace FoundAmbiguousNonTemplates | ||
|
|
||
| namespace FoundAmbiguousTemplate { | ||
| inline namespace N { | ||
| template<int I> | ||
| int f0; // expected-note 3{{candidate found by name lookup is 'FoundAmbiguousTemplate::N::f0'}} | ||
|
|
||
| template<int I> | ||
| struct A0; // expected-note 3{{candidate found by name lookup is 'FoundAmbiguousTemplate::N::A0'}} | ||
| } // namespace N | ||
|
|
||
| template<int I> | ||
| void f0(); // expected-note 3{{candidate found by name lookup is 'FoundAmbiguousTemplate::f0'}} | ||
|
|
||
| template<int I> | ||
| struct A0; // expected-note 3{{candidate found by name lookup is 'FoundAmbiguousTemplate::A0'}} | ||
|
|
||
| template<typename T> | ||
| void g0(T &t) { | ||
| t.f0<0; | ||
| t.f0<0>; // expected-error {{expected expression}} | ||
| t.f0<0>1; | ||
|
|
||
| t.A0<0; | ||
| t.A0<0>; // expected-error {{expected expression}} | ||
| t.A0<0>1; | ||
| } | ||
|
|
||
| template<typename T> | ||
| struct B { | ||
| template<int I> | ||
| void f1(); // expected-note 2{{possible target for call}} | ||
|
|
||
| template<int I> | ||
| struct A1; // expected-note 2{{member 'A1' declared here}} | ||
|
|
||
| void g1() { | ||
| this->f0<0; // expected-error {{no member named 'f0' in 'B<T>'}} | ||
| // expected-error@-1 {{reference to 'f0' is ambiguous}} | ||
| this->f0<0>; // expected-error {{no member named 'f0' in 'B<T>'}} | ||
| // expected-error@-1 {{reference to 'f0' is ambiguous}} | ||
| this->f0<0>1; // expected-error {{no member named 'f0' in 'B<T>'}} | ||
| // expected-error@-1 {{expected ';' after expression}} | ||
| // expected-error@-2 {{reference to 'f0' is ambiguous}} | ||
|
|
||
| this->A0<0; // expected-error {{no member named 'A0' in 'B<T>'}} | ||
| // expected-error@-1 {{reference to 'A0' is ambiguous}} | ||
| this->A0<0>; // expected-error {{no member named 'A0' in 'B<T>'}} | ||
| // expected-error@-1 {{reference to 'A0' is ambiguous}} | ||
| this->A0<0>1; // expected-error {{no member named 'A0' in 'B<T>'}} | ||
| // expected-error@-1 {{expected ';' after expression}} | ||
| // expected-error@-2 {{reference to 'A0' is ambiguous}} | ||
|
|
||
| this->f1<0; // expected-error {{expected '>'}} | ||
| // expected-note@-1 {{to match this '<'}} | ||
| this->f1<0>; // expected-error {{reference to non-static member function must be called}} | ||
| this->f1<0>1; // expected-error {{reference to non-static member function must be called}} | ||
| // expected-error@-1 {{expected ';' after expression}} | ||
|
|
||
| this->A1<0; // expected-error {{expected '>'}} | ||
| // expected-note@-1 {{to match this '<'}} | ||
| this->A1<0>; // expected-error {{cannot refer to member 'A1' in 'B<T>' with '->'}} | ||
| this->A1<0>1; // expected-error {{cannot refer to member 'A1' in 'B<T>' with '->'}} | ||
| // expected-error@-1 {{expected ';' after expression}} | ||
| } | ||
| }; | ||
| } // namespace FoundAmbiguousTemplate |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| // RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ | ||
| // RUN: dxil-pc-shadermodel6.3-library -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s | ||
|
|
||
| /*** for ***/ | ||
| void for_count() | ||
| { | ||
| // CHECK-LABEL: for_count | ||
| [unroll(8)] | ||
| for( int i = 0; i < 1000; ++i); | ||
| // CHECK: br label %{{.*}}, !llvm.loop ![[FOR_DISTINCT:.*]] | ||
| } | ||
|
|
||
| void for_disable() | ||
| { | ||
| // CHECK-LABEL: for_disable | ||
| [loop] | ||
| for( int i = 0; i < 1000; ++i); | ||
| // CHECK: br label %{{.*}}, !llvm.loop ![[FOR_DISABLE:.*]] | ||
| } | ||
|
|
||
| void for_enable() | ||
| { | ||
| // CHECK-LABEL: for_enable | ||
| [unroll] | ||
| for( int i = 0; i < 1000; ++i); | ||
| // CHECK: br label %{{.*}}, !llvm.loop ![[FOR_ENABLE:.*]] | ||
| } | ||
|
|
||
| void for_nested_one_unroll_enable() | ||
| { | ||
| // CHECK-LABEL: for_nested_one_unroll_enable | ||
| int s = 0; | ||
| [unroll] | ||
| for( int i = 0; i < 1000; ++i) { | ||
| for( int j = 0; j < 10; ++j) | ||
| s += i + j; | ||
| } | ||
| // CHECK: br label %{{.*}}, !llvm.loop ![[FOR_NESTED_ENABLE:.*]] | ||
| // CHECK-NOT: br label %{{.*}}, !llvm.loop ![[FOR_NESTED_1_ENABLE:.*]] | ||
| } | ||
|
|
||
| void for_nested_two_unroll_enable() | ||
| { | ||
| // CHECK-LABEL: for_nested_two_unroll_enable | ||
| int s = 0; | ||
| [unroll] | ||
| for( int i = 0; i < 1000; ++i) { | ||
| [unroll] | ||
| for( int j = 0; j < 10; ++j) | ||
| s += i + j; | ||
| } | ||
| // CHECK: br label %{{.*}}, !llvm.loop ![[FOR_NESTED2_ENABLE:.*]] | ||
| // CHECK: br label %{{.*}}, !llvm.loop ![[FOR_NESTED2_1_ENABLE:.*]] | ||
| } | ||
|
|
||
|
|
||
| /*** while ***/ | ||
| void while_count() | ||
| { | ||
| // CHECK-LABEL: while_count | ||
| int i = 1000; | ||
| [unroll(4)] | ||
| while(i-->0); | ||
| // CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_DISTINCT:.*]] | ||
| } | ||
|
|
||
| void while_disable() | ||
| { | ||
| // CHECK-LABEL: while_disable | ||
| int i = 1000; | ||
| [loop] | ||
| while(i-->0); | ||
| // CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_DISABLE:.*]] | ||
| } | ||
|
|
||
| void while_enable() | ||
| { | ||
| // CHECK-LABEL: while_enable | ||
| int i = 1000; | ||
| [unroll] | ||
| while(i-->0); | ||
| // CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_ENABLE:.*]] | ||
| } | ||
|
|
||
| /*** do ***/ | ||
| void do_count() | ||
| { | ||
| // CHECK-LABEL: do_count | ||
| int i = 1000; | ||
| [unroll(16)] | ||
| do {} while(i--> 0); | ||
| // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_DISTINCT:.*]] | ||
| } | ||
|
|
||
| void do_disable() | ||
| { | ||
| // CHECK-LABEL: do_disable | ||
| int i = 1000; | ||
| [loop] | ||
| do {} while(i--> 0); | ||
| // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_DISABLE:.*]] | ||
| } | ||
|
|
||
| void do_enable() | ||
| { | ||
| // CHECK-LABEL: do_enable | ||
| int i = 1000; | ||
| [unroll] | ||
| do {} while(i--> 0); | ||
| // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_ENABLE:.*]] | ||
| } | ||
|
|
||
|
|
||
| // CHECK: ![[FOR_DISTINCT]] = distinct !{![[FOR_DISTINCT]], ![[FOR_COUNT:.*]]} | ||
| // CHECK: ![[FOR_COUNT]] = !{!"llvm.loop.unroll.count", i32 8} | ||
| // CHECK: ![[FOR_DISABLE]] = distinct !{![[FOR_DISABLE]], ![[DISABLE:.*]]} | ||
| // CHECK: ![[DISABLE]] = !{!"llvm.loop.unroll.disable"} | ||
| // CHECK: ![[FOR_ENABLE]] = distinct !{![[FOR_ENABLE]], ![[ENABLE:.*]]} | ||
| // CHECK: ![[ENABLE]] = !{!"llvm.loop.unroll.enable"} | ||
| // CHECK: ![[FOR_NESTED_ENABLE]] = distinct !{![[FOR_NESTED_ENABLE]], ![[ENABLE]]} | ||
| // CHECK: ![[FOR_NESTED2_ENABLE]] = distinct !{![[FOR_NESTED2_ENABLE]], ![[ENABLE]]} | ||
| // CHECK: ![[FOR_NESTED2_1_ENABLE]] = distinct !{![[FOR_NESTED2_1_ENABLE]], ![[ENABLE]]} | ||
| // CHECK: ![[WHILE_DISTINCT]] = distinct !{![[WHILE_DISTINCT]], ![[WHILE_COUNT:.*]]} | ||
| // CHECK: ![[WHILE_COUNT]] = !{!"llvm.loop.unroll.count", i32 4} | ||
| // CHECK: ![[WHILE_DISABLE]] = distinct !{![[WHILE_DISABLE]], ![[DISABLE]]} | ||
| // CHECK: ![[WHILE_ENABLE]] = distinct !{![[WHILE_ENABLE]], ![[ENABLE]]} | ||
| // CHECK: ![[DO_DISTINCT]] = distinct !{![[DO_DISTINCT]], ![[DO_COUNT:.*]]} | ||
| // CHECK: ![[DO_COUNT]] = !{!"llvm.loop.unroll.count", i32 16} | ||
| // CHECK: ![[DO_DISABLE]] = distinct !{![[DO_DISABLE]], ![[DISABLE]]} | ||
| // CHECK: ![[DO_ENABLE]] = distinct !{![[DO_ENABLE]], ![[ENABLE]]} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // Make sure that __cpuidex in cpuid.h doesn't conflict with the MS | ||
| // extensions built in by ensuring compilation succeeds: | ||
| // RUN: %clang_cc1 %s -ffreestanding -fms-extensions -fms-compatibility \ | ||
| // RUN: -fms-compatibility-version=19.00 -triple x86_64-pc-windows-msvc -emit-llvm -o - | ||
| // %clang_cc1 %s -ffreestanding -triple x86_64-w64-windows-gnu -fms-extensions -emit-llvm -o - | ||
| // RUN: %clang_cc1 %s -ffreestanding -fopenmp -fopenmp-is-target-device -aux-triple x86_64-unknown-linux-gnu | ||
|
|
||
| typedef __SIZE_TYPE__ size_t; | ||
|
|
||
| // We declare __cpuidex here as where the buitlin should be exposed (MSVC), the | ||
| // declaration is in <intrin.h>, but <intrin.h> is not available from all the | ||
| // targets that are being tested here. | ||
| void __cpuidex (int[4], int, int); | ||
|
|
||
| #include <cpuid.h> | ||
|
|
||
| int cpuid_info[4]; | ||
|
|
||
| void test_cpuidex(unsigned level, unsigned count) { | ||
| __cpuidex(cpuid_info, level, count); | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| // RUN: %clang_cc1 -O0 -finclude-default-header -fsyntax-only -triple dxil-pc-shadermodel6.6-library %s -verify | ||
| void unroll_no_vars() { | ||
| int I = 3; | ||
| [unroll(I)] // expected-error {{'unroll' attribute requires an integer constant}} | ||
| while (I--); | ||
| } | ||
|
|
||
| void unroll_arg_count() { | ||
| [unroll(2,4)] // expected-error {{'unroll' attribute takes no more than 1 argument}} | ||
| for(int i=0; i<100; i++); | ||
| } | ||
|
|
||
| void loop_arg_count() { | ||
| [loop(2)] // expected-error {{'loop' attribute takes no more than 0 argument}} | ||
| for(int i=0; i<100; i++); | ||
| } | ||
|
|
||
| void unroll_no_negative() { | ||
| [unroll(-1)] // expected-error {{invalid value '-1'; must be positive}} | ||
| for(int i=0; i<100; i++); | ||
| } | ||
|
|
||
| void unroll_no_zero() { | ||
| [unroll(0)] // expected-error {{invalid value '0'; must be positive}} | ||
| for(int i=0; i<100; i++); | ||
| } | ||
|
|
||
| void unroll_no_float() { | ||
| [unroll(2.1)] // expected-error {{invalid argument of type 'float'; expected an integer type}} | ||
| for(int i=0; i<100; i++); | ||
| } | ||
|
|
||
| void unroll_no_bool_false() { | ||
| [unroll(false)] // expected-error {{invalid argument of type 'bool'; expected an integer type}} | ||
| for(int i=0; i<100; i++); | ||
| } | ||
|
|
||
| void unroll_no_bool_true() { | ||
| [unroll(true)] // expected-error {{invalid argument of type 'bool'; expected an integer type}} | ||
| for(int i=0; i<100; i++); | ||
| } | ||
|
|
||
| void unroll_loop_enforcement() { | ||
| int x[10]; | ||
| [unroll(4)] // expected-error {{'unroll' attribute only applies to 'for', 'while', and 'do' statements}} | ||
| if (x[0]) | ||
| x[0] = 15; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,5 +33,5 @@ | |
| ) | ||
| ) | ||
|
|
||
| if config.host_os not in ["Linux", "FreeBSD", "NetBSD"]: | ||
| config.unsupported = True | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| ! RUN: %python %S/test_modfile.py %s %flang_fc1 -fhermetic-module-files | ||
| module m1 | ||
| integer, parameter :: n = 123 | ||
| end | ||
|
|
||
| module m2 | ||
| use m1 | ||
| end | ||
|
|
||
| module m3 | ||
| use m1, m => n | ||
| end | ||
|
|
||
| module m4 | ||
| use m2 | ||
| use m3 | ||
| end | ||
|
|
||
| !Expect: m1.mod | ||
| !module m1 | ||
| !integer(4),parameter::n=123_4 | ||
| !end | ||
|
|
||
| !Expect: m2.mod | ||
| !module m2 | ||
| !use m1,only:n | ||
| !end | ||
| !module m1 | ||
| !integer(4),parameter::n=123_4 | ||
| !end | ||
|
|
||
| !Expect: m3.mod | ||
| !module m3 | ||
| !use m1,only:m=>n | ||
| !end | ||
| !module m1 | ||
| !integer(4),parameter::n=123_4 | ||
| !end | ||
|
|
||
| !Expect: m4.mod | ||
| !module m4 | ||
| !use m2,only:n | ||
| !use m3,only:m | ||
| !end | ||
| !module m2 | ||
| !use m1,only:n | ||
| !end | ||
| !module m3 | ||
| !use m1,only:m=>n | ||
| !end | ||
| !module m1 | ||
| !integer(4),parameter::n=123_4 | ||
| !end |