annotate clang/test/Sema/function-redecl.c @ 150:1d019706d866

LLVM10
author anatofuz
date Thu, 13 Feb 2020 15:10:13 +0900
parents
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 // PR3588
anatofuz
parents:
diff changeset
4 void g0(int, int);
anatofuz
parents:
diff changeset
5 void g0(); // expected-note{{previous declaration is here}} expected-note{{'g0' declared here}}
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 void f0() {
anatofuz
parents:
diff changeset
8 g0(1, 2, 3); // expected-error{{too many arguments to function call}}
anatofuz
parents:
diff changeset
9 }
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 void g0(int); // expected-error{{conflicting types for 'g0'}}
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 int g1(int, int);
anatofuz
parents:
diff changeset
14
anatofuz
parents:
diff changeset
15 typedef int INT;
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 INT g1(x, y)
anatofuz
parents:
diff changeset
18 int x;
anatofuz
parents:
diff changeset
19 int y;
anatofuz
parents:
diff changeset
20 {
anatofuz
parents:
diff changeset
21 return x + y;
anatofuz
parents:
diff changeset
22 }
anatofuz
parents:
diff changeset
23
anatofuz
parents:
diff changeset
24 int g2(int, int); // expected-note{{previous declaration is here}}
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 INT g2(x) // expected-error{{conflicting types for 'g2'}}
anatofuz
parents:
diff changeset
27 int x;
anatofuz
parents:
diff changeset
28 {
anatofuz
parents:
diff changeset
29 return x;
anatofuz
parents:
diff changeset
30 }
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32 void test() {
anatofuz
parents:
diff changeset
33 int f1;
anatofuz
parents:
diff changeset
34 {
anatofuz
parents:
diff changeset
35 void f1(double);
anatofuz
parents:
diff changeset
36 {
anatofuz
parents:
diff changeset
37 void f1(double); // expected-note{{previous declaration is here}}
anatofuz
parents:
diff changeset
38 {
anatofuz
parents:
diff changeset
39 int f1(int); // expected-error{{conflicting types for 'f1'}}
anatofuz
parents:
diff changeset
40 }
anatofuz
parents:
diff changeset
41 }
anatofuz
parents:
diff changeset
42 }
anatofuz
parents:
diff changeset
43 }
anatofuz
parents:
diff changeset
44
anatofuz
parents:
diff changeset
45 extern void g3(int); // expected-note{{previous declaration is here}}
anatofuz
parents:
diff changeset
46 static void g3(int x) { } // expected-error{{static declaration of 'g3' follows non-static declaration}}
anatofuz
parents:
diff changeset
47
anatofuz
parents:
diff changeset
48 void test2() {
anatofuz
parents:
diff changeset
49 extern int f2; // expected-note 2 {{previous definition is here}}
anatofuz
parents:
diff changeset
50 {
anatofuz
parents:
diff changeset
51 void f2(int); // expected-error{{redefinition of 'f2' as different kind of symbol}}
anatofuz
parents:
diff changeset
52 }
anatofuz
parents:
diff changeset
53
anatofuz
parents:
diff changeset
54 {
anatofuz
parents:
diff changeset
55 int f2;
anatofuz
parents:
diff changeset
56 {
anatofuz
parents:
diff changeset
57 void f2(int); // expected-error{{redefinition of 'f2' as different kind of symbol}}
anatofuz
parents:
diff changeset
58 }
anatofuz
parents:
diff changeset
59 }
anatofuz
parents:
diff changeset
60 }
anatofuz
parents:
diff changeset
61
anatofuz
parents:
diff changeset
62 // <rdar://problem/6127293>
anatofuz
parents:
diff changeset
63 int outer1(int); // expected-note{{previous declaration is here}}
anatofuz
parents:
diff changeset
64 struct outer3 { };
anatofuz
parents:
diff changeset
65 int outer4(int); // expected-note{{previous declaration is here}}
anatofuz
parents:
diff changeset
66 int outer5; // expected-note{{previous definition is here}}
anatofuz
parents:
diff changeset
67 int *outer7(int);
anatofuz
parents:
diff changeset
68
anatofuz
parents:
diff changeset
69 void outer_test() {
anatofuz
parents:
diff changeset
70 int outer1(float); // expected-error{{conflicting types for 'outer1'}}
anatofuz
parents:
diff changeset
71 int outer2(int); // expected-note{{previous declaration is here}}
anatofuz
parents:
diff changeset
72 int outer3(int); // expected-note{{previous declaration is here}}
anatofuz
parents:
diff changeset
73 int outer4(int);
anatofuz
parents:
diff changeset
74 int outer5(int); // expected-error{{redefinition of 'outer5' as different kind of symbol}}
anatofuz
parents:
diff changeset
75 int* outer6(int); // expected-note{{previous declaration is here}}
anatofuz
parents:
diff changeset
76 int *outer7(int);
anatofuz
parents:
diff changeset
77 int outer8(int);
anatofuz
parents:
diff changeset
78
anatofuz
parents:
diff changeset
79 int *ip7 = outer7(6);
anatofuz
parents:
diff changeset
80 }
anatofuz
parents:
diff changeset
81
anatofuz
parents:
diff changeset
82 int outer2(float); // expected-error{{conflicting types for 'outer2'}}
anatofuz
parents:
diff changeset
83 int outer3(float); // expected-error{{conflicting types for 'outer3'}}
anatofuz
parents:
diff changeset
84 int outer4(float); // expected-error{{conflicting types for 'outer4'}}
anatofuz
parents:
diff changeset
85
anatofuz
parents:
diff changeset
86 void outer_test2(int x) {
anatofuz
parents:
diff changeset
87 int* ip = outer6(x); // expected-warning{{use of out-of-scope declaration of 'outer6'}}
anatofuz
parents:
diff changeset
88 int *ip2 = outer7(x);
anatofuz
parents:
diff changeset
89 }
anatofuz
parents:
diff changeset
90
anatofuz
parents:
diff changeset
91 void outer_test3() {
anatofuz
parents:
diff changeset
92 int *(*fp)(int) = outer8; // expected-error{{use of undeclared identifier 'outer8'}}
anatofuz
parents:
diff changeset
93 }
anatofuz
parents:
diff changeset
94
anatofuz
parents:
diff changeset
95 enum e { e1, e2 };
anatofuz
parents:
diff changeset
96
anatofuz
parents:
diff changeset
97 // GNU extension: prototypes and K&R function definitions
anatofuz
parents:
diff changeset
98 int isroot(short x, // expected-note{{previous declaration is here}}
anatofuz
parents:
diff changeset
99 enum e);
anatofuz
parents:
diff changeset
100
anatofuz
parents:
diff changeset
101 int isroot(x, y)
anatofuz
parents:
diff changeset
102 short x; // expected-warning{{promoted type 'int' of K&R function parameter is not compatible with the parameter type 'short' declared in a previous prototype}}
anatofuz
parents:
diff changeset
103 unsigned int y;
anatofuz
parents:
diff changeset
104 {
anatofuz
parents:
diff changeset
105 return x == 1;
anatofuz
parents:
diff changeset
106 }
anatofuz
parents:
diff changeset
107
anatofuz
parents:
diff changeset
108 // PR3817
anatofuz
parents:
diff changeset
109 void *h0(unsigned a0, ...);
anatofuz
parents:
diff changeset
110 extern __typeof (h0) h1 __attribute__((__sentinel__));
anatofuz
parents:
diff changeset
111 extern __typeof (h1) h1 __attribute__((__sentinel__));
anatofuz
parents:
diff changeset
112
anatofuz
parents:
diff changeset
113 // PR3840
anatofuz
parents:
diff changeset
114 void i0 (unsigned short a0);
anatofuz
parents:
diff changeset
115 extern __typeof (i0) i1;
anatofuz
parents:
diff changeset
116 extern __typeof (i1) i1;
anatofuz
parents:
diff changeset
117
anatofuz
parents:
diff changeset
118 typedef int a();
anatofuz
parents:
diff changeset
119 typedef int a2(int*);
anatofuz
parents:
diff changeset
120 a x;
anatofuz
parents:
diff changeset
121 a2 x2; // expected-note{{passing argument to parameter here}}
anatofuz
parents:
diff changeset
122 void test_x() {
anatofuz
parents:
diff changeset
123 x(5);
anatofuz
parents:
diff changeset
124 x2(5); // expected-warning{{incompatible integer to pointer conversion passing 'int' to parameter of type 'int *'}}
anatofuz
parents:
diff changeset
125 }
anatofuz
parents:
diff changeset
126
anatofuz
parents:
diff changeset
127 enum e0 {one};
anatofuz
parents:
diff changeset
128 void f3();
anatofuz
parents:
diff changeset
129 void f3(enum e0 x) {}
anatofuz
parents:
diff changeset
130
anatofuz
parents:
diff changeset
131 enum incomplete_enum;
anatofuz
parents:
diff changeset
132 void f4(); // expected-note {{previous declaration is here}}
anatofuz
parents:
diff changeset
133 void f4(enum incomplete_enum); // expected-error {{conflicting types for 'f4'}}