Skip to content

Commit d59f61b

Browse files
committed
fixup! [Clang] Correct the DeclRefExpr's Type after the initializer gets instantiated
1 parent 04e350f commit d59f61b

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

clang/lib/Sema/SemaExpr.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19849,20 +19849,16 @@ static void DoMarkVarDeclReferenced(
1984919849
SemaRef.InstantiateVariableDefinition(PointOfInstantiation, Var);
1985019850
});
1985119851

19852-
if (auto *DRE = dyn_cast_or_null<DeclRefExpr>(E)) {
19853-
// Re-set the member to trigger a recomputation of the dependence bits
19854-
// for the expression.
19852+
// The size of an incomplete array type can be updated by
19853+
// instantiating the initializer. The DeclRefExpr's type should be
19854+
// updated accordingly too, or users of it would be confused!
19855+
SemaRef.getCompletedType(E);
19856+
19857+
// Re-set the member to trigger a recomputation of the dependence bits
19858+
// for the expression.
19859+
if (auto *DRE = dyn_cast_or_null<DeclRefExpr>(E))
1985519860
DRE->setDecl(DRE->getDecl());
19856-
// The size of an incomplete array type can be updated by
19857-
// instantiating the initializer. The DeclRefExpr's type should be
19858-
// updated accordingly too, or users of it would be confused!
19859-
//
19860-
// FIXME: Do we need to recompute the type for all the Decls, as in
19861-
// BuildDeclarationNameExpr?
19862-
if (SemaRef.Context.getAsIncompleteArrayType(DRE->getType()) &&
19863-
!SemaRef.Context.getAsIncompleteArrayType(Var->getType()))
19864-
DRE->setType(Var->getType());
19865-
} else if (auto *ME = dyn_cast_or_null<MemberExpr>(E))
19861+
else if (auto *ME = dyn_cast_or_null<MemberExpr>(E))
1986619862
ME->setMemberDecl(ME->getMemberDecl());
1986719863
} else if (FirstInstantiation) {
1986819864
SemaRef.PendingInstantiations

0 commit comments

Comments
 (0)