Repository navigation
goto-cl: map /std:c++17, /std:c++20, /std:c++latest and the C standards - #9629
Draft
tautschnig wants to merge 2 commits into
Draft
tautschnig wants to merge 2 commits into
tautschnig wants to merge 2 commits into
Conversation
C23 made alignas, alignof, bool, constexpr, false, nullptr and true
keywords, and CBMC's scanner treated them as keywords in C23 in every
mode. Microsoft's cl does not: with /std:clatest, cl 19.51 (Visual
Studio 2026 18.6, checked on Compiler Explorer) compiles
int bool; int true; int false; int alignas; int alignof;
int constexpr; int nullptr;
without a diagnostic at /W4, while it treats typeof, typeof_unqual,
thread_local and static_assert as keywords ("int thread_local;" declares
nothing, warning C4091; the others are syntax errors). typeof,
typeof_unqual and thread_local are keywords only with /std:clatest,
static_assert in all modes. In Visual Studio mode with C23 (cbmc
--winx64 --c23, and goto-cl /std:clatest once goto-cl maps that
option), code that cl accepts, such as "typedef int bool;", therefore
failed to parse.
Treat those seven words as identifiers in Visual Studio mode also in
C23. The other C23 keywords are unchanged: typeof and thread_local
match cl, and _BitInt, a reserved identifier, stays a keyword (cl 19.51
rejects both "_BitInt(8) x;" and "int _BitInt;" in C).
regression/cbmc/constants/predefined-constants1 uses false, true, bool
and nullptr as C23 keywords and therefore becomes gcc-only: Windows
runs the cbmc suite in Visual Studio mode.
Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
goto-cl knew /std:c++14, /std:c++17 and /std:c++latest, all mapped to
C++14 ("we don't have any newer version at the moment"), and
/std:c++11. Any other value, including /std:c++20 (Visual Studio 2019
16.11 and later), only gave a warning and left the C++ standard at
CBMC's default, C++98 on hosts other than Windows, so code using nullptr
or constexpr failed to parse. The C standards /std:c11, /std:c17 and
/std:clatest were not recognised either, so goto-cl could not select
C23.
Map the values that cl 19.51 (Visual Studio 2026 18.6) accepts, checked
on Compiler Explorer (it warns D9002 "ignoring unknown option" for
/std:c89, c99, c23, c++98, c++11, c++23 and c++26):
- /std:c++14 and /std:c++17 select C++14 and C++17;
- /std:c++20, /std:c++23preview and /std:c++latest (_MSVC_LANG 202002L,
202302L and 202400L) select C++17, the newest standard that CBMC's
configuration knows, with a warning. CBMC's C++ front end implements
no feature of the later standards either;
- /std:c11, /std:c17 and /std:clatest (__STDC_VERSION__ 201112L,
201710L and 202312L) select C11, C17 and C23. Without /std, cl
compiles Microsoft's legacy C (no __STDC_VERSION__), for which CBMC
keeps its default, C11.
Start from Visual Studio's default, C++14, also when /std is given, so
that an unknown value (still with a warning) or a C standard leaves
C++14 in place, and use the last /std option, as cl does (warning
D9025 "overriding '/std:c17' with '/std:clatest'"). /std:c++11 keeps
selecting C++11 for GCC command-line compatibility.
The tests use preprocessed input, so that no cl.exe is needed. The
goto-cl suite runs on Windows only; on Linux, with goto-cl a symbolic
link to goto-cc, the new tests pass, and all but cxx14 and cxx17 fail
without this change.
Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #9629 +/- ##
===========================================
+ Coverage 81.29% 81.33% +0.04%
===========================================
Files 1725 1727 +2
Lines 191680 191746 +66
Branches 73 73
===========================================
+ Hits 155835 155966 +131
+ Misses 35845 35780 -65 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
goto-cl knew /std:c++14, /std:c++17 and /std:c++latest, all mapped to
C++14 ("we don't have any newer version at the moment"), and
/std:c++11. Any other value, including /std:c++20 (Visual Studio 2019
16.11 and later), only gave a warning and left the C++ standard at
CBMC's default, C++98 on hosts other than Windows, so code using nullptr
or constexpr failed to parse. The C standards /std:c11, /std:c17 and
/std:clatest were not recognised either, so goto-cl could not select
C23.
Map the values that cl 19.51 (Visual Studio 2026 18.6) accepts, checked
on Compiler Explorer (it warns D9002 "ignoring unknown option" for
/std:c89, c99, c23, c++98, c++11, c++23 and c++26):
202302L and 202400L) select C++17, the newest standard that CBMC's
configuration knows, with a warning. CBMC's C++ front end implements
no feature of the later standards either;
201710L and 202312L) select C11, C17 and C23. Without /std, cl
compiles Microsoft's legacy C (no STDC_VERSION), for which CBMC
keeps its default, C11.
Start from Visual Studio's default, C++14, also when /std is given, so
that an unknown value (still with a warning) or a C standard leaves
C++14 in place, and use the last /std option, as cl does (warning
D9025 "overriding '/std:c17' with '/std:clatest'"). /std:c++11 keeps
selecting C++11 for GCC command-line compatibility.
The tests use preprocessed input, so that no cl.exe is needed. The
goto-cl suite runs on Windows only; on Linux, with goto-cl a symbolic
link to goto-cc, the new tests pass, and all but cxx14 and cxx17 fail
without this change.
Co-authored-by: Kiro kiro-agent@users.noreply.github.com