r226135 - Sema: Recover when a function template is in an extern "C" block
David Majnemer
david.majnemer at gmail.com
Wed Jan 14 23:04:39 PST 2015
Author: majnemer
Date: Thu Jan 15 01:04:38 2015
New Revision: 226135
URL: http://llvm.org/viewvc/llvm-project?rev=226135&view=rev
Log:
Sema: Recover when a function template is in an extern "C" block
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
cfe/trunk/test/SemaTemplate/class-template-decl.cpp
cfe/trunk/test/SemaTemplate/destructor-template.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=226135&r1=226134&r2=226135&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jan 15 01:04:38 2015
@@ -7010,12 +7010,12 @@ Sema::ActOnFunctionDeclarator(Scope *S,
// Check that we can declare a template here.
if (CheckTemplateDeclScope(S, TemplateParams))
- return nullptr;
+ NewFD->setInvalidDecl();
// A destructor cannot be a template.
if (Name.getNameKind() == DeclarationName::CXXDestructorName) {
Diag(NewFD->getLocation(), diag::err_destructor_template);
- return nullptr;
+ NewFD->setInvalidDecl();
}
// If we're adding a template to a dependent context, we may need to
Modified: cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp?rev=226135&r1=226134&r2=226135&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp Thu Jan 15 01:04:38 2015
@@ -173,7 +173,7 @@ namespace PR14577 {
extern "C" {
template<typename _Tp> // expected-error {{templates must have C++ linkage}}
- void PR13573(const _Tp&) = delete; // expected-error {{only functions can have deleted definitions}}
+ void PR13573(const _Tp&) = delete;
}
namespace PR15597 {
Modified: cfe/trunk/test/SemaTemplate/class-template-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/class-template-decl.cpp?rev=226135&r1=226134&r2=226135&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/class-template-decl.cpp (original)
+++ cfe/trunk/test/SemaTemplate/class-template-decl.cpp Thu Jan 15 01:04:38 2015
@@ -146,3 +146,9 @@ namespace redecl {
};
};
}
+
+extern "C" template <typename T> // expected-error{{templates must have C++ linkage}}
+void DontCrashOnThis() {
+ T &pT = T();
+ pT;
+}
Modified: cfe/trunk/test/SemaTemplate/destructor-template.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/destructor-template.cpp?rev=226135&r1=226134&r2=226135&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/destructor-template.cpp (original)
+++ cfe/trunk/test/SemaTemplate/destructor-template.cpp Thu Jan 15 01:04:38 2015
@@ -52,9 +52,13 @@ namespace PR7239 {
}
namespace PR7904 {
- struct Foo {
- template <int i> ~Foo() {} // expected-error{{destructor cannot be declared as a template}}
- };
+ struct Foo {};
+ template <class T>
+ Foo::~Foo() { // expected-error{{destructor cannot be declared as a template}}
+ T t;
+ T &pT = t;
+ pT;
+ }
Foo f;
}
More information about the cfe-commits
mailing list