[clang] ee0f1f1 - Further implement CWG 2292

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 15 05:50:02 PST 2020


Author: Soumi Manna
Date: 2020-01-15T08:49:44-05:00
New Revision: ee0f1f1edc3ec0d4e698d50cc3180217448802b7

URL: https://github.com/llvm/llvm-project/commit/ee0f1f1edc3ec0d4e698d50cc3180217448802b7
DIFF: https://github.com/llvm/llvm-project/commit/ee0f1f1edc3ec0d4e698d50cc3180217448802b7.diff

LOG: Further implement CWG 2292

The core issue is that simple-template-id is ambiguous between class-name
and type-name. This fixes PR43966.

Added: 
    clang/test/SemaCXX/pseudo-destructor-name.cpp

Modified: 
    clang/lib/Sema/SemaExprCXX.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index a73e6906fceb..96e18105df78 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -192,8 +192,10 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc,
       AlreadySearched = true;
       LookupCtx = DC;
       isDependent = false;
-    } else if (DC && isa<CXXRecordDecl>(DC)) {
-      LookAtPrefix = false;
+    } else if (auto *RD = dyn_cast_or_null<CXXRecordDecl>(DC)) {
+      if ((RD->hasDefinition() && RD->hasSimpleDestructor()) ||
+          !RD->hasDefinition())
+        LookAtPrefix = false;
       LookInScope = true;
     }
 

diff  --git a/clang/test/SemaCXX/pseudo-destructor-name.cpp b/clang/test/SemaCXX/pseudo-destructor-name.cpp
new file mode 100644
index 000000000000..cc7c22b8dc4d
--- /dev/null
+++ b/clang/test/SemaCXX/pseudo-destructor-name.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// expected-no-diagnostics
+
+struct AAA
+{
+    struct BBB
+    {
+        ~BBB() {}
+    };
+
+    typedef BBB BBB_alias;
+};
+
+typedef AAA::BBB BBB_alias2;
+
+int
+main()
+{
+    AAA::BBB_alias *ptr1 = new AAA::BBB_alias();
+    AAA::BBB_alias *ptr2 = new AAA::BBB_alias();
+
+    ptr1->AAA::BBB_alias::~BBB_alias(); // Now OK
+    ptr2->AAA::BBB_alias::~BBB();       // OK
+    ptr1->~BBB_alias2();                // OK
+    return 0;
+}


        


More information about the cfe-commits mailing list