xref: /minix3/external/bsd/llvm/dist/clang/test/OpenMP/atomic_messages.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
2*0a6a1f1dSLionel Sambuc 
foo()3*0a6a1f1dSLionel Sambuc int foo() {
4*0a6a1f1dSLionel Sambuc L1:
5*0a6a1f1dSLionel Sambuc   foo();
6*0a6a1f1dSLionel Sambuc #pragma omp atomic
7*0a6a1f1dSLionel Sambuc   // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
8*0a6a1f1dSLionel Sambuc   {
9*0a6a1f1dSLionel Sambuc     foo();
10*0a6a1f1dSLionel Sambuc     goto L1; // expected-error {{use of undeclared label 'L1'}}
11*0a6a1f1dSLionel Sambuc   }
12*0a6a1f1dSLionel Sambuc   goto L2; // expected-error {{use of undeclared label 'L2'}}
13*0a6a1f1dSLionel Sambuc #pragma omp atomic
14*0a6a1f1dSLionel Sambuc   // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
15*0a6a1f1dSLionel Sambuc   {
16*0a6a1f1dSLionel Sambuc     foo();
17*0a6a1f1dSLionel Sambuc   L2:
18*0a6a1f1dSLionel Sambuc     foo();
19*0a6a1f1dSLionel Sambuc   }
20*0a6a1f1dSLionel Sambuc 
21*0a6a1f1dSLionel Sambuc   return 0;
22*0a6a1f1dSLionel Sambuc }
23*0a6a1f1dSLionel Sambuc 
24*0a6a1f1dSLionel Sambuc struct S {
25*0a6a1f1dSLionel Sambuc   int a;
26*0a6a1f1dSLionel Sambuc };
27*0a6a1f1dSLionel Sambuc 
readint()28*0a6a1f1dSLionel Sambuc int readint() {
29*0a6a1f1dSLionel Sambuc   int a = 0, b = 0;
30*0a6a1f1dSLionel Sambuc // Test for atomic read
31*0a6a1f1dSLionel Sambuc #pragma omp atomic read
32*0a6a1f1dSLionel Sambuc   // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
33*0a6a1f1dSLionel Sambuc   // expected-note@+1 {{expected an expression statement}}
34*0a6a1f1dSLionel Sambuc   ;
35*0a6a1f1dSLionel Sambuc #pragma omp atomic read
36*0a6a1f1dSLionel Sambuc   // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
37*0a6a1f1dSLionel Sambuc   // expected-note@+1 {{expected built-in assignment operator}}
38*0a6a1f1dSLionel Sambuc   foo();
39*0a6a1f1dSLionel Sambuc #pragma omp atomic read
40*0a6a1f1dSLionel Sambuc   // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
41*0a6a1f1dSLionel Sambuc   // expected-note@+1 {{expected built-in assignment operator}}
42*0a6a1f1dSLionel Sambuc   a += b;
43*0a6a1f1dSLionel Sambuc #pragma omp atomic read
44*0a6a1f1dSLionel Sambuc   // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
45*0a6a1f1dSLionel Sambuc   // expected-note@+1 {{expected lvalue expression}}
46*0a6a1f1dSLionel Sambuc   a = 0;
47*0a6a1f1dSLionel Sambuc #pragma omp atomic read
48*0a6a1f1dSLionel Sambuc   a = b;
49*0a6a1f1dSLionel Sambuc   // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'read' clause}}
50*0a6a1f1dSLionel Sambuc #pragma omp atomic read read
51*0a6a1f1dSLionel Sambuc   a = b;
52*0a6a1f1dSLionel Sambuc 
53*0a6a1f1dSLionel Sambuc   return 0;
54*0a6a1f1dSLionel Sambuc }
55*0a6a1f1dSLionel Sambuc 
readS()56*0a6a1f1dSLionel Sambuc int readS() {
57*0a6a1f1dSLionel Sambuc   struct S a, b;
58*0a6a1f1dSLionel Sambuc   // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'read' clause}}
59*0a6a1f1dSLionel Sambuc #pragma omp atomic read read
60*0a6a1f1dSLionel Sambuc   // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
61*0a6a1f1dSLionel Sambuc   // expected-note@+1 {{expected expression of scalar type}}
62*0a6a1f1dSLionel Sambuc   a = b;
63*0a6a1f1dSLionel Sambuc 
64*0a6a1f1dSLionel Sambuc   return a.a;
65*0a6a1f1dSLionel Sambuc }
66*0a6a1f1dSLionel Sambuc 
writeint()67*0a6a1f1dSLionel Sambuc int writeint() {
68*0a6a1f1dSLionel Sambuc   int a = 0, b = 0;
69*0a6a1f1dSLionel Sambuc // Test for atomic write
70*0a6a1f1dSLionel Sambuc #pragma omp atomic write
71*0a6a1f1dSLionel Sambuc   // expected-error@+2 {{the statement for 'atomic write' must be an expression statement of form 'x = expr;', where x is a lvalue expression with scalar type}}
72*0a6a1f1dSLionel Sambuc   // expected-note@+1 {{expected an expression statement}}
73*0a6a1f1dSLionel Sambuc   ;
74*0a6a1f1dSLionel Sambuc #pragma omp atomic write
75*0a6a1f1dSLionel Sambuc   // expected-error@+2 {{the statement for 'atomic write' must be an expression statement of form 'x = expr;', where x is a lvalue expression with scalar type}}
76*0a6a1f1dSLionel Sambuc   // expected-note@+1 {{expected built-in assignment operator}}
77*0a6a1f1dSLionel Sambuc   foo();
78*0a6a1f1dSLionel Sambuc #pragma omp atomic write
79*0a6a1f1dSLionel Sambuc   // expected-error@+2 {{the statement for 'atomic write' must be an expression statement of form 'x = expr;', where x is a lvalue expression with scalar type}}
80*0a6a1f1dSLionel Sambuc   // expected-note@+1 {{expected built-in assignment operator}}
81*0a6a1f1dSLionel Sambuc   a += b;
82*0a6a1f1dSLionel Sambuc #pragma omp atomic write
83*0a6a1f1dSLionel Sambuc   a = 0;
84*0a6a1f1dSLionel Sambuc #pragma omp atomic write
85*0a6a1f1dSLionel Sambuc   a = b;
86*0a6a1f1dSLionel Sambuc   // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'write' clause}}
87*0a6a1f1dSLionel Sambuc #pragma omp atomic write write
88*0a6a1f1dSLionel Sambuc   a = b;
89*0a6a1f1dSLionel Sambuc 
90*0a6a1f1dSLionel Sambuc   return 0;
91*0a6a1f1dSLionel Sambuc }
92*0a6a1f1dSLionel Sambuc 
writeS()93*0a6a1f1dSLionel Sambuc int writeS() {
94*0a6a1f1dSLionel Sambuc   struct S a, b;
95*0a6a1f1dSLionel Sambuc   // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'write' clause}}
96*0a6a1f1dSLionel Sambuc #pragma omp atomic write write
97*0a6a1f1dSLionel Sambuc   // expected-error@+2 {{the statement for 'atomic write' must be an expression statement of form 'x = expr;', where x is a lvalue expression with scalar type}}
98*0a6a1f1dSLionel Sambuc   // expected-note@+1 {{expected expression of scalar type}}
99*0a6a1f1dSLionel Sambuc   a = b;
100*0a6a1f1dSLionel Sambuc 
101*0a6a1f1dSLionel Sambuc   return a.a;
102*0a6a1f1dSLionel Sambuc }
103