Home | History | Annotate | Download | only in OpenMP
      1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
      2 
      3 void foo() {
      4 }
      5 
      6 bool foobool(int argc) {
      7   return argc;
      8 }
      9 
     10 struct S1; // expected-note {{declared here}}
     11 
     12 template <class T, typename S, int N> // expected-note {{declared here}}
     13 T tmain(T argc, S **argv) {
     14   T i;
     15 #pragma omp target
     16 #pragma omp teams
     17 #pragma omp distribute parallel for num_threads // expected-error {{expected '(' after 'num_threads'}}
     18   for (i = 0; i < argc; ++i) foo();
     19 #pragma omp target
     20 #pragma omp teams
     21 #pragma omp distribute parallel for num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     22   for (i = 0; i < argc; ++i) foo();
     23 #pragma omp target
     24 #pragma omp teams
     25 #pragma omp distribute parallel for num_threads () // expected-error {{expected expression}}
     26   for (i = 0; i < argc; ++i) foo();
     27 #pragma omp target
     28 #pragma omp teams
     29 #pragma omp distribute parallel for num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
     30   for (i = 0; i < argc; ++i) foo();
     31 #pragma omp target
     32 #pragma omp teams
     33 #pragma omp distribute parallel for num_threads (argc)) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}
     34   for (i = 0; i < argc; ++i) foo();
     35 #pragma omp target
     36 #pragma omp teams
     37 #pragma omp distribute parallel for num_threads ((argc > 0) ? argv[1] : argv[2]) // expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
     38   for (i = 0; i < argc; ++i) foo();
     39 #pragma omp target
     40 #pragma omp teams
     41 #pragma omp distribute parallel for num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp distribute parallel for' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
     42   for (i = 0; i < argc; ++i) foo();
     43 #pragma omp target
     44 #pragma omp teams
     45 #pragma omp distribute parallel for num_threads (S) // expected-error {{'S' does not refer to a value}}
     46   for (i = 0; i < argc; ++i) foo();
     47 #pragma omp target
     48 #pragma omp teams
     49 #pragma omp distribute parallel for 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 *'}}
     50   for (i = 0; i < argc; ++i) foo();
     51 #pragma omp target
     52 #pragma omp teams
     53 #pragma omp distribute parallel for num_threads (argc)
     54   for (i = 0; i < argc; ++i) foo();
     55 #pragma omp target
     56 #pragma omp teams
     57 #pragma omp distribute parallel for num_threads (N) // expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
     58   for (i = 0; i < argc; ++i) foo();
     59 
     60   return argc;
     61 }
     62 
     63 int main(int argc, char **argv) {
     64   int i;
     65 #pragma omp target
     66 #pragma omp teams
     67 #pragma omp distribute parallel for num_threads // expected-error {{expected '(' after 'num_threads'}}
     68   for (i = 0; i < argc; ++i) foo();
     69 #pragma omp target
     70 #pragma omp teams
     71 #pragma omp distribute parallel for num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     72   for (i = 0; i < argc; ++i) foo();
     73 #pragma omp target
     74 #pragma omp teams
     75 #pragma omp distribute parallel for num_threads () // expected-error {{expected expression}}
     76   for (i = 0; i < argc; ++i) foo();
     77 #pragma omp target
     78 #pragma omp teams
     79 #pragma omp distribute parallel for num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
     80   for (i = 0; i < argc; ++i) foo();
     81 #pragma omp target
     82 #pragma omp teams
     83 #pragma omp distribute parallel for num_threads (argc)) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}
     84   for (i = 0; i < argc; ++i) foo();
     85 #pragma omp target
     86 #pragma omp teams
     87 #pragma omp distribute parallel for num_threads (argc > 0 ? argv[1] : argv[2]) // expected-error {{integral }}
     88   for (i = 0; i < argc; ++i) foo();
     89 #pragma omp target
     90 #pragma omp teams
     91 #pragma omp distribute parallel for num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp distribute parallel for' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
     92   for (i = 0; i < argc; ++i) foo();
     93 #pragma omp target
     94 #pragma omp teams
     95 #pragma omp distribute parallel for num_threads (S1) // expected-error {{'S1' does not refer to a value}}
     96   for (i = 0; i < argc; ++i) foo();
     97 #pragma omp target
     98 #pragma omp teams
     99 #pragma omp distribute parallel for 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 *'}}
    100   for (i = 0; i < argc; ++i) foo();
    101 #pragma omp target
    102 #pragma omp teams
    103 #pragma omp distribute parallel for 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}}
    104   for (i = 0; i < argc; ++i) foo();
    105 
    106   return tmain<int, char, 3>(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<int, char, 3>' requested here}}
    107 }
    108