Skip to content

[Parse] Disallow unsupported condition expression in #if directive #6855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 21, 2017

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Jan 17, 2017

In non-Swift3 mode.

Previously:

#if FOO = false
#elseif FOO ? false : true
#endif

were silently accepted.
i.e. = false and ? false : true were silently ignored.

In Swift3 mode, emit a warning:

warning: ignoring invalid conditional compilation expression, which will be rejected in future version of Swift
#if FOO ? BAR : BAZ && QUX
        ^~~~~~~~~~~

In non-Swift3 mode.

Previously:

  #if FOO = false
  #elseif FOO ? false : true
  #endif

were silently accepted.
i.e. '= false' and '? false : true' were silently ignored.
diag::unsupported_conditional_compilation_expression_type);
return ConditionalCompilationExprState::error();
} else {
// TODO: Emit a warning.
Copy link
Member Author

@rintaro rintaro Jan 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any suggestion for the message?

warning: ignoring invalid conditional compilation expression, which will be rejected in future version of Swift
#if FOO ? BAR : BAZ && QUX
        ^~~~~~~~~~~

will be OK?

@rintaro
Copy link
Member Author

rintaro commented Jan 17, 2017

@swift-ci Please smoke test

1 similar comment
@rintaro
Copy link
Member Author

rintaro commented Jan 17, 2017

@swift-ci Please smoke test

@jrose-apple jrose-apple requested a review from CodaFi January 17, 2017 19:37
@@ -1356,6 +1356,9 @@ ERROR(unexpected_version_comparison_operator,none,
())
ERROR(unsupported_conditional_compilation_expression_type,none,
"invalid conditional compilation expression", ())
WARNING(swift3_unsupported_conditional_compilation_expression_type,none,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: align whitespace on next line with (

@rintaro rintaro force-pushed the parse-ifconfig-invalid-binary branch from 185f808 to b2d549e Compare January 17, 2017 20:25
@rintaro
Copy link
Member Author

rintaro commented Jan 17, 2017

@swift-ci Please smoke test?

@slavapestov slavapestov merged commit e8bd702 into swiftlang:master Jan 21, 2017
@rintaro rintaro deleted the parse-ifconfig-invalid-binary branch January 24, 2017 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants