Files
sousa-gecko/build/clang-plugin/tests/TestEmptyBases.cpp
T
serge-sans-paille a55c1eb7b8 Bug 2039238 - Enforce usage of MOZ_EMPTY_BASES r=tsmith
Unlike VS, we're not constrained by legacy behavior and should always
turn this attribute on where it's needed. There's no VS flag for it, but
we can use clang-tidy to detect when it's needed.

It's okay to use that attribute when it has no effect, so don't bother
trying to be smart in dom/bindings/Codegen.py and always add it.

Differential Revision: https://phabricator.services.mozilla.com/D300299
2026-05-14 14:09:57 +00:00

17 lines
459 B
C++

struct EmptyA{};
struct EmptyB{};
struct NonEmpty{
int field;
};
#if defined(_MSC_VER)
# define MOZ_EMPTY_BASES __declspec(empty_bases)
#else
# define MOZ_EMPTY_BASES
#endif
struct MOZ_EMPTY_BASES Some : EmptyA, EmptyB {}; // no-error
struct Some0 : EmptyA, EmptyB {}; // expected-error {{Missing MOZ_EMPTY_BASES}}
struct Some1 : EmptyA, NonEmpty {}; // no-error
struct Some2 : EmptyA, EmptyB, NonEmpty {}; // expected-error {{Missing MOZ_EMPTY_BASES}}