forked from OSchip/llvm-project
Fixes issue introduced by r331556.
Closes bug: https://bugs.llvm.org/show_bug.cgi?id=37357 Patch by Rafael Stahl! Differential revision: https://reviews.llvm.org/D46633 llvm-svn: 331870
This commit is contained in:
parent
e0207a60dd
commit
48fcfc3274
|
@ -1711,13 +1711,15 @@ SVal RegionStoreManager::getBindingForField(RegionBindingsConstRef B,
|
|||
if (const auto *VR = dyn_cast<VarRegion>(superR)) {
|
||||
const VarDecl *VD = VR->getDecl();
|
||||
QualType RecordVarTy = VD->getType();
|
||||
unsigned Index = FD->getFieldIndex();
|
||||
// Either the record variable or the field has to be const qualified.
|
||||
if (RecordVarTy.isConstQualified() || Ty.isConstQualified())
|
||||
if (const Expr *Init = VD->getInit())
|
||||
if (const auto *InitList = dyn_cast<InitListExpr>(Init))
|
||||
if (const Expr *FieldInit = InitList->getInit(FD->getFieldIndex()))
|
||||
if (Optional<SVal> V = svalBuilder.getConstantVal(FieldInit))
|
||||
return *V;
|
||||
if (Index < InitList->getNumInits())
|
||||
if (const Expr *FieldInit = InitList->getInit(Index))
|
||||
if (Optional<SVal> V = svalBuilder.getConstantVal(FieldInit))
|
||||
return *V;
|
||||
}
|
||||
|
||||
return getBindingForFieldOrElementCommon(B, R, Ty);
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
|
||||
// expected-no-diagnostics
|
||||
|
||||
void initbug() {
|
||||
const union { float a; } u = {};
|
||||
(void)u.a; // no-crash
|
||||
}
|
Loading…
Reference in New Issue