File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 17
17
#include " swift/Parse/Parser.h"
18
18
19
19
#include " swift/AST/ASTVisitor.h"
20
+ #include " swift/AST/DiagnosticSuppression.h"
20
21
#include " swift/Basic/Defer.h"
21
22
#include " swift/Basic/LangOptions.h"
22
23
#include " swift/Basic/Version.h"
@@ -638,6 +639,12 @@ ParserResult<IfConfigDecl> Parser::parseIfConfig(
638
639
SmallVector<ASTNode, 16 > Elements;
639
640
if (isActive || !isVersionCondition) {
640
641
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 );
641
648
} else {
642
649
DiagnosticTransaction DT (Diags);
643
650
skipUntilConditionalBlockClose ();
Original file line number Diff line number Diff line change @@ -19,3 +19,10 @@ class { // expected-error {{unknown declaration syntax exists in the source}}
19
19
// expected-error@-4 {{top-level statement cannot begin with a closure expression}}
20
20
21
21
}
22
+
23
+ #if swift(<1)
24
+ print ( " Wat " )
25
+ class { // expected-error {{unknown declaration syntax exists in the source}}
26
+
27
+ }
28
+ #endif
You can’t perform that action at this time.
0 commit comments