2011-10-18 13:54:07 +08:00
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wc++11-compat -verify %s
2011-10-12 01:38:48 +08:00
namespace N {
2011-10-18 10:28:33 +08:00
template < typename T > void f ( T ) { } // expected-note 2{{here}}
2011-10-12 01:38:48 +08:00
namespace M {
2011-10-18 10:28:33 +08:00
template void : : N : : f < int > ( int ) ; // expected-warning {{explicit instantiation of 'f' not in a namespace enclosing 'N'}}
2011-10-12 01:38:48 +08:00
}
}
2011-10-18 10:28:33 +08:00
using namespace N ;
template void f < char > ( char ) ; // expected-warning {{explicit instantiation of 'N::f' must occur in namespace 'N'}}
2011-10-12 01:38:48 +08:00
2011-10-18 10:28:33 +08:00
template < typename T > void g ( T ) { } // expected-note 2{{here}}
2011-10-12 01:38:48 +08:00
namespace M {
2011-10-18 10:28:33 +08:00
template void g < int > ( int ) ; // expected-warning {{explicit instantiation of 'g' must occur at global scope}}
template void : : g < char > ( char ) ; // expected-warning {{explicit instantiation of 'g' must occur at global scope}}
2011-10-12 01:38:48 +08:00
}
2011-10-18 11:44:03 +08:00
template inline void g < double > ( double ) ; // expected-warning {{explicit instantiation cannot be 'inline'}}
2011-10-18 10:28:33 +08:00
void g ( ) {
2011-10-13 03:26:40 +08:00
auto int n = 0 ; // expected-warning {{'auto' storage class specifier is redundant and incompatible with C++11}}
2011-10-12 01:38:48 +08:00
}
int n ;
struct S {
char c ;
}
2011-10-13 03:26:40 +08:00
s = { n } , // expected-warning {{non-constant-expression cannot be narrowed from type 'int' to 'char' in initializer list in C++11}} expected-note {{explicit cast}}
t = { 1234 } ; // expected-warning {{constant expression evaluates to 1234 which cannot be narrowed to type 'char' in C++11}} expected-warning {{changes value}} expected-note {{explicit cast}}
2012-03-07 11:13:00 +08:00
# define PRIuS "uS"
int printf ( const char * , . . . ) ;
typedef __typeof ( sizeof ( int ) ) size_t ;
void h ( size_t foo , size_t bar ) {
2012-03-08 10:39:21 +08:00
printf ( " foo is % " PRIuS " , bar is % " PRIuS , foo , bar ) ; // expected-warning 2{{identifier after literal will be treated as a reserved user-defined literal suffix in C++11}}
2012-03-07 11:13:00 +08:00
}
2012-03-08 10:39:21 +08:00
# define _x + 1
char c = ' x ' _x ; // expected-warning {{will be treated as a user-defined literal suffix}}