diff options
| author | Nico Weber <nicolasweber@gmx.de> | 2014-04-29 01:19:21 +0000 |
|---|---|---|
| committer | Nico Weber <nicolasweber@gmx.de> | 2014-04-29 01:19:21 +0000 |
| commit | 8af28c1e61aacf4eeafea59ca478908fc314b48e (patch) | |
| tree | 91097771d5593d923f688b27f4e7d2681fbdc8c9 /clang/test | |
| parent | 326254f422334c5fdd6e9196b35aceeb77afae5b (diff) | |
| download | bcm5719-llvm-8af28c1e61aacf4eeafea59ca478908fc314b48e.tar.gz bcm5719-llvm-8af28c1e61aacf4eeafea59ca478908fc314b48e.zip | |
Let stddef.h redefine NULL if __need_NULL is set, as needed by glibc, PR12997.
See the bug and the cfe-commits thread "[patch] Let stddef.h redefine NULL if
__need_NULL is set" for discussion.
Fixes PR12997 and is similar to the __need_wint_t bits already in this file.
llvm-svn: 207482
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Headers/needsnull.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/test/Headers/needsnull.cpp b/clang/test/Headers/needsnull.cpp new file mode 100644 index 00000000000..267cb5ddc31 --- /dev/null +++ b/clang/test/Headers/needsnull.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -fsyntax-only -triple i386-linux-gnu -verify -Wsentinel %s +// expected-no-diagnostics + +#include <stddef.h> + +// linux/stddef.h does something like this for cpp files: +#undef NULL +#define NULL 0 + +// glibc (and other) headers then define __need_NULL and rely on stddef.h +// to redefine NULL to the correct value again. +#define __need_NULL +#include <stddef.h> + +// gtk headers then use __attribute__((sentinel)), which doesn't work if NULL +// is 0. +void f(const char* c, ...) __attribute__((sentinel)); +void g() { + f("", NULL); // Shouldn't warn. +} |

