r351911 - [Sema][ObjC] Check whether a DelayedDiagnosticPool has been pushed
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 22 16:55:48 PST 2019
Author: ahatanak
Date: Tue Jan 22 16:55:48 2019
New Revision: 351911
URL: http://llvm.org/viewvc/llvm-project?rev=351911&view=rev
Log:
[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
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaObjCXX/arc-0x.mm
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=351911&r1=351910&r2=351911&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jan 22 16:55:48 2019
@@ -12545,9 +12545,13 @@ ParmVarDecl *Sema::CheckParameter(DeclCo
// - 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 {
Modified: cfe/trunk/test/SemaObjCXX/arc-0x.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/arc-0x.mm?rev=351911&r1=351910&r2=351911&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/arc-0x.mm (original)
+++ cfe/trunk/test/SemaObjCXX/arc-0x.mm Tue Jan 22 16:55:48 2019
@@ -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}}
+ }
+}
More information about the cfe-commits
mailing list