blob: 69bdfa6145170d5bfff3d00d0d568fb68b143f29 [file] [log] [blame]
Richard Smith6cbd65d2013-07-11 02:27:57 +00001// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++11
Anders Carlsson6d417272009-11-14 21:45:58 +00002typedef const struct __CFString * CFStringRef;
3#define CFSTR __builtin___CFStringMakeConstantString
4
5void f() {
6 (void)CFStringRef(CFSTR("Hello"));
Daniel Dunbar8fbe78f2009-12-15 20:14:24 +00007}
Douglas Gregord3a59182010-02-12 05:48:04 +00008
9void a() { __builtin_va_list x, y; ::__builtin_va_copy(x, y); }
Eli Friedman34866c72012-08-31 00:14:07 +000010
11// <rdar://problem/10063539>
12template<int (*Compare)(const char *s1, const char *s2)>
13int equal(const char *s1, const char *s2) {
14 return Compare(s1, s2) == 0;
15}
16// FIXME: Our error recovery here sucks
17template 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
20void f2() {
21 __builtin_isnan; // expected-error {{builtin functions must be directly called}}
22}
Rafael Espindolac48f7342013-01-12 15:27:43 +000023
24// pr14895
25typedef __typeof(sizeof(int)) size_t;
26extern "C" void *__builtin_alloca (size_t);
Richard Smith6cbd65d2013-07-11 02:27:57 +000027
28namespace 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 Klecknercf8933d2013-11-13 22:47:22 +000041
42void 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}