diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:04:05 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:04:05 +0000 |
commit | 676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63 (patch) | |
tree | 02a1ac369cb734d0abfa5000dd86e5b7797e6a74 /test/Parser | |
parent | c7e70c433efc6953dc3888b9fbf9f3512d7da2b0 (diff) |
Notes
Diffstat (limited to 'test/Parser')
20 files changed, 509 insertions, 84 deletions
diff --git a/test/Parser/DelayedTemplateParsing.cpp b/test/Parser/DelayedTemplateParsing.cpp index 6ea245c2d4e42..c65e80b1f732c 100644 --- a/test/Parser/DelayedTemplateParsing.cpp +++ b/test/Parser/DelayedTemplateParsing.cpp @@ -181,3 +181,33 @@ static void h() { } } + +struct PR38460 { + template <typename> + struct T { + static void foo() { + struct U { + void dummy() { + use_delayed_identifier(); + } + }; + } + }; +}; +void use_delayed_identifier(); +void trigger_PR38460() { + PR38460::T<int>::foo(); +} + +template <typename> struct PR38460_2 { + struct p { + struct G { + bool operator()(int) {} + }; + }; + static void as() { + typename p::G g; + g(0); + } +}; +template struct PR38460_2<int>; diff --git a/test/Parser/cuda-kernel-call-c++11.cu b/test/Parser/cuda-kernel-call-c++11.cu index 8f833f79af508..1870b201ad91b 100644 --- a/test/Parser/cuda-kernel-call-c++11.cu +++ b/test/Parser/cuda-kernel-call-c++11.cu @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -template<typename> struct S {}; +template<typename T=int> struct S {}; template<typename> void f(); @@ -11,10 +11,14 @@ void foo(void) { // expected-no-diagnostics S<S<S<int>>> s3; + S<S<S<>>> s30; S<S<S<S<int>>>> s4; + S<S<S<S<>>>> s40; S<S<S<S<S<int>>>>> s5; + S<S<S<S<S<>>>>> s50; (void)(&f<S<S<int>>>==0); + (void)(&f<S<S<>>>==0); } diff --git a/test/Parser/cuda-kernel-call.cu b/test/Parser/cuda-kernel-call.cu index 1970c558c5063..2a409aa3777ea 100644 --- a/test/Parser/cuda-kernel-call.cu +++ b/test/Parser/cuda-kernel-call.cu @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -template<typename> struct S {}; +template<typename T=int> struct S {}; template<typename> void f(); void foo(void) { @@ -13,5 +13,7 @@ void foo(void) { // The following two are parse errors because -std=c++11 is not enabled. S<S<S<int>>> s; // expected-error 2{{use '> >'}} + S<S<S<>>> s1; // expected-error 2{{use '> >'}} (void)(&f<S<S<int>>>==0); // expected-error 2{{use '> >'}} + (void)(&f<S<S<>>>==0); // expected-error 2{{use '> >'}} } diff --git a/test/Parser/cxx0x-attributes.cpp b/test/Parser/cxx0x-attributes.cpp index e01491db41339..101e03845b8f2 100644 --- a/test/Parser/cxx0x-attributes.cpp +++ b/test/Parser/cxx0x-attributes.cpp @@ -373,3 +373,11 @@ int fallthru(int n) { [[attr_name, attr_name_2(bitor), attr_name_3(com, pl)]] int macro_attrs; // expected-warning {{unknown attribute 'compl' ignored}} \ expected-warning {{unknown attribute 'bitor' ignored}} \ expected-warning {{unknown attribute 'bitand' ignored}} + +// Check that we can parse an attribute in our vendor namespace. +[[clang::annotate("test")]] void annotate1(); +[[_Clang::annotate("test")]] void annotate2(); +// Note: __clang__ is a predefined macro, which is why _Clang is the +// prefered "protected" vendor namespace. We support __clang__ only for +// people expecting it to behave the same as __gnu__. +[[__clang__::annotate("test")]] void annotate3(); // expected-warning {{'__clang__' is a predefined macro name, not an attribute scope specifier; did you mean '_Clang' instead?}} diff --git a/test/Parser/cxx1z-decomposition.cpp b/test/Parser/cxx1z-decomposition.cpp index cf4ba77723ad2..1e184a7fac540 100644 --- a/test/Parser/cxx1z-decomposition.cpp +++ b/test/Parser/cxx1z-decomposition.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -std=c++1z %s -verify -fcxx-exceptions +// RUN: not %clang_cc1 -std=c++1z %s -emit-llvm-only -fcxx-exceptions struct S { int a, b, c; }; diff --git a/test/Parser/cxx1z-init-statement.cpp b/test/Parser/cxx1z-init-statement.cpp index 3d119ef8e709c..ade60dc762d5c 100644 --- a/test/Parser/cxx1z-init-statement.cpp +++ b/test/Parser/cxx1z-init-statement.cpp @@ -13,9 +13,9 @@ int f() { if (T(n) = 0; n) {} // init-statement expressions - if (T{f()}; f()) {} - if (T{f()}, g, h; f()) {} // expected-warning 2{{unused}} - if (T(f()), g, h + 1; f()) {} // expected-warning 2{{unused}} + if (T{f()}; f()) {} // expected-warning {{expression result unused}} + if (T{f()}, g, h; f()) {} // expected-warning 2{{unused}} expected-warning {{expression result unused}} + if (T(f()), g, h + 1; f()) {} // expected-warning 2{{unused}} expected-warning {{expression result unused}} // condition declarations if (T(n){g}) {} @@ -35,7 +35,7 @@ int f() { // Likewise for 'switch' switch (int n; n) {} - switch (g; int g = 5) {} + switch (g; int g = 5) {} // expected-warning {{expression result unused}} if (int a, b; int c = a) { // expected-note 6{{previous}} int a; // expected-error {{redefinition}} diff --git a/test/Parser/cxx2a-init-statement.cpp b/test/Parser/cxx2a-init-statement.cpp new file mode 100644 index 0000000000000..3b1862f1d3c5e --- /dev/null +++ b/test/Parser/cxx2a-init-statement.cpp @@ -0,0 +1,34 @@ +// RUN: %clang_cc1 -std=c++2a -verify %s + +template<int N> struct A {}; + +using F = bool(*)(int); +extern F *p; +extern int m; + +struct Convertible { template<typename T> operator T(); }; + +void f() { + int arr1[3]; + for (int n = 5; int x : arr1) {} + + int A<0>::*arr2[3]; + for (int n = 5; int A<true ? 0 : 1>::*x : arr2) {} + + F (*arr3[3])(int); + for (int n = 5; F (*p)(int n) : arr3) {} + for (int n = 5; F (*p)(int (n)) : arr3) {} + + // Here, we have a declaration rather than an expression. + for (int n = 5; F (*p)(int (n)); ++n) {} + + // We detect whether we have a for-range-declaration before parsing so that + // we can give different diagnostics for for-range-declarations versus + // conditions (even though the rules are currently identical). + Convertible arr4[3]; + for (int n = 0; struct { operator bool(); } x = {}; ++n) {} // expected-error {{cannot be defined in a condition}} + for (int n = 0; struct { operator bool(); } x : arr4) {} // expected-error {{may not be defined in a for range declaration}} + + for (int n = 0; static int m = 0; ++n) {} // expected-error {{type name does not allow storage class}} + for (int n = 0; static int m : arr1) {} // expected-error {{loop variable 'm' may not be declared 'static'}} +} diff --git a/test/Parser/cxx2a-inline-nested-namespace-definition.cpp b/test/Parser/cxx2a-inline-nested-namespace-definition.cpp new file mode 100644 index 0000000000000..660287c83fcab --- /dev/null +++ b/test/Parser/cxx2a-inline-nested-namespace-definition.cpp @@ -0,0 +1,51 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14 +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++17 +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++2a -Wc++17-compat + +namespace inline foo1::foo2::foo3 { // expected-error {{expected identifier or '{'}} expected-error {{use of undeclared identifier 'foo1'}} +} + +inline namespace foo4::foo5::foo6 { // expected-error {{nested namespace definition cannot be 'inline'}}} +} + +#if __cplusplus <= 201402L +// expected-warning@+7 {{nested namespace definition is a C++17 extension; define each namespace separately}} +// expected-warning@+6 {{inline nested namespace definition is a C++2a extension}} +#elif __cplusplus <= 201703L +// expected-warning@+4 {{inline nested namespace definition is a C++2a extension}} +#else +// expected-warning@+2 {{inline nested namespace definition is incompatible with C++ standards before C++2a}} +#endif +namespace valid1::valid2::inline valid3::inline valid4::valid5 {} +// expected-note@-1 2 {{previous definition is here}} + +#if __cplusplus <= 201402L +// expected-warning@+3 {{nested namespace definition is a C++17 extension; define each namespace separately}} +#endif +//expected-warning@+1 2 {{inline namespace reopened as a non-inline namespace}} +namespace valid1::valid2::valid3::valid4::valid5 {} + +#if __cplusplus <= 201402L +// expected-warning@+7 {{nested namespace definition is a C++17 extension; define each namespace separately}} +// expected-warning@+6 {{inline nested namespace definition is a C++2a extension}} +#elif __cplusplus <= 201703L +// expected-warning@+4 {{inline nested namespace definition is a C++2a extension}} +#else +// expected-warning@+2 {{inline nested namespace definition is incompatible with C++ standards before C++2a}} +#endif +namespace valid1::valid2::inline valid3::inline valid4::valid5 {} +// expected-note@-1 2 {{previous definition is here}} + +namespace valid1 { +namespace valid2 { +//expected-warning@+1 {{inline namespace reopened as a non-inline namespace}} +namespace valid3 { +//expected-warning@+1 {{inline namespace reopened as a non-inline namespace}} +namespace valid4 { +namespace valid5 { +} +} // namespace valid4 +} // namespace valid3 +} // namespace valid2 +} // namespace valid1 + diff --git a/test/Parser/extra-semi-resulting-in-nullstmt-in-init-statement.cpp b/test/Parser/extra-semi-resulting-in-nullstmt-in-init-statement.cpp new file mode 100644 index 0000000000000..7737eb02947f2 --- /dev/null +++ b/test/Parser/extra-semi-resulting-in-nullstmt-in-init-statement.cpp @@ -0,0 +1,64 @@ +// RUN: %clang_cc1 -fsyntax-only -Wextra -std=c++2a -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wextra-semi-stmt -std=c++2a -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wempty-init-stmt -std=c++2a -verify %s +// RUN: cp %s %t +// RUN: %clang_cc1 -x c++ -Wempty-init-stmt -std=c++2a -fixit %t +// RUN: %clang_cc1 -x c++ -Wempty-init-stmt -std=c++2a -Werror %t + +struct S { + int *begin(); + int *end(); +}; + +void naive(int x) { + if (; true) // expected-warning {{empty initialization statement of 'if' has no effect}} + ; + + switch (; x) { // expected-warning {{empty initialization statement of 'switch' has no effect}} + } + + for (; int y : S()) // expected-warning {{empty initialization statement of 'range-based for' has no effect}} + ; + + for (;;) // OK + ; +} + +#define NULLMACRO + +void with_null_macro(int x) { + if (NULLMACRO; true) + ; + + switch (NULLMACRO; x) { + } + + for (NULLMACRO; int y : S()) + ; +} + +#define SEMIMACRO ; + +void with_semi_macro(int x) { + if (SEMIMACRO true) + ; + + switch (SEMIMACRO x) { + } + + for (SEMIMACRO int y : S()) + ; +} + +#define PASSTHROUGHMACRO(x) x + +void with_passthrough_macro(int x) { + if (PASSTHROUGHMACRO(;) true) + ; + + switch (PASSTHROUGHMACRO(;) x) { + } + + for (PASSTHROUGHMACRO(;) int y : S()) + ; +} diff --git a/test/Parser/extra-semi-resulting-in-nullstmt.cpp b/test/Parser/extra-semi-resulting-in-nullstmt.cpp new file mode 100644 index 0000000000000..a09d942c58920 --- /dev/null +++ b/test/Parser/extra-semi-resulting-in-nullstmt.cpp @@ -0,0 +1,96 @@ +// RUN: %clang_cc1 -fsyntax-only -Wextra-semi-stmt -verify %s +// RUN: cp %s %t +// RUN: %clang_cc1 -x c++ -Wextra-semi-stmt -fixit %t +// RUN: %clang_cc1 -x c++ -Wextra-semi-stmt -Werror %t + +#define GOODMACRO(varname) int varname +#define BETTERMACRO(varname) GOODMACRO(varname); +#define NULLMACRO(varname) + +enum MyEnum { + E1, + E2 +}; + +void test() { + ; // expected-warning {{empty expression statement has no effect; remove unnecessary ';' to silence this warning}} + ; + + // This removal of extra semi also consumes all the comments. + // clang-format: off + ;;; + // clang-format: on + + // clang-format: off + ;NULLMACRO(ZZ); + // clang-format: on + + {}; // expected-warning {{empty expression statement has no effect; remove unnecessary ';' to silence this warning}} + + { + ; // expected-warning {{empty expression statement has no effect; remove unnecessary ';' to silence this warning}} + } + + if (true) { + ; // expected-warning {{empty expression statement has no effect; remove unnecessary ';' to silence this warning}} + } + + GOODMACRO(v0); // OK + + GOODMACRO(v1;) // OK + + BETTERMACRO(v2) // OK + + BETTERMACRO(v3;) // Extra ';', but within macro expansion, so ignored. + + BETTERMACRO(v4); // expected-warning {{empty expression statement has no effect; remove unnecessary ';' to silence this warning}} + + BETTERMACRO(v5;); // expected-warning {{empty expression statement has no effect; remove unnecessary ';' to silence this warning}} + + NULLMACRO(v6) // OK + + NULLMACRO(v7); // OK. This could be either GOODMACRO() or BETTERMACRO() situation, so we can't know we can drop it. + + if (true) + ; // OK + + while (true) + ; // OK + + do + ; // OK + while (true); + + for (;;) // OK + ; // OK + + MyEnum my_enum; + switch (my_enum) { + case E1: + // stuff + break; + case E2:; // OK + } + + for (;;) { + for (;;) { + goto contin_outer; + } + contin_outer:; // OK + } +} + +; + +namespace NS {}; + +void foo(int x) { + switch (x) { + case 0: + [[fallthrough]]; + case 1: + return; + } +} + +[[]]; diff --git a/test/Parser/message-expr-alt-op.mm b/test/Parser/message-expr-alt-op.mm new file mode 100644 index 0000000000000..4fbea5753709a --- /dev/null +++ b/test/Parser/message-expr-alt-op.mm @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +@interface WeirdInterface +-(void)allOfThem:(int)a + and:(int)b + and_eq:(int)c + bitand:(int)d + bitor:(int)e + compl:(int)f + not:(int)g + not_eq:(int)h + or:(int)i + or_eq:(int)j + xor:(int)k + xor_eq:(int)l; + +-(void)justAnd:(int)x and:(int)y; +-(void)and; +-(void)and:(int)x; +@end + +void call_it(WeirdInterface *x) { + [x allOfThem:0 + and:0 + and_eq:0 + bitand:0 + bitor:0 + compl:0 + not:0 + not_eq:0 + or:0 + or_eq:0 + xor:0 + xor_eq:0]; + + [x and]; + [x and:0]; + [x &&:0]; // expected-error{{expected expression}}; + [x justAnd:0 and:1]; + [x and: 0 ? : 1]; +} diff --git a/test/Parser/objc-cxx-keyword-identifiers.mm b/test/Parser/objc-cxx-keyword-identifiers.mm index 6791f0d3732a2..cff38c5543713 100644 --- a/test/Parser/objc-cxx-keyword-identifiers.mm +++ b/test/Parser/objc-cxx-keyword-identifiers.mm @@ -18,7 +18,9 @@ struct S { @protocol new // expected-error {{expected identifier; 'new' is a keyword in Objective-C++}} @end -@protocol P2, delete; // expected-error {{expected identifier; 'delete' is a keyword in Objective-C++}} +@protocol P2; +@protocol delete // expected-error {{expected identifier; 'delete' is a keyword in Objective-C++}} +@end @class Foo, try; // expected-error {{expected identifier; 'try' is a keyword in Objective-C++}} diff --git a/test/Parser/objc-default-ctor-init.mm b/test/Parser/objc-default-ctor-init.mm deleted file mode 100644 index a14a243a31cca..0000000000000 --- a/test/Parser/objc-default-ctor-init.mm +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10 -std=c++11 -ast-dump %s | FileCheck %s
-// CHECK: CXXCtorInitializer Field {{.*}} 'ptr' 'void *'
-// CHECK: CXXCtorInitializer Field {{.*}} 'q' 'Q'
-
-@interface NSObject
-@end
-
-@interface I : NSObject
-@end
-
-struct Q { Q(); };
-
-struct S {
- S();
- void *ptr = nullptr;
- Q q;
-};
-
-@implementation I
-S::S() {}
-@end
diff --git a/test/Parser/pragma-attribute.cpp b/test/Parser/pragma-attribute.cpp index f0ebca2c5313b..4e860b6d5833c 100644 --- a/test/Parser/pragma-attribute.cpp +++ b/test/Parser/pragma-attribute.cpp @@ -100,11 +100,12 @@ void function(); #pragma clang attribute push(__attribute__((annotate("test"))), apply_to = any( variable(unless(is_parameter)), variable(unless(is_parameter)) )) // expected-error {{duplicate attribute subject matcher 'variable(unless(is_parameter))'}} #pragma clang attribute push(__attribute__((annotate("test"))), apply_to = any( variable(unless(is_parameter)), variable(unless(is_parameter)), enum, variable(unless(is_parameter)) )) // expected-error 2 {{duplicate attribute subject matcher 'variable(unless(is_parameter))'}} -#pragma clang attribute // expected-error {{expected 'push' or 'pop' after '#pragma clang attribute'}} -#pragma clang attribute 42 // expected-error {{expected 'push' or 'pop' after '#pragma clang attribute'}} -#pragma clang attribute pushpop // expected-error {{unexpected argument 'pushpop' to '#pragma clang attribute'; expected 'push' or 'pop'}} +#pragma clang attribute // expected-error {{expected 'push', 'pop', or '(' after '#pragma clang attribute'}} +#pragma clang attribute 42 // expected-error {{expected 'push', 'pop', or '(' after '#pragma clang attribute'}} +#pragma clang attribute pushpop // expected-error {{expected '.' after pragma attribute namespace 'pushpop'}} -#pragma clang attribute push // expected-error {{expected '('}} +#pragma clang attribute push +#pragma clang attribute pop #pragma clang attribute push ( // expected-error {{expected an attribute after '('}} #pragma clang attribute push (__attribute__((annotate)) // expected-error {{expected ')'}} #pragma clang attribute push () // expected-error {{expected an attribute after '('}} @@ -123,7 +124,9 @@ void function(); #pragma clang attribute push (__attribute__((annotate)), apply_to=function foo) // expected-error {{extra tokens after attribute in a '#pragma clang attribute push'}} #pragma clang attribute push (__attribute__((objc_bridge_related)), apply_to=function) -// expected-error@-1 {{attribute 'objc_bridge_related' is not supported by '#pragma clang attribute'}} +// expected-error@-1 {{attribute 'objc_bridge_related' can't be applied to 'function'}} +#pragma clang attribute pop + #pragma clang attribute push (__attribute__((objc_bridge_related(1))), apply_to=function) // expected-error {{expected a related ObjectiveC class name, e.g., 'NSColor'}} #pragma clang attribute push (__attribute__((used)), apply_to=function) // expected-error {{attribute 'used' is not supported by '#pragma clang attribute'}} diff --git a/test/Parser/pragma-loop-safety.cpp b/test/Parser/pragma-loop-safety.cpp index ab87dcdcb63e6..1393cf7474986 100644 --- a/test/Parser/pragma-loop-safety.cpp +++ b/test/Parser/pragma-loop-safety.cpp @@ -25,10 +25,10 @@ void test(int *List, int Length) { List[i] = i; } -/* expected-error {{duplicate directives 'vectorize(assume_safety)' and 'vectorize(enable)'}} */ #pragma clang loop vectorize(enable) -#pragma clang loop vectorize(assume_safety) -/* expected-error {{duplicate directives 'interleave(assume_safety)' and 'interleave(enable)'}} */ #pragma clang loop interleave(enable) -#pragma clang loop interleave(assume_safety) +#pragma clang loop vectorize(enable) +/* expected-error {{duplicate directives 'vectorize(enable)' and 'vectorize(assume_safety)'}} */ #pragma clang loop vectorize(assume_safety) +#pragma clang loop interleave(enable) +/* expected-error {{duplicate directives 'interleave(enable)' and 'interleave(assume_safety)'}} */ #pragma clang loop interleave(assume_safety) while (i-9 < Length) { List[i] = i; } diff --git a/test/Parser/pragma-loop.cpp b/test/Parser/pragma-loop.cpp index f42d196ce8bd3..be765170f85b8 100644 --- a/test/Parser/pragma-loop.cpp +++ b/test/Parser/pragma-loop.cpp @@ -147,7 +147,7 @@ void test(int *List, int Length) { /* expected-error {{missing argument; expected 'enable', 'full' or 'disable'}} */ #pragma clang loop unroll() /* expected-error {{missing argument; expected 'enable' or 'disable'}} */ #pragma clang loop distribute() -/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, or distribute}} */ #pragma clang loop +/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, or distribute}} */ #pragma clang loop /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword(enable) /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop vectorize(enable) badkeyword(4) @@ -231,51 +231,50 @@ const int VV = 4; // of the next three tests rather than the last, and the order of the kinds // is also reversed. -/* expected-error {{incompatible directives 'vectorize(disable)' and 'vectorize_width(4)'}} */ #pragma clang loop vectorize_width(4) -#pragma clang loop vectorize(disable) -/* expected-error {{incompatible directives 'interleave(disable)' and 'interleave_count(4)'}} */ #pragma clang loop interleave_count(4) -#pragma clang loop interleave(disable) -/* expected-error {{incompatible directives 'unroll(disable)' and 'unroll_count(4)'}} */ #pragma clang loop unroll_count(4) -#pragma clang loop unroll(disable) +#pragma clang loop vectorize_width(4) +/* expected-error {{incompatible directives 'vectorize(disable)' and 'vectorize_width(4)'}} */ #pragma clang loop vectorize(disable) +#pragma clang loop interleave_count(4) +/* expected-error {{incompatible directives 'interleave(disable)' and 'interleave_count(4)'}} */ #pragma clang loop interleave(disable) +#pragma clang loop unroll_count(4) +/* expected-error {{incompatible directives 'unroll(disable)' and 'unroll_count(4)'}} */ #pragma clang loop unroll(disable) while (i-8 < Length) { List[i] = i; } -/* expected-error {{duplicate directives 'vectorize(disable)' and 'vectorize(enable)'}} */ #pragma clang loop vectorize(enable) -#pragma clang loop vectorize(disable) -/* expected-error {{duplicate directives 'interleave(disable)' and 'interleave(enable)'}} */ #pragma clang loop interleave(enable) -#pragma clang loop interleave(disable) -/* expected-error {{duplicate directives 'unroll(disable)' and 'unroll(full)'}} */ #pragma clang loop unroll(full) -#pragma clang loop unroll(disable) -/* expected-error {{duplicate directives 'distribute(disable)' and 'distribute(enable)'}} */ #pragma clang loop distribute(enable) -#pragma clang loop distribute(disable) +#pragma clang loop vectorize(enable) +/* expected-error {{duplicate directives 'vectorize(enable)' and 'vectorize(disable)'}} */ #pragma clang loop vectorize(disable) +#pragma clang loop interleave(enable) +/* expected-error {{duplicate directives 'interleave(enable)' and 'interleave(disable)'}} */ #pragma clang loop interleave(disable) +#pragma clang loop unroll(full) +/* expected-error {{duplicate directives 'unroll(full)' and 'unroll(disable)'}} */ #pragma clang loop unroll(disable) +#pragma clang loop distribute(enable) +/* expected-error {{duplicate directives 'distribute(enable)' and 'distribute(disable)'}} */ #pragma clang loop distribute(disable) while (i-9 < Length) { List[i] = i; } -/* expected-error {{incompatible directives 'vectorize(disable)' and 'vectorize_width(4)'}} */ #pragma clang loop vectorize(disable) -#pragma clang loop vectorize_width(4) -/* expected-error {{incompatible directives 'interleave(disable)' and 'interleave_count(4)'}} */ #pragma clang loop interleave(disable) -#pragma clang loop interleave_count(4) -/* expected-error {{incompatible directives 'unroll(disable)' and 'unroll_count(4)'}} */ #pragma clang loop unroll(disable) -#pragma clang loop unroll_count(4) +#pragma clang loop vectorize(disable) +/* expected-error {{incompatible directives 'vectorize(disable)' and 'vectorize_width(4)'}} */ #pragma clang loop vectorize_width(4) +#pragma clang loop interleave(disable) +/* expected-error {{incompatible directives 'interleave(disable)' and 'interleave_count(4)'}} */ #pragma clang loop interleave_count(4) +#pragma clang loop unroll(disable) +/* expected-error {{incompatible directives 'unroll(disable)' and 'unroll_count(4)'}} */ #pragma clang loop unroll_count(4) while (i-10 < Length) { List[i] = i; } -/* expected-error {{duplicate directives 'vectorize_width(4)' and 'vectorize_width(8)'}} */ #pragma clang loop vectorize_width(8) -#pragma clang loop vectorize_width(4) -/* expected-error {{duplicate directives 'interleave_count(4)' and 'interleave_count(8)'}} */ #pragma clang loop interleave_count(8) -#pragma clang loop interleave_count(4) -/* expected-error {{duplicate directives 'unroll_count(4)' and 'unroll_count(8)'}} */ #pragma clang loop unroll_count(8) -#pragma clang loop unroll_count(4) +#pragma clang loop vectorize_width(8) +/* expected-error {{duplicate directives 'vectorize_width(8)' and 'vectorize_width(4)'}} */ #pragma clang loop vectorize_width(4) +#pragma clang loop interleave_count(8) +/* expected-error {{duplicate directives 'interleave_count(8)' and 'interleave_count(4)'}} */ #pragma clang loop interleave_count(4) +#pragma clang loop unroll_count(8) +/* expected-error {{duplicate directives 'unroll_count(8)' and 'unroll_count(4)'}} */ #pragma clang loop unroll_count(4) while (i-11 < Length) { List[i] = i; } - -/* expected-error {{incompatible directives 'unroll(full)' and 'unroll_count(4)'}} */ #pragma clang loop unroll(full) -#pragma clang loop unroll_count(4) +#pragma clang loop unroll(full) +/* expected-error {{incompatible directives 'unroll(full)' and 'unroll_count(4)'}} */ #pragma clang loop unroll_count(4) while (i-11 < Length) { List[i] = i; } diff --git a/test/Parser/pragma-pipeline.cpp b/test/Parser/pragma-pipeline.cpp new file mode 100644 index 0000000000000..e500d4d2d5fb2 --- /dev/null +++ b/test/Parser/pragma-pipeline.cpp @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -std=c++11 -verify %s + +// Note that this puts the expected lines before the directives to work around +// limitations in the -verify mode. + +void test(int *List, int Length, int Value) { + int i = 0; + +#pragma clang loop pipeline(disable) + for (int i = 0; i < Length; i++) { + List[i] = Value; + } + +#pragma clang loop pipeline_initiation_interval(10) + for (int i = 0; i < Length; i++) { + List[i] = Value; + } + +/* expected-error {{expected ')'}} */ #pragma clang loop pipeline(disable +/* expected-error {{invalid argument; expected 'disable'}} */ #pragma clang loop pipeline(enable) +/* expected-error {{invalid argument; expected 'disable'}} */ #pragma clang loop pipeline(error) +/* expected-error {{expected '('}} */ #pragma clang loop pipeline disable +/* expected-error {{missing argument; expected an integer value}} */ #pragma clang loop pipeline_initiation_interval() +/* expected-error {{use of undeclared identifier 'error'}} */ #pragma clang loop pipeline_initiation_interval(error) +/* expected-error {{expected '('}} */ #pragma clang loop pipeline_initiation_interval 1 2 +/* expected-error {{expected ')'}} */ #pragma clang loop pipeline_initiation_interval(1 + for (int i = 0; i < Length; i++) { + for (int j = 0; j < Length; j++) { + List[i * Length + j] = Value; + } + } + +} diff --git a/test/Parser/pragma-unroll-and-jam.cpp b/test/Parser/pragma-unroll-and-jam.cpp new file mode 100644 index 0000000000000..ef1867aa19556 --- /dev/null +++ b/test/Parser/pragma-unroll-and-jam.cpp @@ -0,0 +1,78 @@ +// RUN: %clang_cc1 -std=c++11 -verify %s + +// Note that this puts the expected lines before the directives to work around +// limitations in the -verify mode. + +void test(int *List, int Length, int Value) { + int i = 0; + +#pragma unroll_and_jam + for (int i = 0; i < Length; i++) { + for (int j = 0; j < Length; j++) { + List[i * Length + j] = Value; + } + } + +#pragma nounroll_and_jam + for (int i = 0; i < Length; i++) { + for (int j = 0; j < Length; j++) { + List[i * Length + j] = Value; + } + } + +#pragma unroll_and_jam 4 + for (int i = 0; i < Length; i++) { + for (int j = 0; j < Length; j++) { + List[i * Length + j] = Value; + } + } + +/* expected-error {{expected ')'}} */ #pragma unroll_and_jam(4 +/* expected-error {{missing argument; expected an integer value}} */ #pragma unroll_and_jam() +/* expected-warning {{extra tokens at end of '#pragma unroll_and_jam'}} */ #pragma unroll_and_jam 1 2 + for (int i = 0; i < Length; i++) { + for (int j = 0; j < Length; j++) { + List[i * Length + j] = Value; + } + } + +/* expected-warning {{extra tokens at end of '#pragma nounroll_and_jam'}} */ #pragma nounroll_and_jam 1 + for (int i = 0; i < Length; i++) { + for (int j = 0; j < Length; j++) { + List[i * Length + j] = Value; + } + } + +#pragma unroll_and_jam +/* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll_and_jam'}} */ int j = Length; +#pragma unroll_and_jam 4 +/* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll_and_jam'}} */ int k = Length; +#pragma nounroll_and_jam +/* expected-error {{expected a for, while, or do-while loop to follow '#pragma nounroll_and_jam'}} */ int l = Length; + +#pragma unroll_and_jam 4 +/* expected-error {{incompatible directives '#pragma nounroll_and_jam' and '#pragma unroll_and_jam(4)'}} */ #pragma nounroll_and_jam + for (int i = 0; i < Length; i++) { + for (int j = 0; j < Length; j++) { + List[i * Length + j] = Value; + } + } + +#pragma nounroll_and_jam +#pragma unroll(4) + for (int i = 0; i < Length; i++) { + for (int j = 0; j < Length; j++) { + List[i * Length + j] = Value; + } + } + +// pragma clang unroll_and_jam is disabled for the moment +/* expected-error {{invalid option 'unroll_and_jam'; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, or distribute}} */ #pragma clang loop unroll_and_jam(4) + for (int i = 0; i < Length; i++) { + for (int j = 0; j < Length; j++) { + List[i * Length + j] = Value; + } + } + +#pragma unroll_and_jam +/* expected-error {{expected statement}} */ } diff --git a/test/Parser/pragma-unroll.cpp b/test/Parser/pragma-unroll.cpp index b1d7798798317..fb713812877e2 100644 --- a/test/Parser/pragma-unroll.cpp +++ b/test/Parser/pragma-unroll.cpp @@ -55,56 +55,56 @@ void test(int *List, int Length) { #pragma nounroll /* expected-error {{expected a for, while, or do-while loop to follow '#pragma nounroll'}} */ int l = Length; -/* expected-error {{incompatible directives 'unroll(disable)' and '#pragma unroll(4)'}} */ #pragma unroll 4 -#pragma clang loop unroll(disable) +#pragma unroll 4 +/* expected-error {{incompatible directives 'unroll(disable)' and '#pragma unroll(4)'}} */ #pragma clang loop unroll(disable) while (i-10 < Length) { List[i] = i; } -/* expected-error {{incompatible directives 'unroll(full)' and '#pragma unroll(4)'}} */ #pragma unroll(4) -#pragma clang loop unroll(full) +#pragma unroll(4) +/* expected-error {{incompatible directives 'unroll(full)' and '#pragma unroll(4)'}} */ #pragma clang loop unroll(full) while (i-11 < Length) { List[i] = i; } -/* expected-error {{incompatible directives 'unroll(enable)' and '#pragma unroll(4)'}} */ #pragma unroll(4) -#pragma clang loop unroll(enable) +#pragma unroll(4) +/* expected-error {{incompatible directives 'unroll(enable)' and '#pragma unroll(4)'}} */ #pragma clang loop unroll(enable) while (i-11 < Length) { List[i] = i; } -/* expected-error {{incompatible directives '#pragma unroll' and '#pragma unroll(4)'}} */ #pragma unroll(4) -#pragma unroll +#pragma unroll(4) +/* expected-error {{incompatible directives '#pragma unroll' and '#pragma unroll(4)'}} */ #pragma unroll while (i-11 < Length) { List[i] = i; } -/* expected-error {{incompatible directives '#pragma nounroll' and 'unroll_count(4)'}} */ #pragma clang loop unroll_count(4) -#pragma nounroll +#pragma clang loop unroll_count(4) +/* expected-error {{incompatible directives '#pragma nounroll' and 'unroll_count(4)'}} */ #pragma nounroll while (i-12 < Length) { List[i] = i; } -/* expected-error {{duplicate directives '#pragma nounroll' and '#pragma nounroll'}} */ #pragma nounroll #pragma nounroll +/* expected-error {{duplicate directives '#pragma nounroll' and '#pragma nounroll'}} */ #pragma nounroll while (i-13 < Length) { List[i] = i; } -/* expected-error {{duplicate directives '#pragma unroll' and '#pragma unroll'}} */ #pragma unroll #pragma unroll +/* expected-error {{duplicate directives '#pragma unroll' and '#pragma unroll'}} */ #pragma unroll while (i-14 < Length) { List[i] = i; } -/* expected-error {{duplicate directives 'unroll(full)' and '#pragma unroll'}} */ #pragma unroll -#pragma clang loop unroll(full) +#pragma unroll +/* expected-error {{duplicate directives '#pragma unroll' and 'unroll(full)'}} */ #pragma clang loop unroll(full) while (i-15 < Length) { List[i] = i; } -/* expected-error {{duplicate directives '#pragma unroll(4)' and '#pragma unroll(4)'}} */ #pragma unroll 4 -#pragma unroll(4) +#pragma unroll 4 +/* expected-error {{duplicate directives '#pragma unroll(4)' and '#pragma unroll(4)'}} */ #pragma unroll(4) while (i-16 < Length) { List[i] = i; } diff --git a/test/Parser/switch-recovery.cpp b/test/Parser/switch-recovery.cpp index a3a0178cd10b6..eacd017ab2364 100644 --- a/test/Parser/switch-recovery.cpp +++ b/test/Parser/switch-recovery.cpp @@ -105,7 +105,7 @@ void test9(int x) { // expected-note {{'x' declared here}} expected-error {{expected expression}} 8:: x; // expected-error {{expected ';' after expression}} \ expected-error {{no member named 'x' in the global namespace; did you mean simply 'x'?}} \ - expected-warning 2 {{expression result unused}} + expected-warning {{expression result unused}} 9:: :y; // expected-error {{expected ';' after expression}} \ expected-error {{expected unqualified-id}} \ expected-warning {{expression result unused}} |