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