comparison gcc/testsuite/gcc.dg/param-type-mismatch.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 /* { dg-options "-fdiagnostics-show-caret" } */ 1 /* { dg-options "-fdiagnostics-show-caret -Wpointer-sign" } */
2 2
3 /* A collection of calls where argument 2 is of the wrong type. */ 3 /* A collection of calls where argument 2 is of the wrong type. */
4 4
5 /* decl, with argname. */ 5 /* decl, with argname. */
6 6
10 { 10 {
11 return callee_1 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_1' makes pointer from integer without a cast" } */ 11 return callee_1 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_1' makes pointer from integer without a cast" } */
12 /* { dg-begin-multiline-output "" } 12 /* { dg-begin-multiline-output "" }
13 return callee_1 (first, second, third); 13 return callee_1 (first, second, third);
14 ^~~~~~ 14 ^~~~~~
15 |
16 int
15 { dg-end-multiline-output "" } */ 17 { dg-end-multiline-output "" } */
16 /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_1 } */ 18 /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_1 } */
17 /* { dg-begin-multiline-output "" } 19 /* { dg-begin-multiline-output "" }
18 extern int callee_1 (int one, const char *two, float three); 20 extern int callee_1 (int one, const char *two, float three);
19 ~~~~~~~~~~~~^~~ 21 ~~~~~~~~~~~~^~~
28 { 30 {
29 return callee_2 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_2' makes pointer from integer without a cast" } */ 31 return callee_2 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_2' makes pointer from integer without a cast" } */
30 /* { dg-begin-multiline-output "" } 32 /* { dg-begin-multiline-output "" }
31 return callee_2 (first, second, third); 33 return callee_2 (first, second, third);
32 ^~~~~~ 34 ^~~~~~
35 |
36 int
33 { dg-end-multiline-output "" } */ 37 { dg-end-multiline-output "" } */
34 /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_2 } */ 38 /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_2 } */
35 /* { dg-begin-multiline-output "" } 39 /* { dg-begin-multiline-output "" }
36 extern int callee_2 (int, const char *, float); 40 extern int callee_2 (int, const char *, float);
37 ^~~~~~~~~~~~ 41 ^~~~~~~~~~~~
49 { 53 {
50 return callee_3 (first, second, third); // { dg-warning "passing argument 2 of 'callee_3' makes pointer from integer without a cast" } 54 return callee_3 (first, second, third); // { dg-warning "passing argument 2 of 'callee_3' makes pointer from integer without a cast" }
51 /* { dg-begin-multiline-output "" } 55 /* { dg-begin-multiline-output "" }
52 return callee_3 (first, second, third); 56 return callee_3 (first, second, third);
53 ^~~~~~ 57 ^~~~~~
58 |
59 int
54 { dg-end-multiline-output "" } */ 60 { dg-end-multiline-output "" } */
55 /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_3 } */ 61 /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_3 } */
56 /* { dg-begin-multiline-output "" } 62 /* { dg-begin-multiline-output "" }
57 static int callee_3 (int one, const char *two, float three) 63 static int callee_3 (int one, const char *two, float three)
58 ~~~~~~~~~~~~^~~ 64 ~~~~~~~~~~~~^~~
67 { 73 {
68 return callee_4 (first, second, third); /* { dg-error "incompatible type for argument 2 of 'callee_4'" } */ 74 return callee_4 (first, second, third); /* { dg-error "incompatible type for argument 2 of 'callee_4'" } */
69 /* { dg-begin-multiline-output "" } 75 /* { dg-begin-multiline-output "" }
70 return callee_4 (first, second, third); 76 return callee_4 (first, second, third);
71 ^~~~~~ 77 ^~~~~~
78 |
79 const char *
72 { dg-end-multiline-output "" } */ 80 { dg-end-multiline-output "" } */
73 /* { dg-message "expected 'float' but argument is of type 'const char \\*'" "" { target *-*-* } callee_4 } */ 81 /* { dg-message "expected 'float' but argument is of type 'const char \\*'" "" { target *-*-* } callee_4 } */
74 /* { dg-begin-multiline-output "" } 82 /* { dg-begin-multiline-output "" }
75 extern int callee_4 (int one, float two, float three); 83 extern int callee_4 (int one, float two, float three);
76 ~~~~~~^~~ 84 ~~~~~~^~~
85 { 93 {
86 return callee_5 (first, second, third); /* { dg-error "incompatible type for argument 2 of 'callee_5'" } */ 94 return callee_5 (first, second, third); /* { dg-error "incompatible type for argument 2 of 'callee_5'" } */
87 /* { dg-begin-multiline-output "" } 95 /* { dg-begin-multiline-output "" }
88 return callee_5 (first, second, third); 96 return callee_5 (first, second, third);
89 ^~~~~~ 97 ^~~~~~
98 |
99 const char *
90 { dg-end-multiline-output "" } */ 100 { dg-end-multiline-output "" } */
91 /* { dg-message "expected 'float' but argument is of type 'const char \\*'" "" { target *-*-* } callee_5 } */ 101 /* { dg-message "expected 'float' but argument is of type 'const char \\*'" "" { target *-*-* } callee_5 } */
92 /* { dg-begin-multiline-output "" } 102 /* { dg-begin-multiline-output "" }
93 extern int callee_5 (int, float, float); 103 extern int callee_5 (int, float, float);
94 ^~~~~ 104 ^~~~~
103 { 113 {
104 return callee_6 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_6' makes pointer from integer without a cast" } */ 114 return callee_6 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_6' makes pointer from integer without a cast" } */
105 /* { dg-begin-multiline-output "" } 115 /* { dg-begin-multiline-output "" }
106 return callee_6 (first, second, third); 116 return callee_6 (first, second, third);
107 ^~~~~~ 117 ^~~~~~
118 |
119 int
108 { dg-end-multiline-output "" } */ 120 { dg-end-multiline-output "" } */
109 /* { dg-message " expected 'int \\(\\*\\)\\(int, int\\)' but argument is of type 'int'" "" { target *-*-* } callee_6 } */ 121 /* { dg-message " expected 'int \\(\\*\\)\\(int, int\\)' but argument is of type 'int'" "" { target *-*-* } callee_6 } */
110 /* { dg-begin-multiline-output "" } 122 /* { dg-begin-multiline-output "" }
111 extern int callee_6 (int one, int (*two)(int, int), float three); 123 extern int callee_6 (int one, int (*two)(int, int), float three);
112 ~~~~~~^~~~~~~~~~~~~~ 124 ~~~~~~^~~~~~~~~~~~~~
121 { 133 {
122 return callee_7 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_7' makes pointer from integer without a cast" } */ 134 return callee_7 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_7' makes pointer from integer without a cast" } */
123 /* { dg-begin-multiline-output "" } 135 /* { dg-begin-multiline-output "" }
124 return callee_7 (first, second, third); 136 return callee_7 (first, second, third);
125 ^~~~~~ 137 ^~~~~~
138 |
139 int
126 { dg-end-multiline-output "" } */ 140 { dg-end-multiline-output "" } */
127 /* { dg-message " expected 'int \\(\\*\\)\\(int, int\\)' but argument is of type 'int'" "" { target *-*-* } callee_7 } */ 141 /* { dg-message " expected 'int \\(\\*\\)\\(int, int\\)' but argument is of type 'int'" "" { target *-*-* } callee_7 } */
128 /* { dg-begin-multiline-output "" } 142 /* { dg-begin-multiline-output "" }
129 extern int callee_7 (int one, int (*)(int, int), float three); 143 extern int callee_7 (int one, int (*)(int, int), float three);
130 ^~~~~~~~~~~~~~~~~ 144 ^~~~~~~~~~~~~~~~~
131 { dg-end-multiline-output "" } */ 145 { dg-end-multiline-output "" } */
132 } 146 }
147
148 /* -Wincompatible-pointer-types for a parameter. */
149
150 extern int callee_8 (int one, float *two, float (three)); /* { dg-line callee_8 } */
151
152 int test_8 (int first, int *second, float third)
153 {
154 return callee_8 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_8' from incompatible pointer type" } */
155 /* { dg-begin-multiline-output "" }
156 return callee_8 (first, second, third);
157 ^~~~~~
158 |
159 int *
160 { dg-end-multiline-output "" } */
161 /* { dg-message "expected 'float \\*' but argument is of type 'int \\*'" "" { target *-*-* } callee_8 } */
162 /* { dg-begin-multiline-output "" }
163 extern int callee_8 (int one, float *two, float (three));
164 ~~~~~~~^~~
165 { dg-end-multiline-output "" } */
166 }
167
168 /* -Wpointer-sign for a parameter. */
169
170 extern int callee_9 (int one, int *two, float (three)); /* { dg-line callee_9 } */
171
172 int test_9 (int first, unsigned int *second, float third)
173 {
174 return callee_9 (first, second, third); /* { dg-warning "pointer targets in passing argument 2 of 'callee_9' differ in signedness" } */
175 /* { dg-begin-multiline-output "" }
176 return callee_9 (first, second, third);
177 ^~~~~~
178 |
179 unsigned int *
180 { dg-end-multiline-output "" } */
181 /* { dg-message "expected 'int \\*' but argument is of type 'unsigned int \\*'" "" { target *-*-* } callee_9 } */
182 /* { dg-begin-multiline-output "" }
183 extern int callee_9 (int one, int *two, float (three));
184 ~~~~~^~~
185 { dg-end-multiline-output "" } */
186 }