1 // Test this without pch.
2 // RUN: %clang_cc1 -fblocks -include %S/types.h -fsyntax-only -verify %s
3
4 // Test with pch.
5 // RUN: %clang_cc1 -emit-pch -fblocks -o %t %S/types.h
6 // RUN: %clang_cc1 -fblocks -include-pch %t -fsyntax-only -verify %s -ast-print
7
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{{changes address space of pointer}}
15 ASInt *as_int_ptr2 = &int_as_one;
16
17 // TYPE_COMPLEX
18 _Complex float Cfloat_val;
19 Cfloat *Cfloat_ptr = &Cfloat_val;
20
21 // TYPE_ATOMIC
22 _Atomic(int) AtomicInt_val;
23 AtomicInt *AtomicInt_ptr = &AtomicInt_val;
24
25 // TYPE_POINTER
26 int_ptr int_value_ptr = &int_value;
27
28 // TYPE_BLOCK_POINTER
test_block_ptr(Block * bl)29 void test_block_ptr(Block *bl) {
30 *bl = ^(int x, float f) { return x; };
31 }
32
33 // TYPE_CONSTANT_ARRAY
34 five_ints fvi = { 1, 2, 3, 4, 5 };
35
36 // TYPE_INCOMPLETE_ARRAY
37 float_array fa1 = { 1, 2, 3 };
38 float_array fa2 = { 1, 2, 3, 4, 5, 6, 7, 8 };
39
40 // TYPE_VARIABLE_ARRAY in stmts.[ch]
41
42 // TYPE_VECTOR
43 float4 f4 = { 1.0, 2.0, 3.0, 4.0 };
44
45 // TYPE_EXT_VECTOR
46 ext_float4 ef4 = { 1.0, 2.0, 3.0, 4.0 };
47
48 // TYPE_FUNCTION_NO_PROTO
49 noproto np1;
np1(x,y)50 int np1(x, y)
51 int x;
52 float y;
53 {
54 return x;
55 }
56
57 // TYPE_FUNCTION_PROTO
58 proto p1;
p1(float x,float y,...)59 float p1(float x, float y, ...) {
60 return x + y;
61 }
62 proto *p2 = p1;
63
64 // TYPE_TYPEDEF
65 int_ptr_ptr ipp = &int_value_ptr;
66
67 // TYPE_TYPEOF_EXPR
68 typeof_17 *t17 = &int_value;
69 struct S { int x, y; };
70 typeof_17 t17_2 = (struct S){1, 2}; // expected-error{{initializing 'typeof_17' (aka 'int') with an expression of incompatible type 'struct S'}}
71
72 // TYPE_TYPEOF
73 int_ptr_ptr2 ipp2 = &int_value_ptr;
74