summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2018-11-01 18:24:03 +0000
committerReid Kleckner <rnk@google.com>2018-11-01 18:24:03 +0000
commitce7223368e20f40041bd781cb15583d743ad7ef0 (patch)
tree12e166021536588d97e52f8cc220c0e520822500
parentb8980b50beeec7bf2e57b61560710a77d36f3be3 (diff)
Use C++11 fallthrough attribute syntax when available and add a break
Summary: This silences the two -Wimplicit-fallthrough warnings clang finds in ItaniumDemangle.h in libc++abi. Clang does not have a GNU attribute spelling for this attribute, so this is necessary. I will commit the same change to the LLVM demangler soon. Reviewers: EricWF, ldionne Subscribers: christof, erik.pilkington, cfe-commits Differential Revision: https://reviews.llvm.org/D53985
-rw-r--r--libcxx/include/__config6
-rw-r--r--libcxxabi/src/demangle/ItaniumDemangle.h1
2 files changed, 6 insertions, 1 deletions
diff --git a/libcxx/include/__config b/libcxx/include/__config
index b9295bf5d5e..8000f406398 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1248,8 +1248,12 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
# define _LIBCPP_DIAGNOSE_ERROR(...)
#endif
-#if __has_attribute(fallthough) || _GNUC_VER >= 700
// Use a function like macro to imply that it must be followed by a semicolon
+#if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
+# define _LIBCPP_FALLTHROUGH() [[fallthrough]]
+#elif __has_cpp_attribute(clang::fallthrough)
+# define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]]
+#elif __has_attribute(fallthough) || _GNUC_VER >= 700
# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
#else
# define _LIBCPP_FALLTHROUGH() ((void)0)
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index 2f4d7863245..f992645fb92 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -2812,6 +2812,7 @@ AbstractManglingParser<Derived, Alloc>::parseCtorDtorName(Node *&SoFar,
SoFar = make<ExpandedSpecialSubstitution>(SSK);
if (!SoFar)
return nullptr;
+ break;
default:
break;
}