From ee86989029bb5fb1d0d561c93b03460b33bbb480 Mon Sep 17 00:00:00 2001 From: Dewey Dunnington Date: Wed, 11 Jan 2023 09:39:26 -0400 Subject: [PATCH] fix fallthrough attribute --- data-raw/update-absl.R | 5 +++++ src/absl/base/attributes.h | 22 ++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/data-raw/update-absl.R b/data-raw/update-absl.R index d313c978..6c361b20 100644 --- a/data-raw/update-absl.R +++ b/data-raw/update-absl.R @@ -159,3 +159,8 @@ usethis::edit_file("src/absl/container/internal/raw_hash_set.h") # CRAN compiles with -Wpedantic, so we can't use the __int128 intrinsic type # undefine ABSL_HAVE_INTRINSIC_INT128 here: usethis::edit_file("src/absl/base/config.h") + +# The use of ABSL_HAVE_CPP_ATTRIBUTE() with ABSL_FALLTHROUGH_INTENDED +# here uses C++17 attributes even if -std=c++17 is not set, +# which causes CRAN warnings with -Wpedantic +usethis::edit_file("src/absl/base/attributes.h") diff --git a/src/absl/base/attributes.h b/src/absl/base/attributes.h index e4e7a3d8..cf611c6b 100644 --- a/src/absl/base/attributes.h +++ b/src/absl/base/attributes.h @@ -629,19 +629,21 @@ // no effect on diagnostics. In any case this macro has no effect on runtime // behavior and performance of code. -#ifdef ABSL_FALLTHROUGH_INTENDED -#error "ABSL_FALLTHROUGH_INTENDED should not be defined." -#elif ABSL_HAVE_CPP_ATTRIBUTE(fallthrough) -#define ABSL_FALLTHROUGH_INTENDED [[fallthrough]] -#elif ABSL_HAVE_CPP_ATTRIBUTE(clang::fallthrough) -#define ABSL_FALLTHROUGH_INTENDED [[clang::fallthrough]] -#elif ABSL_HAVE_CPP_ATTRIBUTE(gnu::fallthrough) -#define ABSL_FALLTHROUGH_INTENDED [[gnu::fallthrough]] -#else +// The use of ABSL_HAVE_CPP_ATTRIBUTE() here uses C++17 attributes +// even if -std=c++17 is not set, which does not work with -Wpedantic on R +// #ifdef ABSL_FALLTHROUGH_INTENDED +// #error "ABSL_FALLTHROUGH_INTENDED should not be defined." +// #elif ABSL_HAVE_CPP_ATTRIBUTE(fallthrough) +// #define ABSL_FALLTHROUGH_INTENDED [[fallthrough]] +// #elif ABSL_HAVE_CPP_ATTRIBUTE(clang::fallthrough) +// #define ABSL_FALLTHROUGH_INTENDED [[clang::fallthrough]] +// #elif ABSL_HAVE_CPP_ATTRIBUTE(gnu::fallthrough) +// #define ABSL_FALLTHROUGH_INTENDED [[gnu::fallthrough]] +// #else #define ABSL_FALLTHROUGH_INTENDED \ do { \ } while (0) -#endif +// #endif // ABSL_DEPRECATED() //