111
|
1 /* Test for the bad usage of "nonnull" function attribute parms. */
|
|
2 /* { dg-do compile } */
|
|
3 /* { dg-options "-Wnonnull-compare" } */
|
|
4
|
|
5 void bar (char **);
|
|
6
|
|
7 __attribute__((nonnull (1, 3))) int
|
|
8 foo (char *cp1, char *cp2, char *cp3, char *cp4)
|
|
9 {
|
145
|
10 if (cp1 == (char *) 0) /* { dg-warning "'nonnull' argument" "cp1 compared to NULL" } */
|
111
|
11 return 1;
|
|
12
|
|
13 cp1 = cp2;
|
145
|
14 if (cp1 == (char *) 0) /* { dg-bogus "'nonnull' argument" } */
|
111
|
15 return 2;
|
|
16
|
145
|
17 if (!cp4) /* { dg-bogus "'nonnull' argument" } */
|
111
|
18 return 3;
|
|
19
|
|
20 char **p = &cp3;
|
|
21 bar (p);
|
145
|
22 if (cp3 == (char *) 0) /* { dg-bogus "'nonnull' argument" } */
|
111
|
23 return 4;
|
|
24
|
|
25 return 5;
|
|
26 }
|