Skip to content

Commit 3ce7d25

Browse files
committed
[clang][RecoveryExpr] Don't perform alignment check if parameter type is dependent
This patch fixes a crash which appears because of getTypeAlignInChars() call with depentent type. Reviewed By: hokein Differential Revision: https://reviews.llvm.org/D133886
1 parent 693f816 commit 3ce7d25

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

clang/lib/Sema/SemaChecking.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5690,9 +5690,9 @@ void Sema::CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
56905690

56915691
// Find expected alignment, and the actual alignment of the passed object.
56925692
// getTypeAlignInChars requires complete types
5693-
if (ArgTy.isNull() || ParamTy->isIncompleteType() ||
5694-
ArgTy->isIncompleteType() || ParamTy->isUndeducedType() ||
5695-
ArgTy->isUndeducedType())
5693+
if (ArgTy.isNull() || ParamTy->isDependentType() ||
5694+
ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
5695+
ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
56965696
return;
56975697

56985698
CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);

clang/test/SemaCXX/recovery-expr-type.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,12 @@ extern "C" void *memset(void *, int b, unsigned long) {
162162
b = __builtin_object_size(c, 0); // crash2
163163
}
164164
}
165+
166+
namespace test15 {
167+
void f() {
168+
struct {
169+
void m(int (&)[undefined()]) {} // expected-error {{undeclared identifier}}
170+
} S;
171+
S.m(1); // no crash
172+
}
173+
}

0 commit comments

Comments
 (0)