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