Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -verify -fsyntax-only |
Chris Lattner | e3995fe | 2007-11-06 06:07:26 +0000 | [diff] [blame] | 2 | |
| 3 | void foo(void); |
Steve Naroff | adbbd0c | 2008-01-14 20:51:29 +0000 | [diff] [blame] | 4 | void foo(void) {} |
Chris Lattner | e3995fe | 2007-11-06 06:07:26 +0000 | [diff] [blame] | 5 | void foo(void); |
Chris Lattner | 5f4a682 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 6 | void foo(void); // expected-note {{previous declaration is here}} |
Chris Lattner | e3995fe | 2007-11-06 06:07:26 +0000 | [diff] [blame] | 7 | |
Steve Naroff | 837618c | 2008-01-16 15:01:34 +0000 | [diff] [blame] | 8 | void foo(int); // expected-error {{conflicting types for 'foo'}} |
Steve Naroff | adbbd0c | 2008-01-14 20:51:29 +0000 | [diff] [blame] | 9 | |
| 10 | int funcdef() |
| 11 | { |
| 12 | return 0; |
| 13 | } |
| 14 | |
| 15 | int funcdef(); |
| 16 | |
Chris Lattner | 5f4a682 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 17 | int funcdef2() { return 0; } // expected-note {{previous definition is here}} |
Steve Naroff | adbbd0c | 2008-01-14 20:51:29 +0000 | [diff] [blame] | 18 | int funcdef2() { return 0; } // expected-error {{redefinition of 'funcdef2'}} |
| 19 | |
Nuno Lopes | b243b7d | 2009-01-28 00:44:33 +0000 | [diff] [blame] | 20 | // PR2502 |
| 21 | void (*f)(void); |
| 22 | void (*f)() = 0; |
Daniel Dunbar | 64cfdb7 | 2009-01-28 21:22:12 +0000 | [diff] [blame] | 23 | |
| 24 | typedef __attribute__(( ext_vector_type(2) )) int Vi2; |
| 25 | typedef __attribute__(( ext_vector_type(2) )) float Vf2; |
| 26 | |
| 27 | Vf2 g0; // expected-note {{previous definition is here}} |
| 28 | Vi2 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 Lattner | 3ebc36a | 2009-02-11 06:22:30 +0000 | [diff] [blame] | 32 | |
| 33 | // rdar://6096412 |
| 34 | extern char i6096412[10]; |
| 35 | extern char i6096412[]; |
| 36 | void foo6096412(void) { |
| 37 | int x = sizeof(i6096412); |
| 38 | } |
| 39 | |
Rafael Espindola | ec351f1 | 2012-11-27 01:56:54 +0000 | [diff] [blame] | 40 | |
| 41 | typedef int test1_IA[]; |
| 42 | typedef int test1_A10[10]; |
| 43 | static test1_A10 *test1_f(void); |
| 44 | void test1_g(void) |
| 45 | { |
| 46 | { |
| 47 | extern test1_IA *test1_f(void); |
| 48 | } |
| 49 | (void)sizeof(*test1_f()); |
| 50 | } |
Rafael Espindola | 8b8a09e | 2012-11-29 16:09:03 +0000 | [diff] [blame] | 51 | |
| 52 | typedef int test2_IA[]; |
| 53 | typedef int test2_A10[10]; |
| 54 | |
| 55 | static test2_A10 *test2_f(void); |
| 56 | static test2_IA *test2_f(void); |
| 57 | |
| 58 | void test2_g(void) |
| 59 | { |
| 60 | (void)sizeof(*test2_f()); |
| 61 | } |
| 62 | |
| 63 | int (*test3_f())[10]; |
| 64 | int (*test3_f())[]; |
| 65 | int test3_k = sizeof(*test3_f()); |
| 66 | |
| 67 | void test4_f(int); |
| 68 | void test4_f(a) |
| 69 | char a; |
| 70 | { |
| 71 | int v[sizeof(a) == 1 ? 1 : -1]; |
| 72 | } |
| 73 | |
| 74 | int test5_f(int (*)[10]); |
| 75 | int test5_f(int (*x)[]) { |
| 76 | return sizeof(*x); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}} |
| 77 | } |
| 78 | |
| 79 | void test6_f(int (*a)[11]); |
| 80 | void test6_f(a) |
| 81 | int (*a)[]; |
| 82 | {} |
| 83 | void 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 | |
| 88 | void test7_f(int (*)[10]); |
| 89 | void test7_f(int (*)[]); // expected-note {{passing argument to parameter here}} |
| 90 | void 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 | } |