Skip to content

Commit 5e0c89c

Browse files
committed
---
yaml --- r: 319398 b: refs/heads/master-rebranch c: 9e87e49 h: refs/heads/master
1 parent 540d38b commit 5e0c89c

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,4 +1457,4 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14571457
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14581458
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14591459
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1460-
refs/heads/master-rebranch: ee810d21dfc09e4e445cb6a6d70b55060b465c7b
1460+
refs/heads/master-rebranch: 9e87e491c68a514f48741d9ba249f677ef83eace

branches/master-rebranch/lib/Parse/ParseIfConfig.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "swift/Parse/Parser.h"
1818

1919
#include "swift/AST/ASTVisitor.h"
20+
#include "swift/AST/DiagnosticSuppression.h"
2021
#include "swift/Basic/Defer.h"
2122
#include "swift/Basic/LangOptions.h"
2223
#include "swift/Basic/Version.h"
@@ -638,6 +639,12 @@ ParserResult<IfConfigDecl> Parser::parseIfConfig(
638639
SmallVector<ASTNode, 16> Elements;
639640
if (isActive || !isVersionCondition) {
640641
parseElements(Elements, isActive);
642+
} else if (SyntaxContext->isEnabled()) {
643+
// We shouldn't skip code if we are building syntax tree.
644+
// The parser will keep running and we just discard the AST part.
645+
DiagnosticSuppression suppression(Context.Diags);
646+
SmallVector<ASTNode, 16> dropedElements;
647+
parseElements(dropedElements, false);
641648
} else {
642649
DiagnosticTransaction DT(Diags);
643650
skipUntilConditionalBlockClose();

branches/master-rebranch/test/Syntax/diagnostics_verify.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@ class { // expected-error {{unknown declaration syntax exists in the source}}
1919
// expected-error@-4 {{top-level statement cannot begin with a closure expression}}
2020

2121
}
22+
23+
#if swift(<1)
24+
print("Wat")
25+
class { // expected-error {{unknown declaration syntax exists in the source}}
26+
27+
}
28+
#endif

0 commit comments

Comments
 (0)