tigerleapgorge created this revision. I am continuing to make out Lit tests C++11 compatible. There are two tests in this patch. Both tests verify parse errors with ill formed OpenMP expressions.
test/OpenMP/declare_reduction_messages.cpp In C++11, an opening square bracket is the start of a lambda capture. Therefore, a unmatched opening square bracket will cause the following diagnostics change. C++98: error: expected '(' after 'initializer' error: expected expression warning: extra tokens at the end of '#pragma omp declare reduction' are ignored [-Wextra-tokens] C++11: error: expected '(' after 'initializer' error: expected variable name or 'this' in lambda capture list error: expected ')' note: to match this '(' test/OpenMP/openmp_check.cpp This test is created in response to bug 25221, where C++11 code running under C++98 causes the parser to go into an infinite loop. Since this is C++11 code, all expected diagnostics will go away when compiling at C++11. Therefore, guard all of the following diagnostics under C++98. C++98: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions] error: expected expression error: expected ';' at end of declaration C++98: error: C++ requires a type specifier for all declarations C++98: error: expected unqualified-id C++98: error: extraneous closing brace ('}') https://reviews.llvm.org/D29725 Files: test/OpenMP/declare_reduction_messages.cpp test/OpenMP/openmp_check.cpp Index: test/OpenMP/openmp_check.cpp =================================================================== --- test/OpenMP/openmp_check.cpp +++ test/OpenMP/openmp_check.cpp @@ -1,15 +1,35 @@ // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++98 %s +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 %s + int nested(int a) { #pragma omp parallel ++a; - auto F = [&]() { // expected-error {{expected expression}} expected-error {{expected ';' at end of declaration}} expected-warning {{'auto' type specifier is a C++11 extension}} + auto F = [&]() { +#if __cplusplus <= 199711L + // expected-warning@-2 {{'auto' type specifier is a C++11 extension}} + // expected-error@-3 {{expected expression}} + // expected-error@-4 {{expected ';' at end of declaration}} +#else + // expected-no-diagnostics +#endif + #pragma omp parallel { #pragma omp target ++a; } }; - F(); // expected-error {{C++ requires a type specifier for all declarations}} - return a; // expected-error {{expected unqualified-id}} -}// expected-error {{extraneous closing brace ('}')}} + F(); +#if __cplusplus <= 199711L + // expected-error@-2 {{C++ requires a type specifier for all declarations}} +#endif + return a; +#if __cplusplus <= 199711L + // expected-error@-2 {{expected unqualified-id}} +#endif +} +#if __cplusplus <= 199711L +// expected-error@-2 {{extraneous closing brace ('}')}} +#endif Index: test/OpenMP/declare_reduction_messages.cpp =================================================================== --- test/OpenMP/declare_reduction_messages.cpp +++ test/OpenMP/declare_reduction_messages.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++98 %s +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 %s int temp; // expected-note 7 {{'temp' declared here}} @@ -51,7 +53,17 @@ #pragma omp declare reduction(fun222 : long : omp_out += omp_in) // expected-error {{redefinition of user-defined reduction for type 'long'}} #pragma omp declare reduction(fun1 : long : omp_out += omp_in) initializer // expected-error {{expected '(' after 'initializer'}} #pragma omp declare reduction(fun2 : long : omp_out += omp_in) initializer { // expected-error {{expected '(' after 'initializer'}} expected-error {{expected expression}} expected-warning {{extra tokens at the end of '#pragma omp declare reduction' are ignored}} -#pragma omp declare reduction(fun3 : long : omp_out += omp_in) initializer[ // expected-error {{expected '(' after 'initializer'}} expected-error {{expected expression}} expected-warning {{extra tokens at the end of '#pragma omp declare reduction' are ignored}} +#pragma omp declare reduction(fun3 : long : omp_out += omp_in) initializer[ +#if __cplusplus <= 199711L +// expected-error@-2 {{expected '(' after 'initializer'}} +// expected-error@-3 {{expected expression}} +// expected-warning@-4 {{extra tokens at the end of '#pragma omp declare reduction' are ignored}} +#else +// expected-error@-6 {{expected '(' after 'initializer'}} +// expected-error@-7 {{expected variable name or 'this' in lambda capture list}} +// expected-error@-8 {{expected ')'}} +// expected-note@-9 {{to match this '('}} +#endif #pragma omp declare reduction(fun4 : long : omp_out += omp_in) initializer() // expected-error {{expected expression}} #pragma omp declare reduction(fun5 : long : omp_out += omp_in) initializer(temp) // expected-error {{only 'omp_priv' or 'omp_orig' variables are allowed in initializer expression}} #pragma omp declare reduction(fun6 : long : omp_out += omp_in) initializer(omp_orig // expected-error {{expected ')'}} expected-note {{to match this '('}}
Index: test/OpenMP/openmp_check.cpp =================================================================== --- test/OpenMP/openmp_check.cpp +++ test/OpenMP/openmp_check.cpp @@ -1,15 +1,35 @@ // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++98 %s +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 %s + int nested(int a) { #pragma omp parallel ++a; - auto F = [&]() { // expected-error {{expected expression}} expected-error {{expected ';' at end of declaration}} expected-warning {{'auto' type specifier is a C++11 extension}} + auto F = [&]() { +#if __cplusplus <= 199711L + // expected-warning@-2 {{'auto' type specifier is a C++11 extension}} + // expected-error@-3 {{expected expression}} + // expected-error@-4 {{expected ';' at end of declaration}} +#else + // expected-no-diagnostics +#endif + #pragma omp parallel { #pragma omp target ++a; } }; - F(); // expected-error {{C++ requires a type specifier for all declarations}} - return a; // expected-error {{expected unqualified-id}} -}// expected-error {{extraneous closing brace ('}')}} + F(); +#if __cplusplus <= 199711L + // expected-error@-2 {{C++ requires a type specifier for all declarations}} +#endif + return a; +#if __cplusplus <= 199711L + // expected-error@-2 {{expected unqualified-id}} +#endif +} +#if __cplusplus <= 199711L +// expected-error@-2 {{extraneous closing brace ('}')}} +#endif Index: test/OpenMP/declare_reduction_messages.cpp =================================================================== --- test/OpenMP/declare_reduction_messages.cpp +++ test/OpenMP/declare_reduction_messages.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++98 %s +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 %s int temp; // expected-note 7 {{'temp' declared here}} @@ -51,7 +53,17 @@ #pragma omp declare reduction(fun222 : long : omp_out += omp_in) // expected-error {{redefinition of user-defined reduction for type 'long'}} #pragma omp declare reduction(fun1 : long : omp_out += omp_in) initializer // expected-error {{expected '(' after 'initializer'}} #pragma omp declare reduction(fun2 : long : omp_out += omp_in) initializer { // expected-error {{expected '(' after 'initializer'}} expected-error {{expected expression}} expected-warning {{extra tokens at the end of '#pragma omp declare reduction' are ignored}} -#pragma omp declare reduction(fun3 : long : omp_out += omp_in) initializer[ // expected-error {{expected '(' after 'initializer'}} expected-error {{expected expression}} expected-warning {{extra tokens at the end of '#pragma omp declare reduction' are ignored}} +#pragma omp declare reduction(fun3 : long : omp_out += omp_in) initializer[ +#if __cplusplus <= 199711L +// expected-error@-2 {{expected '(' after 'initializer'}} +// expected-error@-3 {{expected expression}} +// expected-warning@-4 {{extra tokens at the end of '#pragma omp declare reduction' are ignored}} +#else +// expected-error@-6 {{expected '(' after 'initializer'}} +// expected-error@-7 {{expected variable name or 'this' in lambda capture list}} +// expected-error@-8 {{expected ')'}} +// expected-note@-9 {{to match this '('}} +#endif #pragma omp declare reduction(fun4 : long : omp_out += omp_in) initializer() // expected-error {{expected expression}} #pragma omp declare reduction(fun5 : long : omp_out += omp_in) initializer(temp) // expected-error {{only 'omp_priv' or 'omp_orig' variables are allowed in initializer expression}} #pragma omp declare reduction(fun6 : long : omp_out += omp_in) initializer(omp_orig // expected-error {{expected ')'}} expected-note {{to match this '('}}
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits