diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.dg/nonnull-1.c | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.dg/nonnull-1.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/nonnull-1.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/nonnull-1.c b/gcc/testsuite/gcc.dg/nonnull-1.c new file mode 100644 index 000000000..51a8a3373 --- /dev/null +++ b/gcc/testsuite/gcc.dg/nonnull-1.c @@ -0,0 +1,39 @@ +/* Test for the "nonnull" function attribute. */ +/* Origin: Jason Thorpe <thorpej@wasabisystems.com> */ +/* { dg-do compile } */ +/* { dg-options "-Wnonnull" } */ + +#include <stddef.h> + +extern void func1 (char *, char *, int) __attribute__((nonnull)); + +extern void func2 (char *, char *) __attribute__((nonnull(1))); + +extern void func3 (char *, int, char *, int) + __attribute__((nonnull(1,3))); + +extern void func4 (char *, char *) __attribute__((nonnull(1))) + __attribute__((nonnull(2))); + +void +foo (int i1, int i2, int i3, char *cp1, char *cp2, char *cp3) +{ + func1(cp1, cp2, i1); + + func1(NULL, cp2, i1); /* { dg-warning "null" "null with argless nonnull 1" } */ + func1(cp1, NULL, i1); /* { dg-warning "null" "null with argless nonnull 2" } */ + func1(cp1, cp2, 0); + + func2(cp1, NULL); + func2(NULL, cp1); /* { dg-warning "null" "null with single explicit nonnull" } */ + + func3(NULL, i2, cp3, i3); /* { dg-warning "null" "null with explicit nonnull 1" } */ + func3(cp3, i2, NULL, i3); /* { dg-warning "null" "null with explicit nonnull 3" } */ + + func1(i1 ? cp1 : NULL, cp2, i3); /* { dg-warning "null" "null with cond expr rhs" } */ + func1(i1 ? NULL : cp1, cp2, i3); /* { dg-warning "null" "null with cond expr lhs" } */ + func1(i1 ? (i2 ? cp1 : NULL) : cp2, cp3, i3); /* { dg-warning "null" "null with nested cond expr" } */ + + func4(NULL, cp1); /* { dg-warning "null" "null with multiple attributes 1" } */ + func4(cp1, NULL); /* { dg-warning "null" "null with multiple attributes 2" } */ +} |