Skip to content

Commit

Permalink
fix fallthrough attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
paleolimbot committed Jan 11, 2023
1 parent cc3fe35 commit ee86989
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
5 changes: 5 additions & 0 deletions data-raw/update-absl.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
22 changes: 12 additions & 10 deletions src/absl/base/attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
//
Expand Down

0 comments on commit ee86989

Please sign in to comment.