aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn W. Bruce <arashikou@gmail.com>2018-07-18 17:49:53 -0700
committerJohn W. Bruce <arashikou@gmail.com>2018-07-18 18:09:13 -0700
commit39c3654e901b4fc35386989cbad49fad8a68c024 (patch)
tree628b2cdb626c110f50bb08ccdbbc8f3c76e57ff9
parentc934cb7eaff31aff63c10f4336dcfc5e6c45d6a3 (diff)
downloadprotobuf-39c3654e901b4fc35386989cbad49fad8a68c024.tar.gz
protobuf-39c3654e901b4fc35386989cbad49fad8a68c024.tar.bz2
protobuf-39c3654e901b4fc35386989cbad49fad8a68c024.zip
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 .
-rw-r--r--src/google/protobuf/stubs/port.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h
index cecefdcb..7c6e2c45 100644
--- a/src/google/protobuf/stubs/port.h
+++ b/src/google/protobuf/stubs/port.h
@@ -243,7 +243,7 @@ static const uint64 kuint64max = GOOGLE_ULONGLONG(0xFFFFFFFFFFFFFFFF);
__has_cpp_attribute(clang::fallthrough)
# define GOOGLE_FALLTHROUGH_INTENDED [[clang::fallthrough]]
# endif
-#elif defined(__GNUC__) && __GNUC__ > 6
+#elif defined(__GNUC__) && __GNUC__ > 6 && __cpp_attributes >= 200809
# define GOOGLE_FALLTHROUGH_INTENDED [[gnu::fallthrough]]
#endif