Alexey Bataev | 0162e45 | 2014-07-22 10:10:35 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s |
| 2 | |
| 3 | int foo() { |
Alexey Bataev | f98b00c | 2014-07-23 02:27:21 +0000 | [diff] [blame] | 4 | L1: |
| 5 | foo(); |
| 6 | #pragma omp atomic |
Alexey Bataev | 67a4f22 | 2014-07-23 10:25:33 +0000 | [diff] [blame] | 7 | // 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}} |
Alexey Bataev | 0162e45 | 2014-07-22 10:10:35 +0000 | [diff] [blame] | 8 | { |
| 9 | foo(); |
| 10 | goto L1; // expected-error {{use of undeclared label 'L1'}} |
| 11 | } |
| 12 | goto L2; // expected-error {{use of undeclared label 'L2'}} |
Alexey Bataev | f98b00c | 2014-07-23 02:27:21 +0000 | [diff] [blame] | 13 | #pragma omp atomic |
Alexey Bataev | 67a4f22 | 2014-07-23 10:25:33 +0000 | [diff] [blame] | 14 | // 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}} |
Alexey Bataev | 0162e45 | 2014-07-22 10:10:35 +0000 | [diff] [blame] | 15 | { |
| 16 | foo(); |
Alexey Bataev | f98b00c | 2014-07-23 02:27:21 +0000 | [diff] [blame] | 17 | L2: |
Alexey Bataev | 0162e45 | 2014-07-22 10:10:35 +0000 | [diff] [blame] | 18 | foo(); |
| 19 | } |
| 20 | |
| 21 | return 0; |
| 22 | } |
Alexey Bataev | f98b00c | 2014-07-23 02:27:21 +0000 | [diff] [blame] | 23 | |
| 24 | template <class T> |
| 25 | T read() { |
| 26 | T a, b = 0; |
| 27 | // Test for atomic read |
| 28 | #pragma omp atomic read |
| 29 | // expected-error@+1 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both l-value expressions with scalar type}} |
| 30 | ; |
| 31 | // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'read' clause}} |
| 32 | #pragma omp atomic read read |
| 33 | a = b; |
| 34 | |
| 35 | return T(); |
| 36 | } |
| 37 | |
| 38 | int read() { |
| 39 | int a, b = 0; |
| 40 | // Test for atomic read |
| 41 | #pragma omp atomic read |
| 42 | // expected-error@+1 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both l-value expressions with scalar type}} |
| 43 | ; |
| 44 | // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'read' clause}} |
| 45 | #pragma omp atomic read read |
| 46 | a = b; |
| 47 | |
| 48 | return read<int>(); |
| 49 | } |
Alexey Bataev | dea4761 | 2014-07-23 07:46:59 +0000 | [diff] [blame] | 50 | |
| 51 | template <class T> |
| 52 | T write() { |
| 53 | T a, b = 0; |
| 54 | // Test for atomic write |
| 55 | #pragma omp atomic write |
| 56 | // expected-error@+1 {{the statement for 'atomic write' must be an expression statement of form 'x = expr;', where x is an l-value expression with scalar type}} |
| 57 | ; |
| 58 | // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'write' clause}} |
| 59 | #pragma omp atomic write write |
| 60 | a = b; |
| 61 | |
| 62 | return T(); |
| 63 | } |
| 64 | |
| 65 | int write() { |
| 66 | int a, b = 0; |
| 67 | // Test for atomic write |
| 68 | #pragma omp atomic write |
| 69 | // expected-error@+1 {{the statement for 'atomic write' must be an expression statement of form 'x = expr;', where x is an l-value expression with scalar type}} |
| 70 | ; |
| 71 | // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'write' clause}} |
| 72 | #pragma omp atomic write write |
| 73 | a = b; |
| 74 | |
| 75 | return write<int>(); |
| 76 | } |
| 77 | |
| 78 | template <class T> |
Alexey Bataev | 67a4f22 | 2014-07-23 10:25:33 +0000 | [diff] [blame] | 79 | T update() { |
| 80 | T a, b = 0; |
| 81 | // Test for atomic update |
| 82 | #pragma omp atomic update |
| 83 | // expected-error@+1 {{the statement for 'atomic update' 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}} |
| 84 | ; |
| 85 | // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'update' clause}} |
| 86 | #pragma omp atomic update update |
| 87 | a += b; |
| 88 | |
| 89 | #pragma omp atomic |
| 90 | // 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}} |
| 91 | ; |
| 92 | |
| 93 | return T(); |
| 94 | } |
| 95 | |
| 96 | int update() { |
| 97 | int a, b = 0; |
| 98 | // Test for atomic update |
| 99 | #pragma omp atomic update |
| 100 | // expected-error@+1 {{the statement for 'atomic update' 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}} |
| 101 | ; |
| 102 | // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'update' clause}} |
| 103 | #pragma omp atomic update update |
| 104 | a += b; |
| 105 | |
| 106 | #pragma omp atomic |
| 107 | // 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}} |
| 108 | ; |
| 109 | |
| 110 | return update<int>(); |
| 111 | } |
| 112 | |
| 113 | template <class T> |
Alexey Bataev | dea4761 | 2014-07-23 07:46:59 +0000 | [diff] [blame] | 114 | T mixed() { |
| 115 | T a, b = T(); |
| 116 | // expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}} |
| 117 | // expected-note@+1 2 {{'read' clause used here}} |
| 118 | #pragma omp atomic read write |
| 119 | a = b; |
| 120 | // expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}} |
| 121 | // expected-note@+1 2 {{'write' clause used here}} |
| 122 | #pragma omp atomic write read |
| 123 | a = b; |
Alexey Bataev | 67a4f22 | 2014-07-23 10:25:33 +0000 | [diff] [blame] | 124 | // expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}} |
| 125 | // expected-note@+1 2 {{'update' clause used here}} |
| 126 | #pragma omp atomic update read |
| 127 | a += b; |
Alexey Bataev | dea4761 | 2014-07-23 07:46:59 +0000 | [diff] [blame] | 128 | return T(); |
| 129 | } |
| 130 | |
| 131 | int mixed() { |
| 132 | int a, b = 0; |
| 133 | // expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}} |
| 134 | // expected-note@+1 {{'read' clause used here}} |
| 135 | #pragma omp atomic read write |
| 136 | a = b; |
| 137 | // expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}} |
| 138 | // expected-note@+1 {{'write' clause used here}} |
| 139 | #pragma omp atomic write read |
| 140 | a = b; |
Alexey Bataev | 67a4f22 | 2014-07-23 10:25:33 +0000 | [diff] [blame] | 141 | // expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}} |
| 142 | // expected-note@+1 {{'write' clause used here}} |
| 143 | #pragma omp atomic write update |
| 144 | a = b; |
Alexey Bataev | dea4761 | 2014-07-23 07:46:59 +0000 | [diff] [blame] | 145 | // expected-note@+1 {{in instantiation of function template specialization 'mixed<int>' requested here}} |
| 146 | return mixed<int>(); |
| 147 | } |
| 148 | |