annotate clang/test/Sema/knr-def-call.c @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
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 i386-pc-unknown -Wconversion -Wliteral-conversion -fsyntax-only -verify %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 // C DR #316, PR 3626.
anatofuz
parents:
diff changeset
4 void f0(a, b, c, d) int a,b,c,d; {}
anatofuz
parents:
diff changeset
5 void t0(void) {
anatofuz
parents:
diff changeset
6 f0(1); // expected-warning{{too few arguments}}
anatofuz
parents:
diff changeset
7 }
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 void f1(a, b) int a, b; {}
anatofuz
parents:
diff changeset
10 void t1(void) {
anatofuz
parents:
diff changeset
11 f1(1, 2, 3); // expected-warning{{too many arguments}}
anatofuz
parents:
diff changeset
12 }
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 void f2(float); // expected-note{{previous declaration is here}}
anatofuz
parents:
diff changeset
15 void f2(x) float x; { } // expected-warning{{promoted type 'double' of K&R function parameter is not compatible with the parameter type 'float' declared in a previous prototype}}
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 typedef void (*f3)(void);
anatofuz
parents:
diff changeset
18 f3 t3(int b) { return b? f0 : f1; } // okay
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 // <rdar://problem/8193107>
anatofuz
parents:
diff changeset
21 void f4() {
anatofuz
parents:
diff changeset
22 char *rindex();
anatofuz
parents:
diff changeset
23 }
anatofuz
parents:
diff changeset
24
anatofuz
parents:
diff changeset
25 char *rindex(s, c)
anatofuz
parents:
diff changeset
26 register char *s, c; // expected-warning{{promoted type 'char *' of K&R function parameter is not compatible with the parameter type 'const char *' declared in a previous prototype}}
anatofuz
parents:
diff changeset
27 {
anatofuz
parents:
diff changeset
28 return 0;
anatofuz
parents:
diff changeset
29 }
anatofuz
parents:
diff changeset
30
anatofuz
parents:
diff changeset
31 // PR8314
anatofuz
parents:
diff changeset
32 void proto(int);
anatofuz
parents:
diff changeset
33 void proto(x)
anatofuz
parents:
diff changeset
34 int x;
anatofuz
parents:
diff changeset
35 {
anatofuz
parents:
diff changeset
36 }
anatofuz
parents:
diff changeset
37
anatofuz
parents:
diff changeset
38 void use_proto() {
anatofuz
parents:
diff changeset
39 proto(42.1); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 42.1 to 42}}
anatofuz
parents:
diff changeset
40 (&proto)(42.1); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 42.1 to 42}}
anatofuz
parents:
diff changeset
41 }
anatofuz
parents:
diff changeset
42
anatofuz
parents:
diff changeset
43 // PR31020
anatofuz
parents:
diff changeset
44 void func(short d) __attribute__((cdecl)); // expected-note{{previous declaration is here}}
anatofuz
parents:
diff changeset
45 void __attribute__((cdecl)) func(d)
anatofuz
parents:
diff changeset
46 short d; // 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
47 {}