Skip to content

Commit fed5ff9

Browse files
authored
Merge pull request #28606 from DougGregor/function-builders-pound-diag
2 parents c32e31c + 6022b38 commit fed5ff9

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/Sema/BuilderTransform.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ class BuilderClosureVisitor
163163
if (isa<IfConfigDecl>(decl))
164164
continue;
165165

166+
// Emit #warning/#error but don't build anything for it.
167+
if (auto poundDiag = dyn_cast<PoundDiagnosticDecl>(decl)) {
168+
TypeChecker::typeCheckDecl(poundDiag);
169+
continue;
170+
}
171+
166172
if (!unhandledNode)
167173
unhandledNode = decl;
168174

test/Constraints/function_builder_diags.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,12 @@ func extraArg() {
225225
6 // expected-error {{extra argument in call}}
226226
}
227227
}
228+
229+
// rdar://problem/53209000 - use of #warning and #error
230+
tuplify(true) { x in
231+
1
232+
#error("boom") // expected-error{{boom}}
233+
"hello"
234+
#warning("oops") // expected-warning{{oops}}
235+
3.14159
236+
}

0 commit comments

Comments
 (0)