diff options
Diffstat (limited to 'test/CXX/drs/dr4xx.cpp')
-rw-r--r-- | test/CXX/drs/dr4xx.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/CXX/drs/dr4xx.cpp b/test/CXX/drs/dr4xx.cpp new file mode 100644 index 0000000..1d3b940 --- /dev/null +++ b/test/CXX/drs/dr4xx.cpp @@ -0,0 +1,32 @@ +// 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(); +} |