Skip to content

Commit 39c3654

Browse files
committed
Do Not Define GOOGLE_FALLTHROUGH_INTENDED on GCC Without Attribute Support
The definition of GOOGLE_FALLTHROUGH_INTENDED assumed that [[gnu::fallthrough]] was always available on GCC 7+. While gnu::fallthrough is supported on GCC 7+, C++ attributes themselves are not supported on GCC if the C++ standard is before C++11. As a fix, the guard on this definition has been expanded to include a check for C++ attribute support. The form of this check is the one recommended by GCC at https://gcc.gnu.org/projects/cxx-status.html .
1 parent c934cb7 commit 39c3654

File tree

1 file changed

+1
-1
lines changed
  • src/google/protobuf/stubs

1 file changed

+1
-1
lines changed

src/google/protobuf/stubs/port.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static const uint64 kuint64max = GOOGLE_ULONGLONG(0xFFFFFFFFFFFFFFFF);
243243
__has_cpp_attribute(clang::fallthrough)
244244
# define GOOGLE_FALLTHROUGH_INTENDED [[clang::fallthrough]]
245245
# endif
246-
#elif defined(__GNUC__) && __GNUC__ > 6
246+
#elif defined(__GNUC__) && __GNUC__ > 6 && __cpp_attributes >= 200809
247247
# define GOOGLE_FALLTHROUGH_INTENDED [[gnu::fallthrough]]
248248
#endif
249249

0 commit comments

Comments
 (0)