]> granicus.if.org Git - clang/commitdiff
PR41854: Don't assert when constant-evaluating a member function call on an invalid...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 13 May 2019 07:51:29 +0000 (07:51 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 13 May 2019 07:51:29 +0000 (07:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360560 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ExprConstant.cpp
test/SemaCXX/constant-expression-cxx11.cpp

index 2b585edaf204f669eb14c64bc7bdfeda079f5b07..adc82bfe0ba71c90288c4d6da30cf1f7dd629415 100644 (file)
@@ -4537,6 +4537,9 @@ const AccessKinds CheckMemberCallThisPointerHandler::AccessKind;
 /// 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());
 
index c136b4d269334503a5a2cacac4f204f72ec7ea09..46a77e1814d7691308ef06fbb37cce79586484c3 100644 (file)
@@ -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;
+}