diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-10-02 01:13:57 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-10-02 01:13:57 +0000 |
commit | 5e18f4db08dc4df3d91869cea1c39810b3e0c83b (patch) | |
tree | 2a5ee05947509aa203a06c47bad69a9fef8d8b26 | |
parent | 86f864dacee0c1c65841723e84503ff1927bf28a (diff) | |
download | bcm5719-llvm-5e18f4db08dc4df3d91869cea1c39810b3e0c83b.tar.gz bcm5719-llvm-5e18f4db08dc4df3d91869cea1c39810b3e0c83b.zip |
Fix crash on constant-evaluation of pseudo-destruction of a pointer.
We got confused and thought we might be pseudo-destroying the pointee
instead.
llvm-svn: 373418
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 2 | ||||
-rw-r--r-- | clang/test/SemaCXX/constant-expression-cxx2a.cpp | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index cf28ecbe5ff..92ea1c93000 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -3997,7 +3997,7 @@ static bool handleIncDec(EvalInfo &Info, const Expr *E, const LValue &LVal, /// 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()) diff --git a/clang/test/SemaCXX/constant-expression-cxx2a.cpp b/clang/test/SemaCXX/constant-expression-cxx2a.cpp index ef3ce5c0ccb..cb8f16a8b0f 100644 --- a/clang/test/SemaCXX/constant-expression-cxx2a.cpp +++ b/clang/test/SemaCXX/constant-expression-cxx2a.cpp @@ -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 { |