Skip to content

Commit 4bf91fe

Browse files
authored
Merge pull request #10356 from rintaro/4.0-parse-ifconfig-invalid-platformarg
[4.0][Parse] Don't invalidate compilation condition with invalid platform condition argument
2 parents ec63e10 + 77759ed commit 4bf91fe

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/Parse/ParseIfConfig.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ class ValidateIfConfigCondition :
321321
diag::unsupported_platform_runtime_condition_argument);
322322
return nullptr;
323323
}
324+
325+
// Just a warning for other unsupported arguments.
324326
StringRef DiagName;
325327
switch (*Kind) {
326328
case PlatformConditionKind::OS:
@@ -338,7 +340,6 @@ class ValidateIfConfigCondition :
338340
for (auto suggestion : suggestions)
339341
D.diagnose(Loc, diag::note_typo_candidate, suggestion)
340342
.fixItReplace(Arg->getSourceRange(), suggestion);
341-
return nullptr;
342343
}
343344

344345
return E;

test/Parse/ConditionalCompilation/basicParseErrors.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,27 @@ undefinedFunc() // ignored.
114114
#else
115115
undefinedFunc() // expected-error {{use of unresolved identifier 'undefinedFunc'}}
116116
#endif
117+
118+
/// Invalid platform condition arguments don't invalidate the whole condition.
119+
#if !arch(tecture) && !os(ystem) && !_endian(ness)
120+
// expected-warning@-1 {{unknown architecture for build configuration 'arch'}}
121+
// expected-note@-2 {{did you mean 'arm'?}} {{11-18=arm}}
122+
// expected-warning@-3 {{unknown operating system for build configuration 'os'}}
123+
// expected-note@-4 {{did you mean 'OSX'?}} {{27-32=OSX}}
124+
// expected-note@-5 {{did you mean 'PS4'?}} {{27-32=PS4}}
125+
// expected-warning@-6 {{unknown endianness for build configuration '_endian'}}
126+
// expected-note@-7 {{did you mean 'big'?}} {{46-50=big}}
127+
func fn_k() {}
128+
#endif
129+
fn_k()
130+
131+
#if os(cillator) || arch(ive)
132+
// expected-warning@-1 {{unknown operating system for build configuration 'os'}}
133+
// expected-note@-2 {{did you mean 'macOS'?}} {{8-16=macOS}}
134+
// expected-note@-3 {{did you mean 'iOS'?}} {{8-16=iOS}}
135+
// expected-warning@-4 {{unknown architecture for build configuration 'arch'}}
136+
// expected-note@-5 {{did you mean 'arm'?}} {{26-29=arm}}
137+
// expected-note@-6 {{did you mean 'i386'?}} {{26-29=i386}}
138+
func undefinedFunc() // ignored.
139+
#endif
140+
undefinedFunc() // expected-error {{use of unresolved identifier 'undefinedFunc'}}

0 commit comments

Comments
 (0)