[cfe-commits] r112565 - in /cfe/trunk: lib/Sema/SemaTemplate.cpp test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Mon Aug 30 17:36:40 PDT 2010
Author: cornedbee
Date: Mon Aug 30 19:36:40 2010
New Revision: 112565
URL: http://llvm.org/viewvc/llvm-project?rev=112565&view=rev
Log:
Add a forgotten place where the enclosing namespace set matters, plus a big testcase for inline namespace fun.
Added:
cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=112565&r1=112564&r2=112565&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon Aug 30 19:36:40 2010
@@ -3440,8 +3440,8 @@
getTemplateSpecializationKind(PrevDecl) == TSK_ImplicitInstantiation)){
// There is no prior declaration of this entity, so this
// specialization must be in the same context as the template
- // itself.
- if (!DC->Equals(SpecializedContext)) {
+ // itself, or in the enclosing namespace set.
+ if (!DC->InEnclosingNamespaceSetOf(SpecializedContext)) {
if (isa<TranslationUnitDecl>(SpecializedContext))
S.Diag(Loc, diag::err_template_spec_decl_out_of_scope_global)
<< EntityKind << Specialized;
Added: cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp?rev=112565&view=auto
==============================================================================
--- cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp (added)
+++ cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp Mon Aug 30 19:36:40 2010
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+// Fun things you can do with inline namespaces:
+
+inline namespace X {
+ void f1();
+
+ inline namespace Y {
+ void f2();
+
+ template <typename T> class C {};
+ }
+
+ // Specialize and partially specialize somewhere else.
+ template <> class C<int> {};
+ template <typename T> class C<T*> {};
+}
+
+// Qualified and unqualified lookup as if member of enclosing NS.
+void foo1() {
+ f1();
+ ::f1();
+ X::f1();
+ Y::f1(); // expected-error {{no member named 'f1' in namespace 'X::Y'}}
+
+ f2();
+ ::f2();
+ X::f2();
+ Y::f2();
+}
+
+template <> class C<float> {};
+template <typename T> class C<T&> {};
+
+template class C<double>;
+
+
+// As well as all the fun with ADL.
+
+namespace ADL {
+ struct Outer {};
+
+ inline namespace IL {
+ struct Inner {};
+
+ void fo(Outer);
+ }
+
+ void fi(Inner);
+
+ inline namespace IL2 {
+ void fi2(Inner);
+ }
+}
+
+void foo2() {
+ ADL::Outer o;
+ ADL::Inner i;
+ fo(o);
+ fi(i);
+ fi2(i);
+}
+
+// Let's not forget overload sets.
+struct Distinct {};
+inline namespace Over {
+ void over(Distinct);
+}
+void over(int);
+
+void foo3() {
+ Distinct d;
+ ::over(d);
+}
More information about the cfe-commits
mailing list