[Sema][ObjC] Check whether a DelayedDiagnosticPool has been pushed

before adding a delayed diagnostic to DelayedDiagnostics.

This fixes an assertion failure in Sema::DelayedDiagnostics::add that
was caused by the changes made in r141037.

rdar://problem/42782323

llvm-svn: 351911
This commit is contained in:
Akira Hatanaka 2019-01-23 00:55:48 +00:00
parent 7a3108ff0f
commit 957accaef0
2 changed files with 17 additions and 3 deletions

View File

@ -12545,9 +12545,13 @@ ParmVarDecl *Sema::CheckParameter(DeclContext *DC, SourceLocation StartLoc,
// - otherwise, it's an error
if (T->isArrayType()) {
if (!T.isConstQualified()) {
DelayedDiagnostics.add(
sema::DelayedDiagnostic::makeForbiddenType(
NameLoc, diag::err_arc_array_param_no_ownership, T, false));
if (DelayedDiagnostics.shouldDelayDiagnostics())
DelayedDiagnostics.add(
sema::DelayedDiagnostic::makeForbiddenType(
NameLoc, diag::err_arc_array_param_no_ownership, T, false));
else
Diag(NameLoc, diag::err_arc_array_param_no_ownership)
<< TSInfo->getTypeLoc().getSourceRange();
}
lifetime = Qualifiers::OCL_ExplicitNone;
} else {

View File

@ -101,3 +101,13 @@ namespace rdar12078752 {
__autoreleasing auto o3 = o;
}
}
namespace test_err_arc_array_param_no_ownership {
template <class T>
void func(T a) {}
void test() {
func([](A *a[]){}); // expected-error{{must explicitly describe intended ownership of an object array parameter}}
func(^(A *a[]){}); // expected-error{{must explicitly describe intended ownership of an object array parameter}}
}
}