Richard Smith | 836de6b | 2016-12-19 23:59:34 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++11 -fcxx-exceptions |
| 2 | // RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++1z -fcxx-exceptions |
Anders Carlsson | 6d41727 | 2009-11-14 21:45:58 +0000 | [diff] [blame] | 3 | typedef const struct __CFString * CFStringRef; |
| 4 | #define CFSTR __builtin___CFStringMakeConstantString |
| 5 | |
| 6 | void f() { |
| 7 | (void)CFStringRef(CFSTR("Hello")); |
Daniel Dunbar | 8fbe78f | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 8 | } |
Douglas Gregor | d3a5918 | 2010-02-12 05:48:04 +0000 | [diff] [blame] | 9 | |
| 10 | void a() { __builtin_va_list x, y; ::__builtin_va_copy(x, y); } |
Eli Friedman | 34866c7 | 2012-08-31 00:14:07 +0000 | [diff] [blame] | 11 | |
| 12 | // <rdar://problem/10063539> |
| 13 | template<int (*Compare)(const char *s1, const char *s2)> |
| 14 | int equal(const char *s1, const char *s2) { |
| 15 | return Compare(s1, s2) == 0; |
| 16 | } |
| 17 | // FIXME: Our error recovery here sucks |
| 18 | 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 '('}} |
| 19 | |
| 20 | // PR13195 |
| 21 | void f2() { |
| 22 | __builtin_isnan; // expected-error {{builtin functions must be directly called}} |
| 23 | } |
Rafael Espindola | c48f734 | 2013-01-12 15:27:43 +0000 | [diff] [blame] | 24 | |
| 25 | // pr14895 |
| 26 | typedef __typeof(sizeof(int)) size_t; |
| 27 | extern "C" void *__builtin_alloca (size_t); |
Richard Smith | 6cbd65d | 2013-07-11 02:27:57 +0000 | [diff] [blame] | 28 | |
| 29 | namespace addressof { |
| 30 | struct S {} s; |
| 31 | static_assert(__builtin_addressof(s) == &s, ""); |
| 32 | |
| 33 | struct T { constexpr T *operator&() const { return nullptr; } int n; } t; |
| 34 | constexpr T *pt = __builtin_addressof(t); |
| 35 | static_assert(&pt->n == &t.n, ""); |
| 36 | |
| 37 | struct U { int n : 5; } u; |
| 38 | int *pbf = __builtin_addressof(u.n); // expected-error {{address of bit-field requested}} |
| 39 | |
| 40 | S *ptmp = __builtin_addressof(S{}); // expected-error {{taking the address of a temporary}} |
| 41 | } |
Reid Kleckner | cf8933d | 2013-11-13 22:47:22 +0000 | [diff] [blame] | 42 | |
| 43 | void no_ms_builtins() { |
| 44 | __assume(1); // expected-error {{use of undeclared}} |
| 45 | __noop(1); // expected-error {{use of undeclared}} |
| 46 | __debugbreak(); // expected-error {{use of undeclared}} |
| 47 | } |
Richard Smith | 836de6b | 2016-12-19 23:59:34 +0000 | [diff] [blame] | 48 | |
| 49 | struct FILE; |
| 50 | extern "C" int vfprintf(FILE *__restrict, const char *__restrict, |
| 51 | __builtin_va_list va); |
| 52 | |
| 53 | void synchronize_args() { |
| 54 | __sync_synchronize(0); // expected-error {{too many arguments}} |
| 55 | } |