Skip to content

Commit 3fca891

Browse files
committed
active conditional compilations: show friendly error message
1 parent 496122b commit 3fca891

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ ERROR(symbol_in_ir_not_in_tbd,none,
209209
"symbol '%0' (%1) is in generated IR file, but not in TBD file",
210210
(StringRef, StringRef))
211211

212+
ERROR(redundant_prefix_compilation_flag,none,
213+
"did you provide a redundant '-D' in your build settings? (got '-D%0')",
214+
(StringRef))
215+
212216
ERROR(invalid_conditional_compilation_flag,none,
213217
"conditional compilation flags must be valid Swift identifiers (rather than '%0')",
214218
(StringRef))

lib/Driver/Driver.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ static void validateArgs(DiagnosticEngine &diags, const ArgList &Args) {
192192
diags.diagnose(SourceLoc(),
193193
diag::cannot_assign_value_to_conditional_compilation_flag,
194194
name);
195+
else if (name.startswith("-D"))
196+
diags.diagnose(SourceLoc(), diag::redundant_prefix_compilation_flag,
197+
name);
195198
else if (!Lexer::isIdentifier(name))
196199
diags.diagnose(SourceLoc(), diag::invalid_conditional_compilation_flag,
197200
name);

0 commit comments

Comments
 (0)