Selaa lähdekoodia

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345870 91177308-0d34-0410-b5e6-96231b3b80d8
Reid Kleckner 6 vuotta sitten
vanhempi
commit
6115b72f60
1 muutettua tiedostoa jossa 5 lisäystä ja 1 poistoa
  1. 5 1
      include/__config

+ 5 - 1
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)