Chris Lattner | 3508084 | 2008-02-02 20:20:10 +0000 | [diff] [blame] | 1 | // RUN: clang %s -verify -pedantic -fsyntax-only |
| 2 | |
| 3 | // PR1966 |
| 4 | _Complex double test1() { |
| 5 | return __extension__ 1.0if; |
| 6 | } |
| 7 | |
| 8 | _Complex double test2() { |
| 9 | return 1.0if; // expected-warning {{imaginary constants are an extension}} |
| 10 | } |
| 11 | |
Chris Lattner | baf0d66 | 2008-07-25 18:07:19 +0000 | [diff] [blame] | 12 | // rdar://6097308 |
| 13 | void test3() { |
| 14 | int x; |
| 15 | (__extension__ x) = 10; |
| 16 | } |
| 17 | |
Chris Lattner | 2c15647 | 2008-08-21 18:04:13 +0000 | [diff] [blame] | 18 | // rdar://6162726 |
| 19 | void test4() { |
| 20 | static int var; |
| 21 | var =+ 5; // expected-warning {{use of unary operator that may be intended as compound assignment (+=)}} |
| 22 | var =- 5; // expected-warning {{use of unary operator that may be intended as compound assignment (-=)}} |
| 23 | var = +5; |
| 24 | var = -5; |
| 25 | } |
| 26 | |
Chris Lattner | ca354fa | 2008-11-17 19:51:54 +0000 | [diff] [blame] | 27 | // rdar://6319320 |
| 28 | void test5(int *X, float *P) { |
| 29 | (float*)X = P; // expected-error {{assignment to cast is illegal, lvalue casts are not supported}} |
| 30 | } |
| 31 | |
Chris Lattner | b1b4d33 | 2008-11-21 18:27:34 +0000 | [diff] [blame] | 32 | void test6() { |
| 33 | int X; |
| 34 | X(); // expected-error {{called object type 'int' is not a function or function pointer}} |
| 35 | } |
Chris Lattner | 7ca1425 | 2008-11-22 19:57:03 +0000 | [diff] [blame] | 36 | |
| 37 | void test7(int *P, _Complex float Gamma) { |
| 38 | P = (P-42) + Gamma*4; // expected-error {{invalid operands to binary expression ('int *' and '_Complex float')}} |
| 39 | } |
| 40 | |
Chris Lattner | 670a62c | 2008-12-12 05:35:08 +0000 | [diff] [blame] | 41 | |
| 42 | // rdar://6095061 |
| 43 | int test8(void) { |
| 44 | int i; |
Chris Lattner | 4209a39 | 2008-12-12 05:59:56 +0000 | [diff] [blame] | 45 | __builtin_choose_expr (0, 42, i) = 10; // expected-warning {{extension used}} |
Chris Lattner | 670a62c | 2008-12-12 05:35:08 +0000 | [diff] [blame] | 46 | return i; |
| 47 | } |
Chris Lattner | 31e21e0 | 2009-01-24 20:17:12 +0000 | [diff] [blame] | 48 | |
| 49 | |
| 50 | // PR3386 |
| 51 | struct f { int x : 4; float y[]; }; |
| 52 | int test9(struct f *P) { |
Chris Lattner | da02747 | 2009-01-24 21:29:22 +0000 | [diff] [blame] | 53 | int R; |
| 54 | R = __alignof(P->x); // expected-error {{invalid application of '__alignof' to bitfield}} expected-warning {{extension used}} |
| 55 | R = __alignof(P->y); // ok. expected-warning {{extension used}} |
| 56 | R = sizeof(P->x); // expected-error {{invalid application of 'sizeof' to bitfield}} |
| 57 | return R; |
Chris Lattner | 31e21e0 | 2009-01-24 20:17:12 +0000 | [diff] [blame] | 58 | } |
| 59 | |