From 3c886885a73b99ffd7f0c9a85e6b4fc8a26c6569 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Sat, 3 May 2014 02:18:46 +0000 Subject: [PATCH] Sema: Implement DR244 Naming the destructor using a typedef-name for the class-name is well-formed. This fixes PR19620. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207892 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExprCXX.cpp | 6 +++--- test/CXX/basic/basic.lookup/basic.lookup.qual/p6.cpp | 3 ++- test/CXX/drs/dr2xx.cpp | 5 ++--- www/cxx_dr_status.html | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 6f60406a4e..a5ecba7310 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -144,8 +144,10 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, AlreadySearched = true; LookupCtx = DC; isDependent = false; - } else if (DC && isa(DC)) + } else if (DC && isa(DC)) { LookAtPrefix = false; + LookInScope = true; + } // The second case from the C++03 rules quoted further above. NestedNameSpecifier *Prefix = 0; @@ -163,8 +165,6 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, LookupCtx = computeDeclContext(SS, EnteringContext); isDependent = LookupCtx && LookupCtx->isDependentContext(); } - - LookInScope = false; } else if (ObjectTypePtr) { // C++ [basic.lookup.classref]p3: // If the unqualified-id is ~type-name, the type-name is looked up diff --git a/test/CXX/basic/basic.lookup/basic.lookup.qual/p6.cpp b/test/CXX/basic/basic.lookup/basic.lookup.qual/p6.cpp index 0956de3c2a..83c8dd8fc2 100644 --- a/test/CXX/basic/basic.lookup/basic.lookup.qual/p6.cpp +++ b/test/CXX/basic/basic.lookup/basic.lookup.qual/p6.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// expected-no-diagnostics struct C { typedef int I; @@ -20,5 +21,5 @@ struct A { typedef A AB; int main() { AB *p; - p->AB::~AB(); // expected-error{{expected the class name after '~' to name a destructor}} + p->AB::~AB(); } diff --git a/test/CXX/drs/dr2xx.cpp b/test/CXX/drs/dr2xx.cpp index 692ed1d1af..fb818fb7fc 100644 --- a/test/CXX/drs/dr2xx.cpp +++ b/test/CXX/drs/dr2xx.cpp @@ -466,7 +466,7 @@ namespace dr243 { // dr243: yes A a2 = b; // expected-error {{ambiguous}} } -namespace dr244 { // dr244: no +namespace dr244 { // dr244: 3.5 struct B {}; struct D : B {}; // expected-note {{here}} D D_object; @@ -480,7 +480,7 @@ namespace dr244 { // dr244: no B_ptr->~B_alias(); B_ptr->B_alias::~B(); // This is valid under DR244. - B_ptr->B_alias::~B_alias(); // FIXME: expected-error {{expected the class name after '~' to name a destructor}} + B_ptr->B_alias::~B_alias(); B_ptr->dr244::~B(); // expected-error {{refers to a member in namespace}} B_ptr->dr244::~B_alias(); // expected-error {{refers to a member in namespace}} } @@ -1013,7 +1013,6 @@ namespace dr298 { // dr298: yes B::B() {} // expected-error {{requires a type specifier}} B::A() {} // ok - C::~C() {} // expected-error {{expected the class name}} C::~A() {} // ok typedef struct D E; // expected-note {{here}} diff --git a/www/cxx_dr_status.html b/www/cxx_dr_status.html index dc6339982c..adb3902b9b 100644 --- a/www/cxx_dr_status.html +++ b/www/cxx_dr_status.html @@ -1504,7 +1504,7 @@ accessible? 244 CD1 Destructor lookup - No + SVN 245 -- 2.40.0