This and r155289 would make good candidates for porting to the branch.<br><br><div class="gmail_quote">On Sat, Apr 21, 2012 at 11:42 AM, Richard Smith <span dir="ltr"><<a href="mailto:richard-llvm@metafoo.co.uk">richard-llvm@metafoo.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rsmith<br>
Date: Sat Apr 21 13:42:51 2012<br>
New Revision: 155293<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=155293&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=155293&view=rev</a><br>
Log:<br>
Fix regression in r154844. If necessary, defer computing adjusted destructor<br>
exception specifications in C++11 until after we've parsed the exception<br>
specifications for nested classes.<br>
<br>
Modified:<br>
cfe/trunk/include/clang/Sema/Sema.h<br>
cfe/trunk/lib/Parse/ParseDeclCXX.cpp<br>
cfe/trunk/lib/Sema/SemaDecl.cpp<br>
cfe/trunk/lib/Sema/SemaDeclCXX.cpp<br>
cfe/trunk/test/SemaCXX/implicit-exception-spec.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Sema/Sema.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=155293&r1=155292&r2=155293&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=155293&r1=155292&r2=155293&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Sema/Sema.h (original)<br>
+++ cfe/trunk/include/clang/Sema/Sema.h Sat Apr 21 13:42:51 2012<br>
@@ -331,6 +331,11 @@<br>
/// cycle detection at the end of the TU.<br>
DelegatingCtorDeclsType DelegatingCtorDecls;<br>
<br>
+ /// \brief All the destructors seen during a class definition that had their<br>
+ /// exception spec computation delayed because it depended on an unparsed<br>
+ /// exception spec.<br>
+ SmallVector<CXXDestructorDecl*, 2> DelayedDestructorExceptionSpecs;<br>
+<br>
/// \brief All the overriding destructors seen during a class definition<br>
/// (there could be multiple due to nested classes) that had their exception<br>
/// spec checks delayed, plus the overridden destructor.<br>
@@ -3203,7 +3208,8 @@<br>
/// C++11 says that user-defined destructors with no exception spec get one<br>
/// that looks as if the destructor was implicitly declared.<br>
void AdjustDestructorExceptionSpec(CXXRecordDecl *ClassDecl,<br>
- CXXDestructorDecl *Destructor);<br>
+ CXXDestructorDecl *Destructor,<br>
+ bool WasDelayed = false);<br>
<br>
/// \brief Declare all inherited constructors for the given class.<br>
///<br>
@@ -4048,6 +4054,7 @@<br>
SourceLocation LBrac,<br>
SourceLocation RBrac,<br>
AttributeList *AttrList);<br>
+ void ActOnFinishCXXMemberDecls();<br>
<br>
void ActOnReenterTemplateScope(Scope *S, Decl *Template);<br>
void ActOnReenterDeclaratorTemplateScope(Scope *S, DeclaratorDecl *D);<br>
<br>
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=155293&r1=155292&r2=155293&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=155293&r1=155292&r2=155293&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)<br>
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Sat Apr 21 13:42:51 2012<br>
@@ -2369,6 +2369,10 @@<br>
SourceLocation SavedPrevTokLocation = PrevTokLocation;<br>
ParseLexedAttributes(getCurrentClass());<br>
ParseLexedMethodDeclarations(getCurrentClass());<br>
+<br>
+ // We've finished with all pending member declarations.<br>
+ Actions.ActOnFinishCXXMemberDecls();<br>
+<br>
ParseLexedMemberInitializers(getCurrentClass());<br>
ParseLexedMethodDefs(getCurrentClass());<br>
PrevTokLocation = SavedPrevTokLocation;<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=155293&r1=155292&r2=155293&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=155293&r1=155292&r2=155293&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Apr 21 13:42:51 2012<br>
@@ -9784,21 +9784,6 @@<br>
if (!Completed)<br>
Record->completeDefinition();<br>
<br>
- // Now that the record is complete, do any delayed exception spec checks<br>
- // we were missing.<br>
- while (!DelayedDestructorExceptionSpecChecks.empty()) {<br>
- const CXXDestructorDecl *Dtor =<br>
- DelayedDestructorExceptionSpecChecks.back().first;<br>
- if (Dtor->getParent() != Record)<br>
- break;<br>
-<br>
- assert(!Dtor->getParent()->isDependentType() &&<br>
- "Should not ever add destructors of templates into the list.");<br>
- CheckOverridingFunctionExceptionSpec(Dtor,<br>
- DelayedDestructorExceptionSpecChecks.back().second);<br>
- DelayedDestructorExceptionSpecChecks.pop_back();<br>
- }<br>
-<br>
} else {<br>
ObjCIvarDecl **ClsFields =<br>
reinterpret_cast<ObjCIvarDecl**>(RecFields.data());<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=155293&r1=155292&r2=155293&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=155293&r1=155292&r2=155293&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat Apr 21 13:42:51 2012<br>
@@ -7317,15 +7317,42 @@<br>
}<br>
}<br>
<br>
+/// \brief Perform any semantic analysis which needs to be delayed until all<br>
+/// pending class member declarations have been parsed.<br>
+void Sema::ActOnFinishCXXMemberDecls() {<br>
+ // Now we have parsed all exception specifications, determine the implicit<br>
+ // exception specifications for destructors.<br>
+ for (unsigned i = 0, e = DelayedDestructorExceptionSpecs.size();<br>
+ i != e; ++i) {<br>
+ CXXDestructorDecl *Dtor = DelayedDestructorExceptionSpecs[i];<br>
+ AdjustDestructorExceptionSpec(Dtor->getParent(), Dtor, true);<br>
+ }<br>
+ DelayedDestructorExceptionSpecs.clear();<br>
+<br>
+ // Perform any deferred checking of exception specifications for virtual<br>
+ // destructors.<br>
+ for (unsigned i = 0, e = DelayedDestructorExceptionSpecChecks.size();<br>
+ i != e; ++i) {<br>
+ const CXXDestructorDecl *Dtor =<br>
+ DelayedDestructorExceptionSpecChecks[i].first;<br>
+ assert(!Dtor->getParent()->isDependentType() &&<br>
+ "Should not ever add destructors of templates into the list.");<br>
+ CheckOverridingFunctionExceptionSpec(Dtor,<br>
+ DelayedDestructorExceptionSpecChecks[i].second);<br>
+ }<br>
+ DelayedDestructorExceptionSpecChecks.clear();<br>
+}<br>
+<br>
void Sema::AdjustDestructorExceptionSpec(CXXRecordDecl *classDecl,<br>
- CXXDestructorDecl *destructor) {<br>
+ CXXDestructorDecl *destructor,<br>
+ bool WasDelayed) {<br>
// C++11 [class.dtor]p3:<br>
// A declaration of a destructor that does not have an exception-<br>
// specification is implicitly considered to have the same exception-<br>
// specification as an implicit declaration.<br>
const FunctionProtoType *dtorType = destructor->getType()-><br>
getAs<FunctionProtoType>();<br>
- if (dtorType->hasExceptionSpec())<br>
+ if (!WasDelayed && dtorType->hasExceptionSpec())<br>
return;<br>
<br>
ImplicitExceptionSpecification exceptSpec =<br>
@@ -7342,6 +7369,14 @@<br>
<br>
destructor->setType(ty);<br>
<br>
+ // If we can't compute the exception specification for this destructor yet<br>
+ // (because it depends on an exception specification which we have not parsed<br>
+ // yet), make a note that we need to try again when the class is complete.<br>
+ if (epi.ExceptionSpecType == EST_Delayed) {<br>
+ assert(!WasDelayed && "couldn't compute destructor exception spec");<br>
+ DelayedDestructorExceptionSpecs.push_back(destructor);<br>
+ }<br>
+<br>
// FIXME: If the destructor has a body that could throw, and the newly created<br>
// spec doesn't allow exceptions, we should emit a warning, because this<br>
// change in behavior can break conforming C++03 programs at runtime.<br>
<br>
Modified: cfe/trunk/test/SemaCXX/implicit-exception-spec.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/implicit-exception-spec.cpp?rev=155293&r1=155292&r2=155293&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/implicit-exception-spec.cpp?rev=155293&r1=155292&r2=155293&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/implicit-exception-spec.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/implicit-exception-spec.cpp Sat Apr 21 13:42:51 2012<br>
@@ -54,3 +54,33 @@<br>
} t; // expected-note {{has no default constructor}}<br>
};<br>
}<br>
+<br>
+namespace ImplicitDtorExceptionSpec {<br>
+ struct A {<br>
+ virtual ~A();<br>
+<br>
+ struct Inner {<br>
+ ~Inner() throw();<br>
+ };<br>
+ Inner inner;<br>
+ };<br>
+<br>
+ struct B {<br>
+ virtual ~B() {} // expected-note {{here}}<br>
+ };<br>
+<br>
+ struct C : B {<br>
+ virtual ~C() {}<br>
+ A a;<br>
+ };<br>
+<br>
+ struct D : B {<br>
+ ~D(); // expected-error {{more lax than base}}<br>
+ struct E {<br>
+ ~E();<br>
+ struct F {<br>
+ ~F() throw(A);<br>
+ } f;<br>
+ } e;<br>
+ };<br>
+}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br>