forked from OSchip/llvm-project
[clang] Fix a crash on CheckArgAlignment.
We might encounter an undeduced type before calling getTypeAlignInChars. NOTE: this retrieves the fix from8f80c66bd2
, which was removed in Adam's followup fixfbfcfdbf68
. We originally thought the crash was caused by recovery-ast, but it turns out it can occur for other cases, e.g. typo-correction. Differential Revision: https://reviews.llvm.org/D102750
This commit is contained in:
parent
222314d8b0
commit
f5b5426433
|
@ -4571,7 +4571,8 @@ void Sema::CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
|
|||
|
||||
// Find expected alignment, and the actual alignment of the passed object.
|
||||
// getTypeAlignInChars requires complete types
|
||||
if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType())
|
||||
if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
|
||||
ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
|
||||
return;
|
||||
|
||||
CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);
|
||||
|
|
|
@ -42,3 +42,12 @@ class S {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace NoCrashOnCheckArgAlignment {
|
||||
template <typename a> void b(a &);
|
||||
void test() {
|
||||
for (auto file_data :b(files_db_data)); // expected-error {{use of undeclared identifier 'files_db_data'; did you mean 'file_data'?}} \
|
||||
// expected-note {{'file_data' declared here}} \
|
||||
// expected-error {{cannot use type 'void' as a range}}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue