1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.9.0 -verify -Wsentinel -std=c++11 %s 2*0a6a1f1dSLionel Sambuc 3*0a6a1f1dSLionel Sambuc ptrdiff_t p0; // expected-error{{unknown}} 4*0a6a1f1dSLionel Sambuc size_t s0; // expected-error{{unknown}} 5*0a6a1f1dSLionel Sambuc void* v0 = NULL; // expected-error{{undeclared}} 6*0a6a1f1dSLionel Sambuc wint_t w0; // expected-error{{unknown}} 7*0a6a1f1dSLionel Sambuc max_align_t m0; // expected-error{{unknown}} 8*0a6a1f1dSLionel Sambuc 9*0a6a1f1dSLionel Sambuc #define __need_ptrdiff_t 10*0a6a1f1dSLionel Sambuc #include <stddef.h> 11*0a6a1f1dSLionel Sambuc 12*0a6a1f1dSLionel Sambuc ptrdiff_t p1; 13*0a6a1f1dSLionel Sambuc size_t s1; // expected-error{{unknown}} 14*0a6a1f1dSLionel Sambuc void* v1 = NULL; // expected-error{{undeclared}} 15*0a6a1f1dSLionel Sambuc wint_t w1; // expected-error{{unknown}} 16*0a6a1f1dSLionel Sambuc max_align_t m1; // expected-error{{unknown}} 17*0a6a1f1dSLionel Sambuc 18*0a6a1f1dSLionel Sambuc #define __need_size_t 19*0a6a1f1dSLionel Sambuc #include <stddef.h> 20*0a6a1f1dSLionel Sambuc 21*0a6a1f1dSLionel Sambuc ptrdiff_t p2; 22*0a6a1f1dSLionel Sambuc size_t s2; 23*0a6a1f1dSLionel Sambuc void* v2 = NULL; // expected-error{{undeclared}} 24*0a6a1f1dSLionel Sambuc wint_t w2; // expected-error{{unknown}} 25*0a6a1f1dSLionel Sambuc max_align_t m2; // expected-error{{unknown}} 26*0a6a1f1dSLionel Sambuc 27*0a6a1f1dSLionel Sambuc #define __need_NULL 28*0a6a1f1dSLionel Sambuc #include <stddef.h> 29*0a6a1f1dSLionel Sambuc 30*0a6a1f1dSLionel Sambuc ptrdiff_t p3; 31*0a6a1f1dSLionel Sambuc size_t s3; 32*0a6a1f1dSLionel Sambuc void* v3 = NULL; 33*0a6a1f1dSLionel Sambuc wint_t w3; // expected-error{{unknown}} 34*0a6a1f1dSLionel Sambuc max_align_t m3; // expected-error{{unknown}} 35*0a6a1f1dSLionel Sambuc 36*0a6a1f1dSLionel Sambuc // Shouldn't bring in wint_t by default: 37*0a6a1f1dSLionel Sambuc #include <stddef.h> 38*0a6a1f1dSLionel Sambuc 39*0a6a1f1dSLionel Sambuc ptrdiff_t p4; 40*0a6a1f1dSLionel Sambuc size_t s4; 41*0a6a1f1dSLionel Sambuc void* v4 = NULL; 42*0a6a1f1dSLionel Sambuc wint_t w4; // expected-error{{unknown}} 43*0a6a1f1dSLionel Sambuc max_align_t m4; 44*0a6a1f1dSLionel Sambuc 45*0a6a1f1dSLionel Sambuc #define __need_wint_t 46*0a6a1f1dSLionel Sambuc #include <stddef.h> 47*0a6a1f1dSLionel Sambuc 48*0a6a1f1dSLionel Sambuc ptrdiff_t p5; 49*0a6a1f1dSLionel Sambuc size_t s5; 50*0a6a1f1dSLionel Sambuc void* v5 = NULL; 51*0a6a1f1dSLionel Sambuc wint_t w5; 52*0a6a1f1dSLionel Sambuc max_align_t m5; 53*0a6a1f1dSLionel Sambuc 54*0a6a1f1dSLionel Sambuc 55*0a6a1f1dSLionel Sambuc // linux/stddef.h does something like this for cpp files: 56*0a6a1f1dSLionel Sambuc #undef NULL 57*0a6a1f1dSLionel Sambuc #define NULL 0 58*0a6a1f1dSLionel Sambuc 59*0a6a1f1dSLionel Sambuc // glibc (and other) headers then define __need_NULL and rely on stddef.h 60*0a6a1f1dSLionel Sambuc // to redefine NULL to the correct value again. 61*0a6a1f1dSLionel Sambuc #define __need_NULL 62*0a6a1f1dSLionel Sambuc #include <stddef.h> 63*0a6a1f1dSLionel Sambuc 64*0a6a1f1dSLionel Sambuc // gtk headers then use __attribute__((sentinel)), which doesn't work if NULL 65*0a6a1f1dSLionel Sambuc // is 0. 66*0a6a1f1dSLionel Sambuc void f(const char* c, ...) __attribute__((sentinel)); g()67*0a6a1f1dSLionel Sambucvoid g() { 68*0a6a1f1dSLionel Sambuc f("", NULL); // Shouldn't warn. 69*0a6a1f1dSLionel Sambuc } 70