r265571 - Diagnose template alias declarations in local classes.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 6 10:39:00 PDT 2016
Author: rsmith
Date: Wed Apr 6 12:38:58 2016
New Revision: 265571
URL: http://llvm.org/viewvc/llvm-project?rev=265571&view=rev
Log:
Diagnose template alias declarations in local classes.
Patch by Erik Pilkington!
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CXX/temp/temp.decls/temp.mem/p2.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=265571&r1=265570&r2=265571&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Apr 6 12:38:58 2016
@@ -8585,6 +8585,10 @@ Decl *Sema::ActOnAliasDeclaration(Scope
}
TemplateParameterList *TemplateParams = TemplateParamLists[0];
+ // Check that we can declare a template here.
+ if (CheckTemplateDeclScope(S, TemplateParams))
+ return nullptr;
+
// Only consider previous declarations in the same scope.
FilterLookupForScope(Previous, CurContext, S, /*ConsiderLinkage*/false,
/*ExplicitInstantiationOrSpecialization*/false);
Modified: cfe/trunk/test/CXX/temp/temp.decls/temp.mem/p2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.decls/temp.mem/p2.cpp?rev=265571&r1=265570&r2=265571&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.decls/temp.mem/p2.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.decls/temp.mem/p2.cpp Wed Apr 6 12:38:58 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
template <typename>
void quux();
@@ -8,5 +8,7 @@ void fun() {
template <typename> struct bar {}; // expected-error{{templates cannot be declared inside of a local class}}
template <typename> void baz() {} // expected-error{{templates cannot be declared inside of a local class}}
template <typename> void qux(); // expected-error{{templates cannot be declared inside of a local class}}
+ template <typename> using corge = int; // expected-error{{templates cannot be declared inside of a local class}}
+ template <typename T> static T grault; // expected-error{{static data member}} expected-error{{templates cannot be declared inside of a local class}}
};
}
More information about the cfe-commits
mailing list