r373418 - Fix crash on constant-evaluation of pseudo-destruction of a pointer.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 1 18:13:58 PDT 2019
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 {
More information about the cfe-commits
mailing list