minix/external/bsd/llvm/dist/clang/test/CXX/drs/dr4xx.cpp

33 lines
897 B
C++
Raw Normal View History

// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// expected-no-diagnostics
namespace dr408 { // dr408: 3.4
template<int N> void g() { int arr[N != 1 ? 1 : -1]; }
template<> void g<2>() { }
template<typename T> struct S {
static int i[];
void f();
};
template<typename T> int S<T>::i[] = { 1 };
template<typename T> void S<T>::f() {
g<sizeof (i) / sizeof (int)>();
}
template<> int S<int>::i[] = { 1, 2 };
template void S<int>::f(); // uses g<2>(), not g<1>().
template<typename T> struct R {
static int arr[];
void f();
};
template<typename T> int R<T>::arr[1];
template<typename T> void R<T>::f() {
int arr[sizeof(arr) != sizeof(int) ? 1 : -1];
}
template<> int R<int>::arr[2];
template void R<int>::f();
}