diff options
author | Moonchild <moonchild@palemoon.org> | 2023-11-12 20:30:17 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2023-11-12 20:30:17 +0000 |
commit | db4ddc5f6855fdd89cf2af9090f78fb7ebb7f032 (patch) | |
tree | 8036ebc434967a0cde3de705a16faea54d117bfd /mfbt | |
parent | c789882a294d29b3e5450a972ad67c4839c75e23 (diff) | |
parent | 9c75c8235e13e0f8309b11fa138253350bce0dd5 (diff) | |
download | uxp-db4ddc5f6855fdd89cf2af9090f78fb7ebb7f032.tar.gz |
Merge pull request 'Replace MOZ_FALLTHROUGH with [[fallthrough]]' (#2379) from 2343-fallthrough-work into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/2379
Diffstat (limited to 'mfbt')
-rw-r--r-- | mfbt/Assertions.h | 4 | ||||
-rw-r--r-- | mfbt/Attributes.h | 44 |
2 files changed, 2 insertions, 46 deletions
diff --git a/mfbt/Assertions.h b/mfbt/Assertions.h index 09a1b8eaa6..a965ae6f1d 100644 --- a/mfbt/Assertions.h +++ b/mfbt/Assertions.h @@ -554,7 +554,7 @@ struct AssertionConditionType * default: * // This case wants to assert in debug builds, fall through in release. * MOZ_ASSERT(false); // -Wimplicit-fallthrough warning in release builds! - * MOZ_FALLTHROUGH; // but -Wunreachable-code warning in debug builds! + * [[fallthrough]]; // but -Wunreachable-code warning in debug builds! * case 5: * return 5; * } @@ -571,7 +571,7 @@ struct AssertionConditionType #ifdef DEBUG # define MOZ_FALLTHROUGH_ASSERT(reason) MOZ_CRASH("MOZ_FALLTHROUGH_ASSERT: " reason) #else -# define MOZ_FALLTHROUGH_ASSERT(...) MOZ_FALLTHROUGH +# define MOZ_FALLTHROUGH_ASSERT(...) [[fallthrough]] #endif /* diff --git a/mfbt/Attributes.h b/mfbt/Attributes.h index fdd253d357..5da4ffe948 100644 --- a/mfbt/Attributes.h +++ b/mfbt/Attributes.h @@ -238,50 +238,6 @@ #ifdef __cplusplus -/** - * MOZ_FALLTHROUGH is an annotation to suppress compiler warnings about switch - * cases that fall through without a break or return statement. MOZ_FALLTHROUGH - * is only needed on cases that have code. - * - * MOZ_FALLTHROUGH_ASSERT is an annotation to suppress compiler warnings about - * switch cases that MOZ_ASSERT(false) (or its alias MOZ_ASSERT_UNREACHABLE) in - * debug builds, but intentionally fall through in release builds. See comment - * in Assertions.h for more details. - * - * switch (foo) { - * case 1: // These cases have no code. No fallthrough annotations are needed. - * case 2: - * case 3: // This case has code, so a fallthrough annotation is needed! - * foo++; - * MOZ_FALLTHROUGH; - * case 4: - * return foo; - * - * default: - * // This case asserts in debug builds, falls through in release. - * MOZ_FALLTHROUGH_ASSERT("Unexpected foo value?!"); - * case 5: - * return 5; - * } - */ -#ifndef __has_cpp_attribute -# define __has_cpp_attribute(x) 0 -#endif - -#if __has_cpp_attribute(clang::fallthrough) -# define MOZ_FALLTHROUGH [[clang::fallthrough]] -#elif __has_cpp_attribute(gnu::fallthrough) -# define MOZ_FALLTHROUGH [[gnu::fallthrough]] -#elif defined(_MSC_VER) - /* - * MSVC's __fallthrough annotations are checked by /analyze (Code Analysis): - * https://msdn.microsoft.com/en-us/library/ms235402%28VS.80%29.aspx - */ -# include <sal.h> -# define MOZ_FALLTHROUGH __fallthrough -#else -# define MOZ_FALLTHROUGH /* FALLTHROUGH */ -#endif /* * MOZ_ASAN_BLACKLIST is a macro to tell AddressSanitizer (a compile-time * instrumentation shipped with Clang and GCC) to not instrument the annotated |