From: John McCall Date: Sun, 11 Jun 2017 20:33:00 +0000 (+0000) Subject: Don't crash when forming a destructor name on an incomplete type. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=414d1fa14aa912f088a0ec6044e1f24bee1ba945;p=clang Don't crash when forming a destructor name on an incomplete type. Fixes PR25156. Patch by Don Hinton! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305169 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 00a4b39f14..a9ff21bc41 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -189,12 +189,15 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, // have one) and, if that fails to find a match, in the scope (if // we're allowed to look there). Found.clear(); - if (Step == 0 && LookupCtx) + if (Step == 0 && LookupCtx) { + if (RequireCompleteDeclContext(SS, LookupCtx)) + return nullptr; LookupQualifiedName(Found, LookupCtx); - else if (Step == 1 && LookInScope && S) + } else if (Step == 1 && LookInScope && S) { LookupName(Found, S); - else + } else { continue; + } // FIXME: Should we be suppressing ambiguities here? if (Found.isAmbiguous()) diff --git a/test/SemaCXX/nested-name-spec.cpp b/test/SemaCXX/nested-name-spec.cpp index 6ae45ff633..725ac64ced 100644 --- a/test/SemaCXX/nested-name-spec.cpp +++ b/test/SemaCXX/nested-name-spec.cpp @@ -169,6 +169,13 @@ void N::f() { } // okay struct Y; // expected-note{{forward declaration of 'Y'}} Y::foo y; // expected-error{{incomplete type 'Y' named in nested name specifier}} +namespace PR25156 { +struct Y; // expected-note{{forward declaration of 'PR25156::Y'}} +void foo() { + Y::~Y(); // expected-error{{incomplete type 'PR25156::Y' named in nested name specifier}} +} +} + X::X() : a(5) { } // expected-error{{use of undeclared identifier 'X'}} struct foo_S {