annotate gcc/testsuite/gcc.dg/assign-warn-1.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Test diagnostics for bad implicit type conversions. */
kono
parents:
diff changeset
2 /* Origin: Joseph Myers <jsm@polyomino.org.uk> */
kono
parents:
diff changeset
3 /* { dg-do compile } */
kono
parents:
diff changeset
4 /* { dg-options "-pedantic -ftrack-macro-expansion=0" } */
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 #define TESTARG(ID, TL, TR) void ID##F(TL); void ID##F2(TR x) { ID##F(x); } extern int dummy
kono
parents:
diff changeset
7 #define TESTARP(ID, TL, TR) struct { void (*x)(TL); } ID##Fp; void ID##F2(TR x) { ID##Fp.x(x); } extern int dummy
kono
parents:
diff changeset
8 #define TESTASS(ID, TL, TR) void ID##F(TR x) { TL y; y = x; } extern int dummy
kono
parents:
diff changeset
9 #define TESTINI(ID, TL, TR) void ID##F(TR x) { TL y = x; } extern int dummy
kono
parents:
diff changeset
10 #define TESTRET(ID, TL, TR) TR ID##V; TL ID##F(void) { return ID##V; } extern int dummy
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 typedef void (*fp)(void);
kono
parents:
diff changeset
13 typedef void (*nrfp)(void) __attribute__((noreturn));
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 TESTARG(fqa, nrfp, fp); /* { dg-warning "passing argument 1 of 'fqaF' makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */
kono
parents:
diff changeset
16 TESTARP(fqb, nrfp, fp); /* { dg-warning "passing argument 1 of 'fqbFp.x' makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */
kono
parents:
diff changeset
17 TESTASS(fqc, nrfp, fp); /* { dg-warning "assignment makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */
kono
parents:
diff changeset
18 TESTINI(fqd, nrfp, fp); /* { dg-warning "initialization makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */
kono
parents:
diff changeset
19 TESTRET(fqe, nrfp, fp); /* { dg-warning "return makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 TESTARG(ofqa, fp, nrfp);
kono
parents:
diff changeset
22 TESTARP(ofqb, fp, nrfp);
kono
parents:
diff changeset
23 TESTASS(ofqc, fp, nrfp);
kono
parents:
diff changeset
24 TESTINI(ofqd, fp, nrfp);
kono
parents:
diff changeset
25 TESTRET(ofqe, fp, nrfp);
kono
parents:
diff changeset
26
kono
parents:
diff changeset
27 TESTARG(qa, char *, const char *); /* { dg-warning "passing argument 1 of 'qaF' discards 'const' qualifier from pointer target type" } */
kono
parents:
diff changeset
28 TESTARP(qb, char *, const char *); /* { dg-warning "passing argument 1 of 'qbFp.x' discards 'const' qualifier from pointer target type" } */
kono
parents:
diff changeset
29 TESTASS(qc, char *, const char *); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */
kono
parents:
diff changeset
30 TESTINI(qd, char *, const char *); /* { dg-warning "initialization discards 'const' qualifier from pointer target type" } */
kono
parents:
diff changeset
31 TESTRET(qe, char *, const char *); /* { dg-warning "return discards 'const' qualifier from pointer target type" } */
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 TESTARG(oqa, const char *, char *);
kono
parents:
diff changeset
34 TESTARP(oqb, const char *, char *);
kono
parents:
diff changeset
35 TESTASS(oqc, const char *, char *);
kono
parents:
diff changeset
36 TESTINI(oqd, const char *, char *);
kono
parents:
diff changeset
37 TESTRET(oqe, const char *, char *);
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 TESTARG(fda, fp, void *); /* { dg-warning "ISO C forbids passing argument 1 of 'fdaF' between function pointer and 'void \\*'" } */
kono
parents:
diff changeset
40 TESTARP(fdb, fp, void *); /* { dg-warning "ISO C forbids passing argument 1 of 'fdbFp.x' between function pointer and 'void \\*'" } */
kono
parents:
diff changeset
41 TESTASS(fdc, fp, void *); /* { dg-warning "ISO C forbids assignment between function pointer and 'void \\*'" } */
kono
parents:
diff changeset
42 TESTINI(fdd, fp, void *); /* { dg-warning "ISO C forbids initialization between function pointer and 'void \\*'" } */
kono
parents:
diff changeset
43 TESTRET(fde, fp, void *); /* { dg-warning "ISO C forbids return between function pointer and 'void \\*'" } */
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 TESTARG(dfa, void *, fp); /* { dg-warning "ISO C forbids passing argument 1 of 'dfaF' between function pointer and 'void \\*'" } */
kono
parents:
diff changeset
46 TESTARP(dfb, void *, fp); /* { dg-warning "ISO C forbids passing argument 1 of 'dfbFp.x' between function pointer and 'void \\*'" } */
kono
parents:
diff changeset
47 TESTASS(dfc, void *, fp); /* { dg-warning "ISO C forbids assignment between function pointer and 'void \\*'" } */
kono
parents:
diff changeset
48 TESTINI(dfd, void *, fp); /* { dg-warning "ISO C forbids initialization between function pointer and 'void \\*'" } */
kono
parents:
diff changeset
49 TESTRET(dfe, void *, fp); /* { dg-warning "ISO C forbids return between function pointer and 'void \\*'" } */
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 TESTARG(sua, int *, unsigned int *); /* { dg-warning "pointer targets in passing argument 1 of 'suaF' differ in signedness" } */
kono
parents:
diff changeset
52 TESTARP(sub, int *, unsigned int *); /* { dg-warning "pointer targets in passing argument 1 of 'subFp.x' differ in signedness" } */
kono
parents:
diff changeset
53 TESTASS(suc, int *, unsigned int *); /* { dg-warning "pointer targets in assignment from 'unsigned int \\*' to 'int \\*' differ in signedness" } */
kono
parents:
diff changeset
54 TESTINI(sud, int *, unsigned int *); /* { dg-warning "pointer targets in initialization of 'int \\*' from 'unsigned int \\*' differ in signedness" } */
kono
parents:
diff changeset
55 TESTRET(sue, int *, unsigned int *); /* { dg-warning "pointer targets in returning 'unsigned int \\*' from a function with return type 'int \\*' differ in signedness" } */
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 TESTARG(usa, unsigned int *, int *); /* { dg-warning "pointer targets in passing argument 1 of 'usaF' differ in signedness" } */
kono
parents:
diff changeset
58 TESTARP(usb, unsigned int *, int *); /* { dg-warning "pointer targets in passing argument 1 of 'usbFp.x' differ in signedness" } */
kono
parents:
diff changeset
59 TESTASS(usc, unsigned int *, int *); /* { dg-warning "pointer targets in assignment from 'int \\*' to 'unsigned int \\*' differ in signedness" } */
kono
parents:
diff changeset
60 TESTINI(usd, unsigned int *, int *); /* { dg-warning "pointer targets in initialization of 'unsigned int \\*' from 'int \\*' differ in signedness" } */
kono
parents:
diff changeset
61 TESTRET(use, unsigned int *, int *); /* { dg-warning "pointer targets in returning 'int \\*' from a function with return type 'unsigned int \\*' differ in signedness" } */
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 TESTARG(cua, char *, unsigned char *); /* { dg-warning "pointer targets in passing argument 1 of 'cuaF' differ in signedness" } */
kono
parents:
diff changeset
64 TESTARP(cub, char *, unsigned char *); /* { dg-warning "pointer targets in passing argument 1 of 'cubFp.x' differ in signedness" } */
kono
parents:
diff changeset
65 TESTASS(cuc, char *, unsigned char *); /* { dg-warning "pointer targets in assignment from 'unsigned char \\*' to 'char \\*' differ in signedness" } */
kono
parents:
diff changeset
66 TESTINI(cud, char *, unsigned char *); /* { dg-warning "pointer targets in initialization of 'char \\*' from 'unsigned char \\*' differ in signedness" } */
kono
parents:
diff changeset
67 TESTRET(cue, char *, unsigned char *); /* { dg-warning "pointer targets in returning 'unsigned char \\*' from a function with return type 'char \\*' differ in signedness" } */
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 TESTARG(uca, unsigned char *, char *); /* { dg-warning "pointer targets in passing argument 1 of 'ucaF' differ in signedness" } */
kono
parents:
diff changeset
70 TESTARP(ucb, unsigned char *, char *); /* { dg-warning "pointer targets in passing argument 1 of 'ucbFp.x' differ in signedness" } */
kono
parents:
diff changeset
71 TESTASS(ucc, unsigned char *, char *); /* { dg-warning "pointer targets in assignment from 'char \\*' to 'unsigned char \\*' differ in signedness" } */
kono
parents:
diff changeset
72 TESTINI(ucd, unsigned char *, char *); /* { dg-warning "pointer targets in initialization of 'unsigned char \\*' from 'char \\*' differ in signedness" } */
kono
parents:
diff changeset
73 TESTRET(uce, unsigned char *, char *); /* { dg-warning "pointer targets in returning 'char \\*' from a function with return type 'unsigned char \\*' differ in signedness" } */
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 TESTARG(csa, char *, signed char *); /* { dg-warning "pointer targets in passing argument 1 of 'csaF' differ in signedness" } */
kono
parents:
diff changeset
76 TESTARP(csb, char *, signed char *); /* { dg-warning "pointer targets in passing argument 1 of 'csbFp.x' differ in signedness" } */
kono
parents:
diff changeset
77 TESTASS(csc, char *, signed char *); /* { dg-warning "pointer targets in assignment from 'signed char \\*' to 'char \\*' differ in signedness" } */
kono
parents:
diff changeset
78 TESTINI(csd, char *, signed char *); /* { dg-warning "pointer targets in initialization of 'char \\*' from 'signed char \\*' differ in signedness" } */
kono
parents:
diff changeset
79 TESTRET(cse, char *, signed char *); /* { dg-warning "pointer targets in returning 'signed char \\*' from a function with return type 'char \\*' differ in signedness" } */
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 TESTARG(sca, signed char *, char *); /* { dg-warning "pointer targets in passing argument 1 of 'scaF' differ in signedness" } */
kono
parents:
diff changeset
82 TESTARP(scb, signed char *, char *); /* { dg-warning "pointer targets in passing argument 1 of 'scbFp.x' differ in signedness" } */
kono
parents:
diff changeset
83 TESTASS(scc, signed char *, char *); /* { dg-warning "pointer targets in assignment from 'char \\*' to 'signed char \\*' differ in signedness" } */
kono
parents:
diff changeset
84 TESTINI(scd, signed char *, char *); /* { dg-warning "pointer targets in initialization of 'signed char \\*' from 'char \\*' differ in signedness" } */
kono
parents:
diff changeset
85 TESTRET(sce, signed char *, char *); /* { dg-warning "pointer targets in returning 'char \\*' from a function with return type 'signed char \\*' differ in signedness" } */
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 TESTARG(cia, char *, int *); /* { dg-warning "passing argument 1 of 'ciaF' from incompatible pointer type" } */
kono
parents:
diff changeset
88 TESTARP(cib, char *, int *); /* { dg-warning "passing argument 1 of 'cibFp.x' from incompatible pointer type" } */
kono
parents:
diff changeset
89 TESTASS(cic, char *, int *); /* { dg-warning "assignment to 'char \\*' from incompatible pointer type 'int \\*'" } */
kono
parents:
diff changeset
90 TESTINI(cid, char *, int *); /* { dg-warning "initialization of 'char \\*' from incompatible pointer type 'int \\*'" } */
kono
parents:
diff changeset
91 TESTRET(cie, char *, int *); /* { dg-warning "returning 'int \\*' from a function with incompatible return type 'char \\*'" } */
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 TESTARG(ica, int *, char *); /* { dg-warning "passing argument 1 of 'icaF' from incompatible pointer type" } */
kono
parents:
diff changeset
94 TESTARP(icb, int *, char *); /* { dg-warning "passing argument 1 of 'icbFp.x' from incompatible pointer type" } */
kono
parents:
diff changeset
95 TESTASS(icc, int *, char *); /* { dg-warning "assignment to 'int \\*' from incompatible pointer type 'char \\*'" } */
kono
parents:
diff changeset
96 TESTINI(icd, int *, char *); /* { dg-warning "initialization of 'int \\*' from incompatible pointer type 'char \\*'" } */
kono
parents:
diff changeset
97 TESTRET(ice, int *, char *); /* { dg-warning "returning 'char \\*' from a function with incompatible return type 'int \\*'" } */
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 TESTARG(ciia, char *, int); /* { dg-warning "passing argument 1 of 'ciiaF' makes pointer from integer without a cast" } */
kono
parents:
diff changeset
100 TESTARP(ciib, char *, int); /* { dg-warning "passing argument 1 of 'ciibFp.x' makes pointer from integer without a cast" } */
kono
parents:
diff changeset
101 TESTASS(ciic, char *, int); /* { dg-warning "assignment to 'char \\*' from 'int' makes pointer from integer without a cast" } */
kono
parents:
diff changeset
102 TESTINI(ciid, char *, int); /* { dg-warning "initialization of 'char \\*' from 'int' makes pointer from integer without a cast" } */
kono
parents:
diff changeset
103 TESTRET(ciie, char *, int); /* { dg-warning "returning 'int' from a function with return type 'char \\*' makes pointer from integer without a cast" } */
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 TESTARG(iica, int, char *); /* { dg-warning "passing argument 1 of 'iicaF' makes integer from pointer without a cast" } */
kono
parents:
diff changeset
106 TESTARP(iicb, int, char *); /* { dg-warning "passing argument 1 of 'iicbFp.x' makes integer from pointer without a cast" } */
kono
parents:
diff changeset
107 TESTASS(iicc, int, char *); /* { dg-warning "assignment to 'int' from 'char \\*' makes integer from pointer without a cast" } */
kono
parents:
diff changeset
108 TESTINI(iicd, int, char *); /* { dg-warning "initialization of 'int' from 'char \\*' makes integer from pointer without a cast" } */
kono
parents:
diff changeset
109 TESTRET(iice, int, char *); /* { dg-warning "returning 'char \\*' from a function with return type 'int' makes integer from pointer without a cast" } */
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 struct s { int a; };
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 TESTARG(stria, struct s, int); /* { dg-error "incompatible type for argument 1 of 'striaF'" } */
kono
parents:
diff changeset
114 TESTARP(strib, struct s, int); /* { dg-error "incompatible type for argument 1 of 'stribFp.x'" } */
kono
parents:
diff changeset
115 TESTASS(stric, struct s, int); /* { dg-error "incompatible types when assigning to type 'struct s' from type 'int'" } */
kono
parents:
diff changeset
116 TESTINI(strid, struct s, int); /* { dg-error "invalid initializer" } */
kono
parents:
diff changeset
117 TESTRET(strie, struct s, int); /* { dg-error "incompatible types when returning type 'int' but 'struct s' was expected" } */
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 TESTARG(istra, int, struct s); /* { dg-error "incompatible type for argument 1 of 'istraF'" } */
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 TESTARP(istrb, int, struct s); /* { dg-error "incompatible type for argument 1 of 'istrbFp.x'" } */
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 TESTASS(istrc, int, struct s); /* { dg-error "incompatible types when assigning to type 'int' from type 'struct s'" } */
kono
parents:
diff changeset
124 TESTINI(istrd, int, struct s); /* { dg-error "incompatible types when initializing type 'int' using type 'struct s'" } */
kono
parents:
diff changeset
125 TESTRET(istre, int, struct s); /* { dg-error "incompatible types when returning type 'struct s' but 'int' was expected" } */
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 /* Match all extra informative notes. */
kono
parents:
diff changeset
128 /* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" { target *-*-* } 0 } */