1 // RUN: %clang_cc1 %s -fblocks -pedantic -verify -triple=x86_64-apple-darwin9
2 // RUN: %clang_cc1 %s -fblocks -pedantic -verify -triple=mips64-linux-gnu
3 // RUN: %clang_cc1 %s -fblocks -pedantic -verify -triple=x86_64-unknown-linux
4 // RUN: %clang_cc1 %s -fblocks -pedantic -verify -triple=x86_64-unknown-linux-gnux32
5 // RUN: %clang_cc1 %s -fblocks -pedantic -pedantic -verify -triple=arm64_32-apple-ios7.0
6 
7 // rdar://6097662
8 typedef int (*T)[2];
9 restrict T x;
10 
11 typedef int *S[2];
12 restrict S y; // expected-error {{restrict requires a pointer or reference ('S' (aka 'int *[2]') is invalid)}}
13 
14 
15 
16 // int128_t is available.
a()17 int a() {
18   __int128_t s;
19   __uint128_t t;
20 }
21 // but not a keyword
b()22 int b() {
23   int __int128_t;
24   int __uint128_t;
25 }
26 // __int128 is a keyword
c()27 int c() {
28   __int128 i;
29   unsigned __int128 j;
30   long unsigned __int128 k; // expected-error {{'long __int128' is invalid}}
31   int __int128; // expected-error {{cannot combine with previous}} expected-warning {{does not declare anything}}
32 }
33 // __int128_t is __int128; __uint128_t is unsigned __int128.
34 typedef __int128 check_int_128;
35 typedef __int128_t check_int_128; // expected-note {{here}}
36 typedef int check_int_128; // expected-error {{different types ('int' vs '__int128_t' (aka '__int128'))}}
37 
38 typedef unsigned __int128 check_uint_128;
39 typedef __uint128_t check_uint_128; // expected-note {{here}}
40 typedef int check_uint_128; // expected-error {{different types ('int' vs '__uint128_t' (aka 'unsigned __int128'))}}
41 
42 // Array type merging should convert array size to whatever matches the target
43 // pointer size.
44 // rdar://6880874
45 extern int i[1LL];
46 int i[(short)1];
47 
48 enum e { e_1 };
49 extern int j[sizeof(enum e)];  // expected-note {{previous declaration}}
50 int j[42];   // expected-error {{redefinition of 'j' with a different type: 'int [42]' vs 'int [4]'}}
51 
52 // rdar://6880104
53 _Decimal32 x;  // expected-error {{GNU decimal type extension not supported}}
54 
55 
56 // rdar://6880951
57 int __attribute__ ((vector_size (8), vector_size (8))) v;  // expected-error {{invalid vector element type}}
58 
test(int i)59 void test(int i) {
60   char c = (char __attribute__((aligned(8)))) i; // expected-warning {{'aligned' attribute ignored when parsing type}}
61 }
62 
63 // http://llvm.org/PR11082
64 //
65 // FIXME: This may or may not be the correct approach (no warning or error),
66 // but large amounts of Linux and FreeBSD code need this attribute to not be
67 // a hard error in order to work correctly.
test2(int i)68 void test2(int i) {
69   char c = (char __attribute__((may_alias))) i;
70 }
71 
72 // vector size too large
73 int __attribute__ ((vector_size(8192))) x1; // expected-error {{vector size too large}}
74 typedef int __attribute__ ((ext_vector_type(8192))) x2; // expected-error {{vector size too large}}
75 
76 // no support for vector enum type
77 enum { e_2 } x3 __attribute__((vector_size(64))); // expected-error {{invalid vector element type}}
78 
79 int x4 __attribute__((ext_vector_type(64)));  // expected-error {{'ext_vector_type' attribute only applies to typedefs}}
80 
81 // rdar://16492792
82 typedef __attribute__ ((ext_vector_type(32),__aligned__(32))) unsigned char uchar32;
83 
convert()84 void convert() {
85     uchar32 r = 0;
86     r.s[ 1234 ] = 1; // expected-error {{illegal vector component name 's'}}
87 }
88 
89 int &*_Atomic null_type_0; // expected-error {{expected identifier or '('}}
90 int &*__restrict__ null_type_1; // expected-error {{expected identifier or '('}}
91 int ^_Atomic null_type_2; // expected-error {{block pointer to non-function type is invalid}}
92