2013-07-11 10:27:57 +08:00
// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++11
2009-11-15 05:45:58 +08:00
typedef const struct __CFString * CFStringRef ;
# define CFSTR __builtin___CFStringMakeConstantString
void f ( ) {
( void ) CFStringRef ( CFSTR ( " Hello " ) ) ;
2009-12-16 04:14:24 +08:00
}
2010-02-12 13:48:04 +08:00
void a ( ) { __builtin_va_list x , y ; : : __builtin_va_copy ( x , y ) ; }
2012-08-31 08:14:07 +08:00
// <rdar://problem/10063539>
template < int ( * Compare ) ( const char * s1 , const char * s2 ) >
int equal ( const char * s1 , const char * s2 ) {
return Compare ( s1 , s2 ) = = 0 ;
}
// FIXME: Our error recovery here sucks
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 '('}}
// PR13195
void f2 ( ) {
__builtin_isnan ; // expected-error {{builtin functions must be directly called}}
}
2013-01-12 23:27:43 +08:00
// pr14895
typedef __typeof ( sizeof ( int ) ) size_t ;
extern " C " void * __builtin_alloca ( size_t ) ;
2013-07-11 10:27:57 +08:00
namespace addressof {
struct S { } s ;
static_assert ( __builtin_addressof ( s ) = = & s , " " ) ;
struct T { constexpr T * operator & ( ) const { return nullptr ; } int n ; } t ;
constexpr T * pt = __builtin_addressof ( t ) ;
static_assert ( & pt - > n = = & t . n , " " ) ;
struct U { int n : 5 ; } u ;
int * pbf = __builtin_addressof ( u . n ) ; // expected-error {{address of bit-field requested}}
S * ptmp = __builtin_addressof ( S { } ) ; // expected-error {{taking the address of a temporary}}
}
2013-11-14 06:47:22 +08:00
void no_ms_builtins ( ) {
__assume ( 1 ) ; // expected-error {{use of undeclared}}
__noop ( 1 ) ; // expected-error {{use of undeclared}}
__debugbreak ( ) ; // expected-error {{use of undeclared}}
}