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

Switch to C++17 standard #3547

Merged
merged 1 commit into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,12 @@ enable_testing ()
# set (CPACK_PACKAGE_VERSION_PATCH ${CPACK_PACKAGE_VERSION_PATCH}-${__P4C_VERSION_RC})
# endif ()

# set (CMAKE_CXX_EXTENSIONS OFF) # prefer using -std=c++11 rather than -std=gnu++11
# CMAKE_CXX_STANDARD was introduced in CMake 3.1, so for older versions of CMake, we use -std=gnu++11
# set (CMAKE_CXX_EXTENSIONS OFF) # prefer using -std=c++17 rather than -std=gnu++17
# CMAKE_CXX_STANDARD was introduced in CMake 3.1, so for older versions of CMake, we use -std=gnu++17
if (CMAKE_VERSION VERSION_LESS "3.1")
set (CMAKE_CXX_FLAGS "-std=gnu++11 ${CMAKE_CXX_FLAGS}")
elseif(NOT DEFINED CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 11)
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_FLAGS "-std=gnu++17 ${CMAKE_CXX_FLAGS}")
elseif(NOT DEFINED CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 17)
set (CMAKE_CXX_STANDARD 17)
endif ()
set (CMAKE_CXX_STANDARD_REQUIRED ON)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Ubuntu 20.04 is the officially supported platform for p4c. There's also
unofficial support for macOS 10.12. Other platforms are untested; you can try to
use them, but YMMV.

- A C++11 compiler. GCC 4.9 or later or Clang 3.3 or later is required.
- A C++17 compiler. GCC 9.1 or later or Clang 6.0 or later is required.

- `git` for version control

Expand Down Expand Up @@ -370,7 +370,7 @@ We recommend using `clang++` with no optimizations for speeding up
compilation and simplifying debugging.

We recommend installing a new version of [gdb](http://ftp.gnu.org/gnu/gdb).,
because older gdb versions do not always handle C++11 correctly.
because older gdb versions do not always handle C++11 or newer correctly.

We recommend exuberant ctags for navigating source code in Emacs and vi. `sudo
apt-get install exuberant-ctags.` The Makefile targets `make ctags` and `make
Expand Down
1 change: 1 addition & 0 deletions frontends/parsers/p4/p4lexer.ll
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ using Parser = P4::P4Parser;
#pragma GCC diagnostic ignored "-Wtautological-undefined-compare"
#ifdef __clang__
#pragma clang diagnostic ignored "-Wnull-conversion"
#pragma clang diagnostic ignored "-Wregister"
#endif

%}
Expand Down
1 change: 1 addition & 0 deletions frontends/parsers/v1/v1lexer.ll
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ using Parser = V1::V1Parser;
#pragma GCC diagnostic ignored "-Wtautological-undefined-compare"
#ifdef __clang__
#pragma clang diagnostic ignored "-Wnull-conversion"
#pragma clang diagnostic ignored "-Wregister"
#endif

%}
Expand Down
8 changes: 7 additions & 1 deletion lib/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,15 @@ void operator delete(void *p) _GLIBCXX_USE_NOEXCEPT {
gc::operator delete(p);
}

void operator delete(void *p, std::size_t) _GLIBCXX_USE_NOEXCEPT {
if (p >= emergency_pool && p < emergency_pool + sizeof(emergency_pool))
return;
gc::operator delete(p);
}

void *operator new[](std::size_t size) { return ::operator new(size); }
void operator delete[](void *p) _GLIBCXX_USE_NOEXCEPT { ::operator delete(p); }

void operator delete[](void *p, std::size_t) _GLIBCXX_USE_NOEXCEPT { ::operator delete(p); }

namespace {

Expand Down
4 changes: 2 additions & 2 deletions lib/hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ std::uint32_t murmur32(const void* data, std::uint32_t size) {
switch (size) {
case 3:
result ^= static_cast<unsigned char>(raw[2]) << 16;
// fallthrough
[[fallthrough]];
case 2:
result ^= static_cast<unsigned char>(raw[1]) << 8;
// fallthrough
[[fallthrough]];
case 1:
result ^= static_cast<unsigned char>(raw[0]);
result *= m;
Expand Down
1 change: 1 addition & 0 deletions tools/ir-generator/ir-generator-lex.l
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#ifdef __clang__
#pragma clang diagnostic ignored "-Wnull-conversion"
#pragma clang diagnostic ignored "-Wregister"
#endif


Expand Down