Home | History | Annotate | Download | only in Headers
      1 // RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.9.0 -verify -Wsentinel -std=c++11 %s
      2 
      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}}
      8 
      9 #define __need_ptrdiff_t
     10 #include <stddef.h>
     11 
     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}}
     17 
     18 #define __need_size_t
     19 #include <stddef.h>
     20 
     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}}
     26 
     27 #define __need_NULL
     28 #include <stddef.h>
     29 
     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}}
     35 
     36 // Shouldn't bring in wint_t by default:
     37 #include <stddef.h>
     38 
     39 ptrdiff_t p4;
     40 size_t s4;
     41 void* v4 = NULL;
     42 wint_t w4; // expected-error{{unknown}}
     43 max_align_t m4;
     44 
     45 #define __need_wint_t
     46 #include <stddef.h>
     47 
     48 ptrdiff_t p5;
     49 size_t s5;
     50 void* v5 = NULL;
     51 wint_t w5;
     52 max_align_t m5;
     53 
     54 
     55 // linux/stddef.h does something like this for cpp files:
     56 #undef NULL
     57 #define NULL 0
     58 
     59 // glibc (and other) headers then define __need_NULL and rely on stddef.h
     60 // to redefine NULL to the correct value again.
     61 #define __need_NULL
     62 #include <stddef.h>
     63 
     64 // gtk headers then use __attribute__((sentinel)), which doesn't work if NULL
     65 // is 0.
     66 void f(const char* c, ...) __attribute__((sentinel));
     67 void g() {
     68   f("", NULL);  // Shouldn't warn.
     69 }
     70