xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/nonnull.c (revision 0b98e8aad89f2bd4ba80b523d73cf29e9dd82ce1)
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // rdar://9584012
3 
4 typedef struct {
5 	char *str;
6 } Class;
7 
8 typedef union {
9 	Class *object;
10 } Instance __attribute__((transparent_union));
11 
12 __attribute__((nonnull(1))) void Class_init(Instance this, char *str) {
13 	this.object->str = str;
14 }
15 
16 int main(void) {
17 	Class *obj;
18 	Class_init(0, "Hello World"); // expected-warning {{null passed to a callee which requires a non-null argument}}
19 	Class_init(obj, "Hello World");
20 }
21 
22 void foo(const char *str) __attribute__((nonnull("foo"))); // expected-error{{'nonnull' attribute requires parameter 1 to be an integer constant}}
23