Fix warning with -Wsign-compare -Wsystem-headers
[official-gcc.git] / gcc / testsuite / gcc.dg / bad-binary-ops.c
blob46c158e6a5f6780f2edcc8b34ae5dda120937ee5
1 /* { dg-options "-fdiagnostics-show-caret" } */
3 /* Adapted from https://gcc.gnu.org/wiki/ClangDiagnosticsComparison */
5 typedef float __m128;
6 void test_1 ()
8 __m128 myvec[2];
9 int const *ptr;
10 myvec[1]/ptr; /* { dg-error "invalid operands to binary /" } */
12 /* TODO: ideally we'd underline "ptr" as well.
13 { dg-begin-multiline-output "" }
14 myvec[1]/ptr;
15 ~~~~~~~~^
17 __m128
18 { dg-end-multiline-output "" } */
23 struct s {};
24 struct t {};
25 extern struct s some_function (void);
26 extern struct t some_other_function (void);
28 int test_2 (void)
30 return (some_function ()
31 + some_other_function ()); /* { dg-error "invalid operands to binary \+" } */
33 /* { dg-begin-multiline-output "" }
34 return (some_function ()
35 ~~~~~~~~~~~~~~~~
37 struct s
38 + some_other_function ());
39 ^ ~~~~~~~~~~~~~~~~~~~~~~
41 struct t
42 { dg-end-multiline-output "" } */
45 int test_3 (struct s param_s, struct t param_t)
47 return param_s + param_t; // { dg-error "invalid operands to binary \+" }
49 /* { dg-begin-multiline-output "" }
50 return param_s + param_t;
52 { dg-end-multiline-output "" } */
53 /* TODO: ideally we'd underline both params here. */
56 typedef struct s S;
57 typedef struct t T;
59 extern S callee_4a (void);
60 extern T callee_4b (void);
62 int test_4 (void)
64 return callee_4a () + callee_4b (); /* { dg-error "invalid operands to binary \+" } */
66 /* { dg-begin-multiline-output "" }
67 return callee_4a () + callee_4b ();
68 ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
69 | |
70 | T {aka struct t}
71 S {aka struct s}
72 { dg-end-multiline-output "" } */