blob: e22eb8150af657dfab365fd8fb9b7398b6842013 [file] [log] [blame]
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00001// RUN: %clang_cc1 -verify -fopenmp %s
2
3void foo() {
4}
5
6bool foobool(int argc) {
7 return argc;
8}
9
10struct S1; // expected-note {{declared here}}
11
12template <class T, class S> // expected-note {{declared here}}
13int tmain(T argc, S **argv) {
14 #pragma omp target parallel if // expected-error {{expected '(' after 'if'}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000015 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000016 #pragma omp target parallel if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000017 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000018 #pragma omp target parallel if () // expected-error {{expected expression}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000019 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000020 #pragma omp target parallel if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000021 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000022 #pragma omp target parallel if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000023 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000024 #pragma omp target parallel if (argc > 0 ? argv[1] : argv[2])
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000025 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000026 #pragma omp target parallel if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000027 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000028 #pragma omp target parallel if (S) // expected-error {{'S' does not refer to a value}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000029 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000030 #pragma omp target parallel if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000031 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000032 #pragma omp target parallel if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000033 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000034 #pragma omp target parallel if(argc)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000035 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000036 #pragma omp target parallel if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000037 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000038 #pragma omp target parallel if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000039 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000040 #pragma omp target parallel if(target : argc)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000041 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000042 #pragma omp target parallel if(parallel : argc)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000043 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000044 #pragma omp target parallel if(target : argc) if(parallel : argc)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000045 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000046 #pragma omp target parallel if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target parallel'}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000047 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000048 #pragma omp target parallel if(target : argc) if (target :argc) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause with 'target' name modifier}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000049 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000050 #pragma omp target parallel if(parallel : argc) if (parallel :argc) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause with 'parallel' name modifier}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000051 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000052 #pragma omp target parallel if(target : argc) if (argc) // expected-error {{expected 'parallel' directive name modifier}} expected-note {{previous clause with directive name modifier specified here}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000053 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000054 #pragma omp target parallel if(target : argc) if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}} expected-note {{previous clause with directive name modifier specified here}}
55 foo();
56
57 return 0;
58}
59
60int main(int argc, char **argv) {
61 #pragma omp target parallel if // expected-error {{expected '(' after 'if'}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000062 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000063 #pragma omp target parallel if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000064 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000065 #pragma omp target parallel if () // expected-error {{expected expression}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000066 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000067 #pragma omp target parallel if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000068 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000069 #pragma omp target parallel if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000070 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000071 #pragma omp target parallel if (argc > 0 ? argv[1] : argv[2])
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000072 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000073 #pragma omp target parallel if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000074 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000075 #pragma omp target parallel if (S1) // expected-error {{'S1' does not refer to a value}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000076 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000077 #pragma omp target parallel if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000078 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000079 #pragma omp target parallel if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000080 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000081 #pragma omp target parallel if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000082 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000083 #pragma omp target parallel if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000084 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000085 #pragma omp target parallel if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000086 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000087 #pragma omp target parallel if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000088 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000089 #pragma omp target parallel if(parallel : argc)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000090 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000091 #pragma omp target parallel if(target : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target parallel'}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000092 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000093 #pragma omp target parallel if(target : argc) if (target :argc) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause with 'target' name modifier}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000094 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000095 #pragma omp target parallel if(parallel : argc) if (parallel :argc) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause with 'parallel' name modifier}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000096 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000097 #pragma omp target parallel if(target : argc) if (argc) // expected-error {{expected 'parallel' directive name modifier}} expected-note {{previous clause with directive name modifier specified here}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000098 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000099 #pragma omp target parallel if(target : argc) if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}} expected-note {{previous clause with directive name modifier specified here}}
100 foo();
101
102 return tmain(argc, argv);
103}