154 lines · cpp
1// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized2 3// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized4 5// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized6// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized7 8void foo() {9}10 11bool foobool(int argc) {12 return argc;13}14 15void xxx(int argc) {16 int cond; // expected-note {{initialize the variable 'cond' to silence this warning}}17#pragma omp target18#pragma omp teams distribute parallel for if(cond) // expected-warning {{variable 'cond' is uninitialized when used here}}19 for (int i = 0; i < 10; ++i)20 ;21}22 23struct S1; // expected-note {{declared here}}24 25template <class T, class S> // expected-note {{declared here}}26int tmain(T argc, S **argv) {27 T i, z;28#pragma omp target29#pragma omp teams distribute parallel for if // expected-error {{expected '(' after 'if'}}30 for (i = 0; i < argc; ++i) foo();31#pragma omp target32#pragma omp teams distribute parallel for if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}33 for (i = 0; i < argc; ++i) foo();34#pragma omp target35#pragma omp teams distribute parallel for if () // expected-error {{expected expression}}36 for (i = 0; i < argc; ++i) foo();37#pragma omp target38#pragma omp teams distribute parallel for if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}39 for (i = 0; i < argc; ++i) foo();40#pragma omp target41#pragma omp teams distribute parallel for if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}42 for (i = 0; i < argc; ++i) foo();43#pragma omp target44#pragma omp teams distribute parallel for if (argc > 0 ? argv[1] : argv[2])45 for (i = 0; i < argc; ++i) foo();46#pragma omp target47#pragma omp teams distribute parallel for if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'if' clause}}48 for (i = 0; i < argc; ++i) foo();49#pragma omp target50#pragma omp teams distribute parallel for if (S) // expected-error {{'S' does not refer to a value}}51 for (i = 0; i < argc; ++i) foo();52#pragma omp target53#pragma omp teams distribute parallel for if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}54 for (i = 0; i < argc; ++i) foo();55#pragma omp target56#pragma omp teams distribute parallel for if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}57 for (i = 0; i < argc; ++i) foo();58#pragma omp target59#pragma omp teams distribute parallel for if(argc+z)60 for (i = 0; i < argc; ++i) foo();61#pragma omp target62#pragma omp teams distribute parallel for if(parallel // expected-error {{use of undeclared identifier 'parallel'}} expected-error {{expected ')'}} expected-note {{to match this '('}}63 for (i = 0; i < argc; ++i) foo();64#pragma omp target65#pragma omp teams distribute parallel for if(parallel : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}66 for (i = 0; i < argc; ++i) foo();67#pragma omp target68#pragma omp teams distribute parallel for if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}69 for (i = 0; i < argc; ++i) foo();70#pragma omp target71#pragma omp teams distribute parallel for if(parallel : argc)72 for (i = 0; i < argc; ++i) foo();73#pragma omp target74#pragma omp teams distribute parallel for if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp teams distribute parallel for'}}75 for (i = 0; i < argc; ++i) foo();76#pragma omp target77#pragma omp teams distribute parallel for if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'if' clause with 'parallel' name modifier}}78 for (i = 0; i < argc; ++i) foo();79#pragma omp target80#pragma omp teams distribute parallel for if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}81 for (i = 0; i < argc; ++i) foo();82#pragma omp target83#pragma omp teams distribute parallel for if(distribute : argc) // expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp teams distribute parallel for'}}84 for (i = 0; i < argc; ++i) foo();85 86 return 0;87}88 89int main(int argc, char **argv) {90 int i, z;91#pragma omp target92#pragma omp teams distribute parallel for if // expected-error {{expected '(' after 'if'}}93 for (i = 0; i < argc; ++i) foo();94#pragma omp target95#pragma omp teams distribute parallel for if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}96 for (i = 0; i < argc; ++i) foo();97#pragma omp target98#pragma omp teams distribute parallel for if () // expected-error {{expected expression}}99 for (i = 0; i < argc; ++i) foo();100#pragma omp target101#pragma omp teams distribute parallel for if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}102 for (i = 0; i < argc; ++i) foo();103#pragma omp target104#pragma omp teams distribute parallel for if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}105 for (i = 0; i < argc; ++i) foo();106#pragma omp target107#pragma omp teams distribute parallel for if (argc > 0 ? argv[1] : argv[2])108 for (i = 0; i < argc; ++i) foo();109#pragma omp target110#pragma omp teams distribute parallel for if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'if' clause}}111 for (i = 0; i < argc; ++i) foo();112#pragma omp target113#pragma omp teams distribute parallel for if (S1) // expected-error {{'S1' does not refer to a value}}114 for (i = 0; i < argc; ++i) foo();115#pragma omp target116#pragma omp teams distribute parallel for if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}117 for (i = 0; i < argc; ++i) foo();118#pragma omp target119#pragma omp teams distribute parallel for if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}120 for (i = 0; i < argc; ++i) foo();121#pragma omp target122#pragma omp teams distribute parallel for if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}123 for (i = 0; i < argc; ++i) foo();124#pragma omp target125#pragma omp teams distribute parallel for if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}126 for (i = 0; i < argc; ++i) foo();127#pragma omp target128#pragma omp teams distribute parallel for if(parallel // expected-error {{use of undeclared identifier 'parallel'}} expected-error {{expected ')'}} expected-note {{to match this '('}}129 for (i = 0; i < argc; ++i) foo();130#pragma omp target131#pragma omp teams distribute parallel for if(parallel : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}132 for (i = 0; i < argc; ++i) foo();133#pragma omp target134#pragma omp teams distribute parallel for if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}135 for (i = 0; i < argc; ++i) foo();136#pragma omp target137#pragma omp teams distribute parallel for if(parallel : argc + z)138 for (i = 0; i < argc; ++i) foo();139#pragma omp target140#pragma omp teams distribute parallel for if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp teams distribute parallel for'}}141 for (i = 0; i < argc; ++i) foo();142#pragma omp target143#pragma omp teams distribute parallel for if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'if' clause with 'parallel' name modifier}}144 for (i = 0; i < argc; ++i) foo();145#pragma omp target146#pragma omp teams distribute parallel for if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}147 for (i = 0; i < argc; ++i) foo();148#pragma omp target149#pragma omp teams distribute parallel for if(distribute : argc) // expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp teams distribute parallel for'}}150 for (i = 0; i < argc; ++i) foo();151 152 return tmain(argc, argv);153}154