forked from OSchip/llvm-project
Fix crash if, during evaluation of __builtin_object_size, we try to load
through an invalid base. llvm-svn: 360998
This commit is contained in:
parent
77483765eb
commit
51ce8444f0
|
@ -3285,6 +3285,11 @@ static bool AreElementsOfSameArray(QualType ObjType,
|
|||
static CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E,
|
||||
AccessKinds AK, const LValue &LVal,
|
||||
QualType LValType) {
|
||||
if (LVal.InvalidBase) {
|
||||
Info.FFDiag(E);
|
||||
return CompleteObject();
|
||||
}
|
||||
|
||||
if (!LVal.Base) {
|
||||
Info.FFDiag(E, diag::note_constexpr_access_null) << AK;
|
||||
return CompleteObject();
|
||||
|
|
|
@ -97,3 +97,10 @@ void tooSmallBuf() {
|
|||
copy5CharsIntoStrict(small.buf); // expected-error{{no matching function for call}}
|
||||
}
|
||||
}
|
||||
|
||||
namespace InvalidBase {
|
||||
// Ensure this doesn't crash.
|
||||
struct S { const char *name; };
|
||||
S invalid_base();
|
||||
constexpr long bos_name = __builtin_object_size(invalid_base().name, 1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue