[cfe-commits] r172676 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/cxx0x-defaulted-functions.cpp
Aaron Ballman
aaron at aaronballman.com
Wed Jan 16 15:39:10 PST 2013
Author: aaronballman
Date: Wed Jan 16 17:39:10 2013
New Revision: 172676
URL: http://llvm.org/viewvc/llvm-project?rev=172676&view=rev
Log:
Fixes crash when illegal function definitions are deleted or defaulted. Fixes PR14577.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=172676&r1=172675&r2=172676&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Jan 16 17:39:10 2013
@@ -10815,7 +10815,7 @@
void Sema::SetDeclDeleted(Decl *Dcl, SourceLocation DelLoc) {
AdjustDeclIfTemplate(Dcl);
- FunctionDecl *Fn = dyn_cast<FunctionDecl>(Dcl);
+ FunctionDecl *Fn = dyn_cast_or_null<FunctionDecl>(Dcl);
if (!Fn) {
Diag(DelLoc, diag::err_deleted_non_function);
return;
@@ -10835,7 +10835,7 @@
}
void Sema::SetDeclDefaulted(Decl *Dcl, SourceLocation DefaultLoc) {
- CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(Dcl);
+ CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(Dcl);
if (MD) {
if (MD->getParent()->isDependentType()) {
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=172676&r1=172675&r2=172676&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp Wed Jan 16 17:39:10 2013
@@ -149,3 +149,24 @@
Y &Y::operator=(Y&&) = default; // expected-error {{definition of explicitly defaulted}}
Y::~Y() = default; // expected-error {{definition of explicitly defaulted}}
}
+
+namespace PR14577 {
+ template<typename T>
+ struct Outer {
+ template<typename U>
+ struct Inner1 {
+ ~Inner1();
+ };
+
+ template<typename U>
+ struct Inner2 {
+ ~Inner2();
+ };
+ };
+
+ template<typename T>
+ Outer<T>::Inner1<T>::~Inner1() = delete; // expected-error {{nested name specifier 'Outer<T>::Inner1<T>::' for declaration does not refer into a class, class template or class template partial specialization}} expected-error {{only functions can have deleted definitions}}
+
+ template<typename T>
+ Outer<T>::Inner2<T>::~Inner2() = default; // expected-error {{nested name specifier 'Outer<T>::Inner2<T>::' for declaration does not refer into a class, class template or class template partial specialization}} expected-error {{only special member functions may be defaulted}}
+}
More information about the cfe-commits
mailing list