summaryrefslogtreecommitdiff
path: root/test/SemaTemplate/temp_explicit.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-05-11 17:39:34 +0000
committerDouglas Gregor <dgregor@apple.com>2010-05-11 17:39:34 +0000
commit2166beba8d939d2938c5401af2c8d3687afd5d8c (patch)
tree705463c93c0c35b62eec8cf8b747a5897fe0847e /test/SemaTemplate/temp_explicit.cpp
parent85bcd9920582f4d3879d8fbbaf4ca4fe09690160 (diff)
downloadclang-2166beba8d939d2938c5401af2c8d3687afd5d8c.tar.gz
The C++98/03 standard is disturbingly silent about out-of-scope
explicit instantiations of template. C++0x clarifies the intent (they're ill-formed in some cases; see [temp.explicit] for details). However, one could squint at the C++98/03 standard and conclude they are permitted, so reduce the error to a warning (controlled by -Wc++0x-compat) in C++98/03 mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103482 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaTemplate/temp_explicit.cpp')
-rw-r--r--test/SemaTemplate/temp_explicit.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/test/SemaTemplate/temp_explicit.cpp b/test/SemaTemplate/temp_explicit.cpp
index fbb41ff601..76244c25e8 100644
--- a/test/SemaTemplate/temp_explicit.cpp
+++ b/test/SemaTemplate/temp_explicit.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++0x-compat %s
//
// Tests explicit instantiation of templates.
template<typename T, typename U = T> class X0 { };
@@ -125,3 +125,27 @@ template <> // expected-warning{{extraneous template parameter list}}
template <>
struct Foo<int>::Bar<void>
{};
+
+namespace N1 {
+
+ template<typename T> struct X7 { }; // expected-note{{here}}
+
+ namespace Inner {
+ template<typename T> struct X8 { };
+ }
+
+ template struct X7<int>;
+ template struct Inner::X8<int>;
+}
+
+template<typename T> struct X9 { }; // expected-note{{here}}
+
+template struct ::N1::Inner::X8<float>;
+
+namespace N2 {
+ using namespace N1;
+
+ template struct X7<double>; // expected-warning{{must occur in namespace}}
+
+ template struct X9<float>; // expected-warning{{must occur in the global}}
+}