1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++11 2*f4a2713aSLionel Sambuc typedef const struct __CFString * CFStringRef; 3*f4a2713aSLionel Sambuc #define CFSTR __builtin___CFStringMakeConstantString 4*f4a2713aSLionel Sambuc f()5*f4a2713aSLionel Sambucvoid f() { 6*f4a2713aSLionel Sambuc (void)CFStringRef(CFSTR("Hello")); 7*f4a2713aSLionel Sambuc } 8*f4a2713aSLionel Sambuc a()9*f4a2713aSLionel Sambucvoid a() { __builtin_va_list x, y; ::__builtin_va_copy(x, y); } 10*f4a2713aSLionel Sambuc 11*f4a2713aSLionel Sambuc // <rdar://problem/10063539> 12*f4a2713aSLionel Sambuc template<int (*Compare)(const char *s1, const char *s2)> equal(const char * s1,const char * s2)13*f4a2713aSLionel Sambucint equal(const char *s1, const char *s2) { 14*f4a2713aSLionel Sambuc return Compare(s1, s2) == 0; 15*f4a2713aSLionel Sambuc } 16*f4a2713aSLionel Sambuc // FIXME: Our error recovery here sucks 17*f4a2713aSLionel Sambuc template int equal<&__builtin_strcmp>(const char*, const char*); // expected-error {{builtin functions must be directly called}} expected-error {{expected unqualified-id}} expected-error {{expected ')'}} expected-note {{to match this '('}} 18*f4a2713aSLionel Sambuc 19*f4a2713aSLionel Sambuc // PR13195 f2()20*f4a2713aSLionel Sambucvoid f2() { 21*f4a2713aSLionel Sambuc __builtin_isnan; // expected-error {{builtin functions must be directly called}} 22*f4a2713aSLionel Sambuc } 23*f4a2713aSLionel Sambuc 24*f4a2713aSLionel Sambuc // pr14895 25*f4a2713aSLionel Sambuc typedef __typeof(sizeof(int)) size_t; 26*f4a2713aSLionel Sambuc extern "C" void *__builtin_alloca (size_t); 27*f4a2713aSLionel Sambuc 28*f4a2713aSLionel Sambuc namespace addressof { 29*f4a2713aSLionel Sambuc struct S {} s; 30*f4a2713aSLionel Sambuc static_assert(__builtin_addressof(s) == &s, ""); 31*f4a2713aSLionel Sambuc operator &addressof::T32*f4a2713aSLionel Sambuc struct T { constexpr T *operator&() const { return nullptr; } int n; } t; 33*f4a2713aSLionel Sambuc constexpr T *pt = __builtin_addressof(t); 34*f4a2713aSLionel Sambuc static_assert(&pt->n == &t.n, ""); 35*f4a2713aSLionel Sambuc 36*f4a2713aSLionel Sambuc struct U { int n : 5; } u; 37*f4a2713aSLionel Sambuc int *pbf = __builtin_addressof(u.n); // expected-error {{address of bit-field requested}} 38*f4a2713aSLionel Sambuc 39*f4a2713aSLionel Sambuc S *ptmp = __builtin_addressof(S{}); // expected-error {{taking the address of a temporary}} 40*f4a2713aSLionel Sambuc } 41*f4a2713aSLionel Sambuc no_ms_builtins()42*f4a2713aSLionel Sambucvoid no_ms_builtins() { 43*f4a2713aSLionel Sambuc __assume(1); // expected-error {{use of undeclared}} 44*f4a2713aSLionel Sambuc __noop(1); // expected-error {{use of undeclared}} 45*f4a2713aSLionel Sambuc __debugbreak(); // expected-error {{use of undeclared}} 46*f4a2713aSLionel Sambuc } 47