Index: include/llvm/Support/JSON.h =================================================================== --- include/llvm/Support/JSON.h +++ include/llvm/Support/JSON.h @@ -452,7 +452,23 @@ new (reinterpret_cast(Union.buffer)) T(std::forward(V)...); } template T &as() const { +#if defined(__GNUC__) && !defined(__clang) && (__GNUC__ < 7) +// Silence +// +// warning: dereferencing type-punned pointer will break strict-aliasing rules +// [-Wstrict-aliasing] +// +// This private method is always called after type-checking, so the +// reinterpret_cast<> just re-casts the char buffer to the type that was +// placement-new-ed into it. Because AlignedCharArrayUnion guarantees correct +// alignment for all contained types, this plays by the strict aliasing rules. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif return *reinterpret_cast(Union.buffer); +#if defined(__GNUC__) && !defined(__clang) && (__GNUC__ < 7) +#pragma GCC diagnostic pop +#endif } template