1 /* Test for the bad usage of "nonnull" function attribute parms. */
3 /* { dg-do compile } */
4 /* { dg-options "-Wnonnull-compare" } */
9 void foo(void *bar
) __attribute__((nonnull(1)));
11 void foo(void *bar
) { if (!bar
) abort(); } /* { dg-warning "nonnull argument" "bar compared to NULL" } */
13 extern int func (char *, char *, char *, char *) __attribute__((nonnull
));
16 func (char *cp1
, char *cp2
, char *cp3
, char *cp4
)
18 if (cp1
) /* { dg-warning "nonnull argument" "cp1 compared to NULL" } */
21 if (cp2
== NULL
) /* { dg-warning "nonnull argument" "cp2 compared to NULL" } */
24 if (NULL
!= cp3
) /* { dg-warning "nonnull argument" "cp3 compared to NULL" } */
27 return cp4
!= 0 ? 0 : 1; /* { dg-warning "nonnull argument" "cp4 compared to NULL" } */
30 __attribute__((nonnull (1))) int
33 return (cp
!= NULL
) ? 1 : 0; /* { dg-warning "nonnull argument" "cp compared to NULL" { xfail c++ } } */