[llvm-branch-commits] [clang] c4af1c8 - PR48383: Disallow decltype(auto) in pseudodestructor calls

David Blaikie via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Dec 3 20:45:51 PST 2020


Author: David Blaikie
Date: 2020-12-03T20:41:06-08:00
New Revision: c4af1c8d939b21ac7deb631887fc26db7451c592

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

LOG: PR48383: Disallow decltype(auto) in pseudodestructor calls

Added: 
    

Modified: 
    clang/lib/Sema/SemaExprCXX.cpp
    clang/test/SemaCXX/cxx1y-deduced-return-type.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index e36d9adfbaba..241b8f72c56e 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -7595,6 +7595,11 @@ ExprResult Sema::ActOnPseudoDestructorExpr(Scope *S, Expr *Base,
   if (CheckArrow(*this, ObjectType, Base, OpKind, OpLoc))
     return ExprError();
 
+  if (DS.getTypeSpecType() == DeclSpec::TST_decltype_auto) {
+    Diag(DS.getTypeSpecTypeLoc(), diag::err_decltype_auto_invalid);
+    return true;
+  }
+
   QualType T = BuildDecltypeType(DS.getRepAsExpr(), DS.getTypeSpecTypeLoc(),
                                  false);
 

diff  --git a/clang/test/SemaCXX/cxx1y-deduced-return-type.cpp b/clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
index 3e544c300884..051b0e7b1469 100644
--- a/clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
+++ b/clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
@@ -421,6 +421,7 @@ namespace DecltypeAutoShouldNotBeADecltypeSpecifier {
   namespace Dtor {
     struct A {};
     void f(A a) { a.~decltype(auto)(); } // expected-error {{'decltype(auto)' not allowed here}}
+    void g(int i) { i.~decltype(auto)(); } // expected-error {{'decltype(auto)' not allowed here}}
   }
 
   namespace BaseClass {


        


More information about the llvm-branch-commits mailing list