Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / Headers / stddefneeds.cpp
blob0282e8afa600d62251b9cbc210d592027e713bd2
1 // RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.9.0 -verify -Wsentinel -std=c++11 %s
3 ptrdiff_t p0; // expected-error{{unknown}}
4 size_t s0; // expected-error{{unknown}}
5 void* v0 = NULL; // expected-error{{undeclared}}
6 wint_t w0; // expected-error{{unknown}}
7 max_align_t m0; // expected-error{{unknown}}
9 #define __need_ptrdiff_t
10 #include <stddef.h>
12 ptrdiff_t p1;
13 size_t s1; // expected-error{{unknown}}
14 void* v1 = NULL; // expected-error{{undeclared}}
15 wint_t w1; // expected-error{{unknown}}
16 max_align_t m1; // expected-error{{unknown}}
18 #define __need_size_t
19 #include <stddef.h>
21 ptrdiff_t p2;
22 size_t s2;
23 void* v2 = NULL; // expected-error{{undeclared}}
24 wint_t w2; // expected-error{{unknown}}
25 max_align_t m2; // expected-error{{unknown}}
27 #define __need_NULL
28 #include <stddef.h>
30 ptrdiff_t p3;
31 size_t s3;
32 void* v3 = NULL;
33 wint_t w3; // expected-error{{unknown}}
34 max_align_t m3; // expected-error{{unknown}}
36 // Shouldn't bring in wint_t by default:
37 #include <stddef.h>
39 ptrdiff_t p4;
40 size_t s4;
41 void* v4 = NULL;
42 wint_t w4; // expected-error{{unknown}}
43 max_align_t m4;
45 #define __need_wint_t
46 #include <stddef.h>
48 ptrdiff_t p5;
49 size_t s5;
50 void* v5 = NULL;
51 wint_t w5;
52 max_align_t m5;
55 // linux/stddef.h does something like this for cpp files:
56 #undef NULL
57 #define NULL 0
59 // Including stddef.h again shouldn't redefine NULL
60 #include <stddef.h>
62 // gtk headers then use __attribute__((sentinel)), which doesn't work if NULL
63 // is 0.
64 void f(const char* c, ...) __attribute__((sentinel)); // expected-note{{function has been explicitly marked sentinel here}}
65 void g() {
66 f("", NULL); // expected-warning{{missing sentinel in function call}}
69 // glibc (and other) headers then define __need_NULL and rely on stddef.h
70 // to redefine NULL to the correct value again.
71 #define __need_NULL
72 #include <stddef.h>
74 void h() {
75 f("", NULL); // Shouldn't warn.