diff options
author | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
commit | 1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch) | |
tree | c607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/gcc.dg/nonnull-1.c | |
parent | 283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff) | |
download | toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2 toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip |
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.dg/nonnull-1.c')
-rw-r--r-- | gcc-4.9/gcc/testsuite/gcc.dg/nonnull-1.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/nonnull-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/nonnull-1.c new file mode 100644 index 000000000..51a8a3373 --- /dev/null +++ b/gcc-4.9/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" } */ +} |