120 lines · cpp
1// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized2// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized3 4// RUN: %clang_cc1 -DOMP60 -verify=expected,omp60 -fopenmp -fopenmp-version=60 -ferror-limit 100 %s -Wuninitialized5// RUN: %clang_cc1 -DOMP60 -verify=expected,omp60 -fopenmp-simd -fopenmp-version=60 -ferror-limit 100 %s -Wuninitialized6 7void foo() {8}9 10bool foobool(int argc) {11 return argc;12}13 14struct S1; // expected-note {{declared here}} omp60-note {{declared here}}15 16#define redef_num_threads(a, b) num_threads(a)17 18template <class T, typename S, int N> // expected-note {{declared here}} omp60-note {{declared here}}19T tmain(T argc, S **argv) {20 T z;21 #pragma omp parallel num_threads // expected-error {{expected '(' after 'num_threads'}}22 #pragma omp parallel num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}23 #pragma omp parallel num_threads () // expected-error {{expected expression}}24 #pragma omp parallel num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}25 #pragma omp parallel num_threads (argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}}26 #pragma omp parallel num_threads ((argc > 0) ? argv[1] : argv[2]) // expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}27 #pragma omp parallel num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp parallel' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}28 #pragma omp parallel num_threads (S) // expected-error {{'S' does not refer to a value}}29 #pragma omp parallel num_threads (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}30 #pragma omp parallel num_threads (argc+z)31 #pragma omp parallel num_threads (N) // expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}32 #pragma omp parallel redef_num_threads (argc, argc)33 34#ifdef OMP6035 // Valid uses of strict modifier36 #pragma omp parallel num_threads(strict: 4)37 #pragma omp parallel num_threads(strict: argc+z)38 39 // Invalid: missing expression after strict:40 #pragma omp parallel num_threads(strict: ) // omp60-error {{expected expression}}41 #pragma omp parallel num_threads(strict:) // omp60-error {{expected expression}}42 #pragma omp parallel num_threads(strict: // omp60-error {{expected expression}} omp60-error {{expected ')'}} omp60-note {{to match this '('}}43 44 // Invalid: unknown/missing modifier45 #pragma omp parallel num_threads(foo: 4) // omp60-error {{expected 'strict' in OpenMP clause 'num_threads'}}46 #pragma omp parallel num_threads(: 4) // omp60-error {{expected expression}} omp60-error {{expected ')'}} omp60-note {{to match this '('}}47 #pragma omp parallel num_threads(:)// omp60-error {{expected expression}} omp60-error {{expected ')'}} omp60-note {{to match this '('}}48 49 // Invalid: missing colon after modifier50 #pragma omp parallel num_threads(strict 4) // omp60-error {{missing ':' after strict modifier}}51 52 // Invalid: negative, zero, or non-integral53 #pragma omp parallel num_threads(strict: -1) // omp60-error {{argument to 'num_threads' clause must be a strictly positive integer value}}54 #pragma omp parallel num_threads(strict: 0) // omp60-error {{argument to 'num_threads' clause must be a strictly positive integer value}}55 #pragma omp parallel num_threads(strict: (argc > 0) ? argv[1] : argv[2]) // omp60-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}56 #pragma omp parallel num_threads(strict: S) // omp60-error {{'S' does not refer to a value}}57 #pragma omp parallel num_threads(strict: argv[1]=2) // omp60-error {{expected ')'}} omp60-note {{to match this '('}} omp60-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}58 #pragma omp parallel num_threads(strict: N) // omp60-error {{argument to 'num_threads' clause must be a strictly positive integer value}}59 60 // Invalid: multiple strict modifiers or mixed with non-strict61 #pragma omp parallel num_threads(strict: 4, strict: 5) // omp60-error {{expected ')'}} expected-note {{to match this '('}}62 #pragma omp parallel num_threads(strict: 4), num_threads(5) // omp60-error {{directive '#pragma omp parallel' cannot contain more than one 'num_threads' clause}}63 #pragma omp parallel num_threads(4), num_threads(strict: 5) // omp60-error {{directive '#pragma omp parallel' cannot contain more than one 'num_threads' clause}}64#endif // OMP6065 66 foo();67 68 return argc;69}70 71int main(int argc, char **argv) {72int z;73 #pragma omp parallel num_threads // expected-error {{expected '(' after 'num_threads'}}74 #pragma omp parallel num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}75 #pragma omp parallel num_threads () // expected-error {{expected expression}}76 #pragma omp parallel num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}77 #pragma omp parallel num_threads (z+argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}}78 #pragma omp parallel num_threads (argc > 0 ? argv[1] : argv[2]) // expected-error {{integral }}79 #pragma omp parallel num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp parallel' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}80 #pragma omp parallel num_threads (S1) // expected-error {{'S1' does not refer to a value}}81 #pragma omp parallel num_threads (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}}82 #pragma omp parallel num_threads (num_threads(tmain<int, char, -1>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} expected-note {{in instantiation of function template specialization 'tmain<int, char, -1>' requested here}}83 #pragma omp parallel redef_num_threads (argc, argc)84 85#ifdef OMP6086 // Valid uses of strict modifier87 #pragma omp parallel num_threads(strict: 4)88 #pragma omp parallel num_threads(strict: argc+z)89 90 // Invalid: missing expression after strict:91 #pragma omp parallel num_threads(strict: ) // omp60-error {{expected expression}}92 #pragma omp parallel num_threads(strict:) // omp60-error {{expected expression}}93 #pragma omp parallel num_threads(strict: // omp60-error {{expected expression}} omp60-error {{expected ')'}} omp60-note {{to match this '('}}94 95 // Invalid: unknown/missing modifier96 #pragma omp parallel num_threads(foo: 4) // omp60-error {{expected 'strict' in OpenMP clause 'num_threads'}}97 #pragma omp parallel num_threads(: 4) // omp60-error {{expected expression}} omp60-error {{expected ')'}} omp60-note {{to match this '('}}98 #pragma omp parallel num_threads(:) // omp60-error {{expected expression}} omp60-error {{expected ')'}} omp60-note {{to match this '('}}99 100 // Invalid: missing colon after modifier101 #pragma omp parallel num_threads(strict 4) // omp60-error {{missing ':' after strict modifier}}102 103 // Invalid: negative, zero, or non-integral104 #pragma omp parallel num_threads(strict: -1) // omp60-error {{argument to 'num_threads' clause must be a strictly positive integer value}}105 #pragma omp parallel num_threads(strict: 0) // omp60-error {{argument to 'num_threads' clause must be a strictly positive integer value}}106 #pragma omp parallel num_threads(strict: (argc > 0) ? argv[1] : argv[2]) // omp60-error {{expression must have integral or unscoped enumeration type, not 'char *'}}107 #pragma omp parallel num_threads(strict: S1) // omp60-error {{'S1' does not refer to a value}}108 #pragma omp parallel num_threads(strict: argv[1]=2) // omp60-error {{expected ')'}} omp60-note {{to match this '('}} omp60-error {{expression must have integral or unscoped enumeration type, not 'char *'}}109 110 // Invalid: multiple strict modifiers or mixed with non-strict111 #pragma omp parallel num_threads(strict: 4, strict: 5) // omp60-error {{expected ')'}} expected-note {{to match this '('}}112 #pragma omp parallel num_threads(strict: 4), num_threads(5) // omp60-error {{directive '#pragma omp parallel' cannot contain more than one 'num_threads' clause}}113 #pragma omp parallel num_threads(4), num_threads(strict: 5) // omp60-error {{directive '#pragma omp parallel' cannot contain more than one 'num_threads' clause}}114#endif // OMP60115 116 foo();117 118 return tmain<int, char, 3>(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<int, char, 3>' requested here}}119}120