summaryrefslogtreecommitdiffstats
path: root/clang/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
commitc97d7a2c6a3ab6eb21bc7e1a8b3aabea7f78970d (patch)
treecc8c1a87591b6d0b3836df76dc522b49c2ee13ac /clang/test/SemaTemplate/temp_explicit.cpp
parentbb919dfb6bfe6c3f8b119a2341fb647f6d18a150 (diff)
downloadbcm5719-llvm-c97d7a2c6a3ab6eb21bc7e1a8b3aabea7f78970d.tar.gz
bcm5719-llvm-c97d7a2c6a3ab6eb21bc7e1a8b3aabea7f78970d.zip
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. llvm-svn: 103482
Diffstat (limited to 'clang/test/SemaTemplate/temp_explicit.cpp')
-rw-r--r--clang/test/SemaTemplate/temp_explicit.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/clang/test/SemaTemplate/temp_explicit.cpp b/clang/test/SemaTemplate/temp_explicit.cpp
index fbb41ff601a..76244c25e82 100644
--- a/clang/test/SemaTemplate/temp_explicit.cpp
+++ b/clang/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}}
+}
OpenPOWER on IntegriCloud