Skip to content
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

Support the -std=<standard> command-line option #456

Merged
merged 6 commits into from
Sep 23, 2022
Merged

Conversation

xavierleroy
Copy link
Contributor

This PR adds a -std command-line option similar to those of GCC and Clang.

Currently three values are supported: -std=c99, -std=c11 and -std=c18.

The option has two effects:

  • With a GNU toolchain, it's passed down to the preprocessor. This influences the contents of standard header files.
  • It determines the default handling of the "C11 feature" warning: with -std=c99, CompCert warns on the use of C11 features; with -std=c11 or -std=c18, no warnings are emitted.

For backward compatibility with CompCert's current behavior, if no -std option is given, the default is to not warn, but -std=c99 is passed to the preprocessor. This may change in the future, when C11 will become the default instead of C99.

Activation and deactivation of a given warning,
plus set-as-error and remove-as-error.
…rg>`

Also: use `int_of_string_opt` instead of `int_of_string` for slightly
cleaner code.
driver/CommonOptions.ml Outdated Show resolved Hide resolved
xavierleroy and others added 3 commits September 23, 2022 13:54
It has two effects:
- With a GNU toolchain, it's passed down to the preprocessor.
  This influences the contents of standard includes.
- It determines the default effect of the "C11 feature" warning:
     -std=c99: warn on the use of C11 features
     -std=c11 or -std=c18: don't warn

For backward compatiblity, the default, if no `-std` option is given,
is to not warn, but to pass `-std=c99` to the preprocessor.

Co-authored-by: Bernhard Schommer <bschommer@users.noreply.github.com>
The correct -std option is now added by ccomp itself.
Just like in the other test/ directories.
@xavierleroy xavierleroy merged commit a1f01c8 into master Sep 23, 2022
xavierleroy added a commit that referenced this pull request Sep 23, 2022
It has two effects:
- With a GNU toolchain, it's passed down to the preprocessor.
  This influences the contents of standard includes.
- It determines the default effect of the "C11 feature" warning:
     -std=c99: warn on the use of C11 features
     -std=c11 or -std=c18: don't warn

For backward compatiblity, the default, if no `-std` option is given,
is to not warn, but to pass `-std=c99` to the preprocessor.

Co-authored-by: Bernhard Schommer <bschommer@users.noreply.github.com>
@xavierleroy xavierleroy deleted the dash-std branch September 23, 2022 11:55
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