Skip to content

Commit

Permalink
PR41854: Don't assert when constant-evaluating a member function call…
Browse files Browse the repository at this point in the history
… on an invalid designator.

llvm-svn: 360560
  • Loading branch information
zygoloid committed May 13, 2019
1 parent 5c5be6b commit dab287b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
8 changes: 8 additions & 0 deletions clang/test/SemaCXX/constant-expression-cxx11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit dab287b

Please sign in to comment.