summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-01-15 07:04:38 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-01-15 07:04:38 +0000
commit8e1a913cfacad6de89eaa3cdd95d19fbe1743ac6 (patch)
treef08466fc9690779fcc1de8a31ff6fd422173f181
parentbe30c2c56eeb2e2532a4a5f6d67aa64e9e58c7b9 (diff)
downloadbcm5719-llvm-8e1a913cfacad6de89eaa3cdd95d19fbe1743ac6.tar.gz
bcm5719-llvm-8e1a913cfacad6de89eaa3cdd95d19fbe1743ac6.zip
Sema: Recover when a function template is in an extern "C" block
llvm-svn: 226135
-rw-r--r--clang/lib/Sema/SemaDecl.cpp4
-rw-r--r--clang/test/SemaCXX/cxx0x-defaulted-functions.cpp2
-rw-r--r--clang/test/SemaTemplate/class-template-decl.cpp6
-rw-r--r--clang/test/SemaTemplate/destructor-template.cpp10
4 files changed, 16 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 007470344f1..9b9a6afbfd8 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -7010,12 +7010,12 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
// 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
diff --git a/clang/test/SemaCXX/cxx0x-defaulted-functions.cpp b/clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
index bc03bcd2a13..617a2571631 100644
--- a/clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
+++ b/clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
@@ -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 {
diff --git a/clang/test/SemaTemplate/class-template-decl.cpp b/clang/test/SemaTemplate/class-template-decl.cpp
index c67361bfeaf..4f861dea705 100644
--- a/clang/test/SemaTemplate/class-template-decl.cpp
+++ b/clang/test/SemaTemplate/class-template-decl.cpp
@@ -146,3 +146,9 @@ namespace redecl {
};
};
}
+
+extern "C" template <typename T> // expected-error{{templates must have C++ linkage}}
+void DontCrashOnThis() {
+ T &pT = T();
+ pT;
+}
diff --git a/clang/test/SemaTemplate/destructor-template.cpp b/clang/test/SemaTemplate/destructor-template.cpp
index 4e1af9ad1f9..853ba492f8e 100644
--- a/clang/test/SemaTemplate/destructor-template.cpp
+++ b/clang/test/SemaTemplate/destructor-template.cpp
@@ -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;
}
OpenPOWER on IntegriCloud