Author: rsmith
Date: Tue Oct  1 18:13:57 2019
New Revision: 373418

URL: http://llvm.org/viewvc/llvm-project?rev=373418&view=rev
Log:
Fix crash on constant-evaluation of pseudo-destruction of a pointer.

We got confused and thought we might be pseudo-destroying the pointee
instead.

Modified:
    cfe/trunk/lib/AST/ExprConstant.cpp
    cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=373418&r1=373417&r2=373418&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Oct  1 18:13:57 2019
@@ -3997,7 +3997,7 @@ static bool handleIncDec(EvalInfo &Info,
 /// Build an lvalue for the object argument of a member function call.
 static bool EvaluateObjectArgument(EvalInfo &Info, const Expr *Object,
                                    LValue &This) {
-  if (Object->getType()->isPointerType())
+  if (Object->getType()->isPointerType() && Object->isRValue())
     return EvaluatePointer(Object, This, Info);
 
   if (Object->isGLValue())

Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp?rev=373418&r1=373417&r2=373418&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp Tue Oct  1 18:13:57 
2019
@@ -1283,6 +1283,15 @@ namespace dtor_call {
     // FIXME: This diagnostic is wrong; the union has no active member now.
     as.b.~A(); // expected-note {{destruction of member 'b' of union with 
active member 'a'}}
   }
+
+  constexpr void destroy_pointer() {
+    using T = int*;
+    T p;
+    // We used to think this was an -> member access because its left-hand side
+    // is a pointer. Ensure we don't crash.
+    p.~T();
+  }
+  static_assert((destroy_pointer(), true));
 }
 
 namespace temp_dtor {


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to