blob: 29707d259b96328d3e3639c4a593311831973eec [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 %s -verify -fsyntax-only
Chris Lattnere3995fe2007-11-06 06:07:26 +00002
3void foo(void);
Steve Naroffadbbd0c2008-01-14 20:51:29 +00004void foo(void) {}
Chris Lattnere3995fe2007-11-06 06:07:26 +00005void foo(void);
Chris Lattner5f4a6822008-11-23 23:12:31 +00006void foo(void); // expected-note {{previous declaration is here}}
Chris Lattnere3995fe2007-11-06 06:07:26 +00007
Steve Naroff837618c2008-01-16 15:01:34 +00008void foo(int); // expected-error {{conflicting types for 'foo'}}
Steve Naroffadbbd0c2008-01-14 20:51:29 +00009
10int funcdef()
11{
12 return 0;
13}
14
15int funcdef();
16
Chris Lattner5f4a6822008-11-23 23:12:31 +000017int funcdef2() { return 0; } // expected-note {{previous definition is here}}
Steve Naroffadbbd0c2008-01-14 20:51:29 +000018int funcdef2() { return 0; } // expected-error {{redefinition of 'funcdef2'}}
19
Nuno Lopesb243b7d2009-01-28 00:44:33 +000020// PR2502
21void (*f)(void);
22void (*f)() = 0;
Daniel Dunbar64cfdb72009-01-28 21:22:12 +000023
24typedef __attribute__(( ext_vector_type(2) )) int Vi2;
25typedef __attribute__(( ext_vector_type(2) )) float Vf2;
26
27Vf2 g0; // expected-note {{previous definition is here}}
28Vi2 g0; // expected-error {{redefinition of 'g0'}}
29
30_Complex int g1; // expected-note {{previous definition is here}}
31_Complex float g1; // expected-error {{redefinition of 'g1'}}
Chris Lattner3ebc36a2009-02-11 06:22:30 +000032
33// rdar://6096412
34extern char i6096412[10];
35extern char i6096412[];
36void foo6096412(void) {
37 int x = sizeof(i6096412);
38}
39
Rafael Espindolaec351f12012-11-27 01:56:54 +000040
41typedef int test1_IA[];
42typedef int test1_A10[10];
43static test1_A10 *test1_f(void);
44void test1_g(void)
45{
46 {
47 extern test1_IA *test1_f(void);
48 }
49 (void)sizeof(*test1_f());
50}
Rafael Espindola8b8a09e2012-11-29 16:09:03 +000051
52typedef int test2_IA[];
53typedef int test2_A10[10];
54
55static test2_A10 *test2_f(void);
56static test2_IA *test2_f(void);
57
58void test2_g(void)
59{
60 (void)sizeof(*test2_f());
61}
62
63int (*test3_f())[10];
64int (*test3_f())[];
65int test3_k = sizeof(*test3_f());
66
67void test4_f(int);
68void test4_f(a)
69 char a;
70{
71 int v[sizeof(a) == 1 ? 1 : -1];
72}
73
74int test5_f(int (*)[10]);
75int test5_f(int (*x)[]) {
76 return sizeof(*x); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}}
77}
78
79void test6_f(int (*a)[11]);
80void test6_f(a)
81 int (*a)[];
82{}
83void test6_g() {
84 int arr[10];
85 test6_f(&arr); // expected-warning {{incompatible pointer types passing 'int (*)[10]' to parameter of type 'int (*)[11]}}
86}
87
88void test7_f(int (*)[10]);
89void test7_f(int (*)[]); // expected-note {{passing argument to parameter here}}
90void test7_g() {
91 int x[5];
92 test7_f(&x); // expected-warning {{incompatible pointer types passing 'int (*)[5]' to parameter of type 'int (*)[10]}}
93}