Skip to content

Set standard to C++17 when -std=c++17 or -std=gnu++17 are used #6402

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
Oct 26, 2021
Merged

Set standard to C++17 when -std=c++17 or -std=gnu++17 are used #6402

merged 2 commits into from
Oct 26, 2021

Conversation

lzaoral
Copy link
Contributor

@lzaoral lzaoral commented Oct 20, 2021

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

Based on suggestions by @martin-cs and @tautschnig.
Fixes: #6090
Obsoletes: #6144

@@ -551,6 +551,15 @@ bool c_preprocess_gcc_clang(
#endif
argv.push_back("-std=gnu++14");
break;

case configt::cppt::cpp_standardt::CPP17:
#if defined(__OpenBSD__)
Copy link
Member

Choose a reason for hiding this comment

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

This one is a bit puzzling? Why is OpenBSD different?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks to me like this is a copy-n-paste of all the corresponding c++14, etc, condition blocks above this... And I'm suspecting that "OpenBSD" really means "is the platform using LLVM/clang by default" - which would also cover FreeBSD and similar...

Copy link
Member

Choose a reason for hiding this comment

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

Can we confirm that these platforms indeed default to -std=cpp++XX instead of gnu++XX?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's just copy-pasted from the C++11/14 cases. The change @kroening refers to was made in b811680 as part of #4053 and the PR description says that:

The c_preprocess.cpp source file in ansi-c has been patched to pass the appropriate -std to Clang on OpenBSD. OpenBSD does not use GNU extensions with the system Clang.

@chrisr-diffblue
Copy link
Contributor

I'd suggest that the PR title should probably change - this PR doesn't, as far as I can tell, actually implement C++17 support - it adds some support for passing appropriate C++17 flags to the preprocessor, and detection of compiler C++17 modes. The PR title should probably make that clearer.

@lzaoral lzaoral changed the title Add support for C++17 Set standard to C++17 when -std=c++17 or -std=gnu++17 are used Oct 20, 2021
@lzaoral
Copy link
Contributor Author

lzaoral commented Oct 20, 2021

Thanks @chrisr-diffblue! The PR title should be more appropriate now.

@codecov
Copy link

codecov bot commented Oct 21, 2021

Codecov Report

Merging #6402 (5e12e87) into develop (eff2507) will decrease coverage by 0.00%.
The diff coverage is 50.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #6402      +/-   ##
===========================================
- Coverage    75.98%   75.98%   -0.01%     
===========================================
  Files         1524     1523       -1     
  Lines       164290   164305      +15     
===========================================
+ Hits        124843   124848       +5     
- Misses       39447    39457      +10     
Impacted Files Coverage Δ
src/analyses/goto_check.cpp 88.47% <0.00%> (-0.09%) ⬇️
src/ansi-c/c_preprocess.cpp 34.87% <0.00%> (-0.33%) ⬇️
src/ansi-c/gcc_version.cpp 81.57% <0.00%> (-2.21%) ⬇️
src/goto-cc/gcc_mode.cpp 66.37% <50.00%> (-0.08%) ⬇️
src/util/config.h 60.00% <57.89%> (-2.50%) ⬇️
src/cpp/cpp_parser.cpp 100.00% <100.00%> (ø)
src/solvers/flattening/boolbv_union.cpp 86.66% <0.00%> (-1.57%) ⬇️
src/solvers/flattening/boolbv.cpp 80.51% <0.00%> (-0.12%) ⬇️
src/util/std_expr.h 91.42% <0.00%> (-0.09%) ⬇️
src/solvers/flattening/boolbv_get.cpp 83.00% <0.00%> (-0.09%) ⬇️
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 29ca8a9...5e12e87. Read the comment docs.

lzaoral and others added 2 commits October 21, 2021 19:28
CBMC will be able to understand code that is compiled with -std=c++17 or
-std=gnu++17.  Otherwise, it fell back to C++03 making the code un-parsable.

Fixes: #6090

Co-authored-by: Michael Tautschnig <[email protected]>
Co-authored-by: Lukas Zaoral <[email protected]>
Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

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

Looks good to me; are there any other blockers to this being merged?

@tautschnig tautschnig merged commit fd10a22 into diffblue:develop Oct 26, 2021
@lzaoral lzaoral deleted the c++17-support branch October 26, 2021 12:17
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.

tests fail on parsing noexcept and decltype in c++17 mode
6 participants