1 /* { dg-options "-fdiagnostics-show-caret" }  */
2 
3 /* A collection of calls where argument 2 is of the wrong type.  */
4 
5 /* decl, with argname.  */
6 
7 extern int callee_1 (int one, const char *two, float three); /* { dg-line callee_1 } */
8 
test_1(int first,int second,float third)9 int test_1 (int first, int second, float third)
10 {
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 "" }
13    return callee_1 (first, second, third);
14                            ^~~~~~
15      { dg-end-multiline-output "" } */
16   /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_1 } */
17   /* { dg-begin-multiline-output "" }
18  extern int callee_1 (int one, const char *two, float three);
19                                ~~~~~~~~~~~~^~~
20      { dg-end-multiline-output "" } */
21 }
22 
23 /* decl, without argname.  */
24 
25 extern int callee_2 (int, const char *, float); /* { dg-line callee_2 } */
26 
test_2(int first,int second,float third)27 int test_2 (int first, int second, float third)
28 {
29   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 "" }
31    return callee_2 (first, second, third);
32                            ^~~~~~
33      { dg-end-multiline-output "" } */
34   /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_2 } */
35   /* { dg-begin-multiline-output "" }
36  extern int callee_2 (int, const char *, float);
37                            ^~~~~~~~~~~~
38      { dg-end-multiline-output "" } */
39 }
40 
41 /* defn, with argname.  */
42 
callee_3(int one,const char * two,float three)43 static int callee_3 (int one, const char *two, float three) /* { dg-line callee_3 } */
44 {
45   return callee_2 (one, two, three);
46 }
47 
test_3(int first,int second,float third)48 int test_3 (int first, int second, float third)
49 {
50   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 "" }
52    return callee_3 (first, second, third);
53                            ^~~~~~
54      { dg-end-multiline-output "" } */
55   /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_3 } */
56   /* { dg-begin-multiline-output "" }
57  static int callee_3 (int one, const char *two, float three)
58                                ~~~~~~~~~~~~^~~
59      { dg-end-multiline-output "" } */
60 }
61 
62 /* Trivial decl, with argname.  */
63 
64 extern int callee_4 (int one, float two, float three); /* { dg-line callee_4 } */
65 
test_4(int first,const char * second,float third)66 int test_4 (int first, const char *second, float third)
67 {
68   return callee_4 (first, second, third); /* { dg-error "incompatible type for argument 2 of 'callee_4'" }  */
69   /* { dg-begin-multiline-output "" }
70    return callee_4 (first, second, third);
71                            ^~~~~~
72      { dg-end-multiline-output "" } */
73   /* { dg-message "expected 'float' but argument is of type 'const char \\*'" "" { target *-*-* } callee_4 } */
74   /* { dg-begin-multiline-output "" }
75  extern int callee_4 (int one, float two, float three);
76                                ~~~~~~^~~
77      { dg-end-multiline-output "" } */
78 }
79 
80 /* Trivial decl, without argname.  */
81 
82 extern int callee_5 (int, float, float); /* { dg-line callee_5 } */
83 
test_5(int first,const char * second,float third)84 int test_5 (int first, const char *second, float third)
85 {
86   return callee_5 (first, second, third); /* { dg-error "incompatible type for argument 2 of 'callee_5'" }  */
87   /* { dg-begin-multiline-output "" }
88    return callee_5 (first, second, third);
89                            ^~~~~~
90      { dg-end-multiline-output "" } */
91   /* { dg-message "expected 'float' but argument is of type 'const char \\*'" "" { target *-*-* } callee_5 } */
92   /* { dg-begin-multiline-output "" }
93  extern int callee_5 (int, float, float);
94                            ^~~~~
95      { dg-end-multiline-output "" } */
96 }
97 
98 /* Callback with name.  */
99 
100 extern int callee_6 (int one, int (*two)(int, int), float three); /* { dg-line callee_6 } */
101 
test_6(int first,int second,float third)102 int test_6 (int first, int second, float third)
103 {
104   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 "" }
106    return callee_6 (first, second, third);
107                            ^~~~~~
108      { dg-end-multiline-output "" } */
109   /* { dg-message " expected 'int \\(\\*\\)\\(int,  int\\)' but argument is of type 'int'" "" { target *-*-* } callee_6 } */
110   /* { dg-begin-multiline-output "" }
111  extern int callee_6 (int one, int (*two)(int, int), float three);
112                                ~~~~~~^~~~~~~~~~~~~~
113      { dg-end-multiline-output "" } */
114 }
115 
116 /* Callback without name.  */
117 
118 extern int callee_7 (int one, int (*)(int, int), float three); /* { dg-line callee_7 } */
119 
test_7(int first,int second,float third)120 int test_7 (int first, int second, float third)
121 {
122   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 "" }
124    return callee_7 (first, second, third);
125                            ^~~~~~
126      { dg-end-multiline-output "" } */
127   /* { dg-message " expected 'int \\(\\*\\)\\(int,  int\\)' but argument is of type 'int'" "" { target *-*-* } callee_7 } */
128   /* { dg-begin-multiline-output "" }
129  extern int callee_7 (int one, int (*)(int, int), float three);
130                                ^~~~~~~~~~~~~~~~~
131      { dg-end-multiline-output "" } */
132 }
133