61 lines · cpp
1// RUN: %clang_cc1 -fopenmp %s -verify2 3int foobar() {4 return 1;5}6 7int main(int argc, char *argv[]) {8 // expected-note@+1 {{declared here}}9 int a;10 // expected-note@+1 {{declared here}}11 int b;12 // expected-note@+1 {{declared here}}13 int c;14 double f;15 int foo2[10];16 17// expected-error@+1 {{expected '(' after 'align'}}18#pragma omp allocate(a) align19// expected-error@+3 {{expected expression}}20// expected-error@+2 {{expected ')'}}21// expected-note@+1 {{to match this '('}}22#pragma omp allocate(a) align(23// expected-error@+1 {{expected expression}}24#pragma omp allocate(a) align()25// expected-error@+4 {{expected ')'}}26// expected-note@+3 {{to match this '('}}27// expected-error@+2 {{expression is not an integral constant expression}}28// expected-note@+1 {{read of non-const variable 'a' is not allowed in a constant expression}}29#pragma omp allocate(a) align(a30// expected-error@+2 {{expression is not an integral constant expression}}31// expected-note@+1 {{read of non-const variable 'b' is not allowed in a constant expression}}32#pragma omp allocate(a) align(b)33// expected-error@+2 {{expression is not an integral constant expression}}34// expected-note@+1 {{read of non-const variable 'c' is not allowed in a constant expression}}35#pragma omp allocate(a) align(c + 1)36// expected-error@+1 {{expected an OpenMP directive}}37#pragma omp align(2) allocate(a)38// expected-error@+1 {{directive '#pragma omp allocate' cannot contain more than one 'align' clause}}39#pragma omp allocate(a) align(2) align(4)40// expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}}41#pragma omp allocate(a) align(9)42// expected-error@+1 {{integral constant expression must have integral or unscoped enumeration type, not 'double'}}43#pragma omp allocate(a) align(f)44}45 46// Verify appropriate errors when using templates.47template <typename T, unsigned size, unsigned align>48T run() {49 T foo[size];50// expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}}51#pragma omp allocate(foo) align(align)52 return foo[0];53}54 55int template_test() {56 double d;57 // expected-note@+1 {{in instantiation of function template specialization 'run<double, 10U, 3U>' requested here}}58 d = run<double, 10, 3>();59 return 0;60}61