8239357: Revert gcc implementation of offset_of

Revert definition of offset_of and reenable -Winvalid-offsetof.

Reviewed-by: erikj, ihse, dholmes
This commit is contained in:
Kim Barrett 2020-04-23 12:57:18 -04:00
parent 079b60c6b9
commit e1f07cd05b
2 changed files with 7 additions and 4 deletions

View File

@ -86,7 +86,7 @@ DISABLED_WARNINGS_gcc := parentheses comment unknown-pragmas address \
delete-non-virtual-dtor char-subscripts array-bounds int-in-bool-context \
ignored-qualifiers missing-field-initializers implicit-fallthrough \
empty-body strict-overflow sequence-point maybe-uninitialized \
misleading-indentation cast-function-type invalid-offsetof
misleading-indentation cast-function-type
ifeq ($(call check-jvm-feature, zero), true)
DISABLED_WARNINGS_gcc += return-type switch clobbered
@ -95,8 +95,7 @@ endif
DISABLED_WARNINGS_clang := tautological-compare \
undefined-var-template sometimes-uninitialized unknown-pragmas \
delete-non-virtual-dtor missing-braces char-subscripts \
ignored-qualifiers missing-field-initializers mismatched-tags \
invalid-offsetof
ignored-qualifiers missing-field-initializers mismatched-tags
DISABLED_WARNINGS_solstudio := labelnotused hidef w_novirtualdescr inlafteruse \
unknownpragma doubunder w_enumnotused w_toomanyenumnotused \

View File

@ -235,7 +235,11 @@ inline int wcslen(const jchar* x) { return wcslen((const wchar_t*)x); }
#define FORMAT64_MODIFIER "ll"
#endif // _LP64
#define offset_of(klass,field) offsetof(klass,field)
// gcc warns about applying offsetof() to non-POD object or calculating
// offset directly when base address is NULL. Use 16 to get around the
// warning. The -Wno-invalid-offsetof option could be used to suppress
// this warning, but we instead just avoid the use of offsetof().
#define offset_of(klass,field) (size_t)((intx)&(((klass*)16)->field) - 16)
#if defined(_LP64) && defined(__APPLE__)
#define JLONG_FORMAT "%ld"