r360560 - PR41854: Don't assert when constant-evaluating a member function call on an invalid designator.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon May 13 00:51:29 PDT 2019


Author: rsmith
Date: Mon May 13 00:51:29 2019
New Revision: 360560

URL: http://llvm.org/viewvc/llvm-project?rev=360560&view=rev
Log:
PR41854: Don't assert when constant-evaluating a member function call on an invalid designator.

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

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=360560&r1=360559&r2=360560&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon May 13 00:51:29 2019
@@ -4537,6 +4537,9 @@ const AccessKinds CheckMemberCallThisPoi
 /// either within its lifetime or in its period of construction or destruction.
 static bool checkMemberCallThisPointer(EvalInfo &Info, const Expr *E,
                                        const LValue &This) {
+  if (This.Designator.Invalid)
+    return false;
+
   CompleteObject Obj =
       findCompleteObject(Info, E, AK_MemberCall, This, QualType());
 

Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp?rev=360560&r1=360559&r2=360560&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp Mon May 13 00:51:29 2019
@@ -2284,3 +2284,11 @@ namespace PR40430 {
   };
   static_assert(S().foo() == 'f', "");
 }
+
+namespace PR41854 {
+  struct e { operator int(); };
+  struct f { e c; };
+  int a;
+  f &d = reinterpret_cast<f&>(a);
+  unsigned b = d.c;
+}




More information about the cfe-commits mailing list