Douglas Gregor | b4e715b | 2009-04-13 20:46:52 +0000 | [diff] [blame] | 1 | // Test this without pch. |
Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -fblocks -include %S/types.h -fsyntax-only -verify %s |
Douglas Gregor | b4e715b | 2009-04-13 20:46:52 +0000 | [diff] [blame] | 3 | |
| 4 | // Test with pch. |
Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 5 | // RUN: %clang_cc1 -emit-pch -fblocks -o %t %S/types.h |
| 6 | // RUN: %clang_cc1 -fblocks -include-pch %t -fsyntax-only -verify %s |
Douglas Gregor | b4e715b | 2009-04-13 20:46:52 +0000 | [diff] [blame] | 7 | |
Douglas Gregor | 6d47396 | 2009-04-15 22:00:08 +0000 | [diff] [blame] | 8 | typedef int INT; |
| 9 | INT int_value; |
| 10 | |
| 11 | __attribute__((address_space(1))) int int_as_one; |
| 12 | |
| 13 | // TYPE_EXT_QUAL |
| 14 | ASInt *as_int_ptr1 = &int_value; // expected-error{{different address spaces}} \ |
| 15 | // FIXME: expected-warning{{discards qualifiers}} |
| 16 | ASInt *as_int_ptr2 = &int_as_one; |
| 17 | |
Douglas Gregor | b4e715b | 2009-04-13 20:46:52 +0000 | [diff] [blame] | 18 | // FIXME: TYPE_FIXED_WIDTH_INT |
| 19 | |
| 20 | // TYPE_COMPLEX |
| 21 | _Complex float Cfloat_val; |
| 22 | Cfloat *Cfloat_ptr = &Cfloat_val; |
| 23 | |
| 24 | // TYPE_POINTER |
Douglas Gregor | b4e715b | 2009-04-13 20:46:52 +0000 | [diff] [blame] | 25 | int_ptr int_value_ptr = &int_value; |
| 26 | |
| 27 | // TYPE_BLOCK_POINTER |
| 28 | void test_block_ptr(Block *bl) { |
| 29 | *bl = ^(int x, float f) { return x; }; |
| 30 | } |
| 31 | |
| 32 | // TYPE_CONSTANT_ARRAY |
| 33 | five_ints fvi = { 1, 2, 3, 4, 5 }; |
| 34 | |
| 35 | // TYPE_INCOMPLETE_ARRAY |
| 36 | float_array fa1 = { 1, 2, 3 }; |
| 37 | float_array fa2 = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 38 | |
Douglas Gregor | ba48d05 | 2009-04-22 00:21:21 +0000 | [diff] [blame] | 39 | // TYPE_VARIABLE_ARRAY in stmts.[ch] |
Douglas Gregor | b4e715b | 2009-04-13 20:46:52 +0000 | [diff] [blame] | 40 | |
| 41 | // TYPE_VECTOR |
| 42 | float4 f4 = { 1.0, 2.0, 3.0, 4.0 }; |
| 43 | |
| 44 | // TYPE_EXT_VECTOR |
| 45 | ext_float4 ef4 = { 1.0, 2.0, 3.0, 4.0 }; |
| 46 | |
| 47 | // TYPE_FUNCTION_NO_PROTO |
| 48 | noproto np1; |
| 49 | int np1(x, y) |
| 50 | int x; |
| 51 | float y; |
| 52 | { |
| 53 | return x; |
| 54 | } |
| 55 | |
| 56 | // TYPE_FUNCTION_PROTO |
| 57 | proto p1; |
| 58 | float p1(float x, float y, ...) { |
| 59 | return x + y; |
| 60 | } |
| 61 | proto *p2 = p1; |
| 62 | |
| 63 | // TYPE_TYPEDEF |
| 64 | int_ptr_ptr ipp = &int_value_ptr; |
| 65 | |
Douglas Gregor | 0b74891 | 2009-04-14 21:18:50 +0000 | [diff] [blame] | 66 | // TYPE_TYPEOF_EXPR |
| 67 | typeof_17 *t17 = &int_value; |
| 68 | struct S { int x, y; }; |
Douglas Gregor | 08a4190 | 2010-04-09 17:53:29 +0000 | [diff] [blame] | 69 | typeof_17 t17_2 = (struct S){1, 2}; // expected-error{{initializing 'typeof_17' (aka 'int') with an expression of incompatible type 'struct S'}} |
Douglas Gregor | b4e715b | 2009-04-13 20:46:52 +0000 | [diff] [blame] | 70 | |
| 71 | // TYPE_TYPEOF |
| 72 | int_ptr_ptr2 ipp2 = &int_value_ptr; |