@@ -186,9 +186,10 @@ extern "C" int swift_ASTGen_roundTripCheck(void *sourceFile);
186186
187187// / Emit parser diagnostics for given source file.. Returns non-zero if any
188188// / diagnostics were emitted.
189- extern " C" int swift_ASTGen_emitParserDiagnostics (void *diagEngine,
190- void *sourceFile,
191- int emitOnlyErrors);
189+ extern " C" int
190+ swift_ASTGen_emitParserDiagnostics (void *diagEngine, void *sourceFile,
191+ int emitOnlyErrors,
192+ int downgradePlaceholderErrorsToWarnings);
192193
193194// Build AST nodes for the top-level entities in the syntax.
194195extern " C" void swift_ASTGen_buildTopLevelASTNodes (void *sourceFile,
@@ -274,9 +275,12 @@ void Parser::parseTopLevelItems(SmallVectorImpl<ASTNode> &items) {
274275 diagnose (loc, diag::parser_round_trip_error);
275276 } else if (Context.LangOpts .hasFeature (Feature::ParserValidation) &&
276277 !Context.Diags .hadAnyError () &&
277- swift_ASTGen_emitParserDiagnostics (&Context.Diags ,
278- SF.exportedSourceFile ,
279- /* emitOnlyErrors=*/ true )) {
278+ swift_ASTGen_emitParserDiagnostics (
279+ &Context.Diags , SF.exportedSourceFile ,
280+ /* emitOnlyErrors=*/ true ,
281+ /* downgradePlaceholderErrorsToWarnings=*/
282+ Context.LangOpts .Playground ||
283+ Context.LangOpts .WarnOnEditorPlaceholder )) {
280284 // We might have emitted warnings in the C++ parser but no errors, in
281285 // which case we still have `hadAnyError() == false`. To avoid emitting
282286 // the same warnings from SwiftParser, only emit errors from SwiftParser
@@ -316,7 +320,10 @@ Parser::parseSourceFileViaASTGen(SmallVectorImpl<ASTNode> &items,
316320 Context.LangOpts .hasFeature (Feature::ParserASTGen)) &&
317321 !suppressDiagnostics &&
318322 swift_ASTGen_emitParserDiagnostics (
319- &Context.Diags , SF.exportedSourceFile , /* emitOnlyErrors=*/ false ) &&
323+ &Context.Diags , SF.exportedSourceFile , /* emitOnlyErrors=*/ false ,
324+ /* downgradePlaceholderErrorsToWarnings=*/
325+ Context.LangOpts .Playground ||
326+ Context.LangOpts .WarnOnEditorPlaceholder ) &&
320327 Context.Diags .hadAnyError () &&
321328 !Context.LangOpts .hasFeature (Feature::ParserASTGen)) {
322329 // Errors were emitted, and we're still using the C++ parser, so
0 commit comments