Richard Smith | 6cbd65d | 2013-07-11 02:27:57 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++11 |
Anders Carlsson | 6d41727 | 2009-11-14 21:45:58 +0000 | [diff] [blame] | 2 | typedef const struct __CFString * CFStringRef; |
| 3 | #define CFSTR __builtin___CFStringMakeConstantString |
| 4 | |
| 5 | void f() { |
| 6 | (void)CFStringRef(CFSTR("Hello")); |
Daniel Dunbar | 8fbe78f | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 7 | } |
Douglas Gregor | d3a5918 | 2010-02-12 05:48:04 +0000 | [diff] [blame] | 8 | |
| 9 | void a() { __builtin_va_list x, y; ::__builtin_va_copy(x, y); } |
Eli Friedman | 34866c7 | 2012-08-31 00:14:07 +0000 | [diff] [blame] | 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 | } |
Rafael Espindola | c48f734 | 2013-01-12 15:27:43 +0000 | [diff] [blame] | 23 | |
| 24 | // pr14895 |
| 25 | typedef __typeof(sizeof(int)) size_t; |
| 26 | extern "C" void *__builtin_alloca (size_t); |
Richard Smith | 6cbd65d | 2013-07-11 02:27:57 +0000 | [diff] [blame] | 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 | } |
Reid Kleckner | cf8933d | 2013-11-13 22:47:22 +0000 | [diff] [blame] | 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 | } |