]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/c-c++-common/nonnull-2.c
c-decl.c (start_decl): Adjust quoting and hyphenation in diagnostics.
[thirdparty/gcc.git] / gcc / testsuite / c-c++-common / nonnull-2.c
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 {
10 if (cp1 == (char *) 0) /* { dg-warning "'nonnull' argument" "cp1 compared to NULL" } */
11 return 1;
12
13 cp1 = cp2;
14 if (cp1 == (char *) 0) /* { dg-bogus "'nonnull' argument" } */
15 return 2;
16
17 if (!cp4) /* { dg-bogus "'nonnull' argument" } */
18 return 3;
19
20 char **p = &cp3;
21 bar (p);
22 if (cp3 == (char *) 0) /* { dg-bogus "'nonnull' argument" } */
23 return 4;
24
25 return 5;
26 }