blob: f26931b55bdb09c7346fe39e6584e16f60d68275 [file] [log] [blame]
Richard Smith836de6b2016-12-19 23:59:34 +00001// 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 Carlsson6d417272009-11-14 21:45:58 +00003typedef const struct __CFString * CFStringRef;
4#define CFSTR __builtin___CFStringMakeConstantString
5
6void f() {
7 (void)CFStringRef(CFSTR("Hello"));
Daniel Dunbar8fbe78f2009-12-15 20:14:24 +00008}
Douglas Gregord3a59182010-02-12 05:48:04 +00009
10void a() { __builtin_va_list x, y; ::__builtin_va_copy(x, y); }
Eli Friedman34866c72012-08-31 00:14:07 +000011
12// <rdar://problem/10063539>
13template<int (*Compare)(const char *s1, const char *s2)>
14int equal(const char *s1, const char *s2) {
15 return Compare(s1, s2) == 0;
16}
17// FIXME: Our error recovery here sucks
18template 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
21void f2() {
22 __builtin_isnan; // expected-error {{builtin functions must be directly called}}
23}
Rafael Espindolac48f7342013-01-12 15:27:43 +000024
25// pr14895
26typedef __typeof(sizeof(int)) size_t;
27extern "C" void *__builtin_alloca (size_t);
Richard Smith6cbd65d2013-07-11 02:27:57 +000028
29namespace 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 Klecknercf8933d2013-11-13 22:47:22 +000042
43void 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 Smith836de6b2016-12-19 23:59:34 +000048
49struct FILE;
50extern "C" int vfprintf(FILE *__restrict, const char *__restrict,
51 __builtin_va_list va);
52
53void synchronize_args() {
54 __sync_synchronize(0); // expected-error {{too many arguments}}
55}