1 From 4cea86e76af28b28aa72cb7c69ff7cf242b2bd5d Mon Sep 17 00:00:00 2001
2 From: Stephan Hartmann <stha09@googlemail.com>
3 Date: Sat, 27 Jun 2020 12:18:05 +0000
4 Subject: [PATCH] GCC: supress invalid-offsetof warning
6 GCC emits a warning if offsetof is used for non-POD
7 types. However, GCC supports this and prints only
8 the warning, because it might be nonportable code.
9 Disable the warning for GCC with a pragma.
11 src/net/third_party/quiche/src/quic/core/frames/quic_frame.h | 7 +++++++
12 .../quiche/src/quic/core/frames/quic_inlined_frame.h | 7 +++++++
13 2 files changed, 14 insertions(+)
15 diff --git a/src/net/third_party/quiche/src/quic/core/frames/quic_frame.h b/src/net/third_party/quiche/src/quic/core/frames/quic_frame.h
16 index 756b69f..aceba76 100644
17 --- a/src/net/third_party/quiche/src/quic/core/frames/quic_frame.h
18 +++ b/src/net/third_party/quiche/src/quic/core/frames/quic_frame.h
19 @@ -110,8 +110,15 @@ struct QUIC_EXPORT_PRIVATE QuicFrame {
21 static_assert(sizeof(QuicFrame) <= 24,
22 "Frames larger than 24 bytes should be referenced by pointer.");
23 +#if defined(__GNUC__)
24 +#pragma GCC diagnostic push
25 +#pragma GCC diagnostic ignored "-Winvalid-offsetof"
27 static_assert(offsetof(QuicStreamFrame, type) == offsetof(QuicFrame, type),
28 "Offset of |type| must match in QuicFrame and QuicStreamFrame");
29 +#if defined(__GNUC__)
30 +#pragma GCC diagnostic pop
33 // A inline size of 1 is chosen to optimize the typical use case of
34 // 1-stream-frame in QuicTransmissionInfo.retransmittable_frames.
35 diff --git a/src/net/third_party/quiche/src/quic/core/frames/quic_inlined_frame.h b/src/net/third_party/quiche/src/quic/core/frames/quic_inlined_frame.h
36 index 08c4869..804e4bb 100644
37 --- a/src/net/third_party/quiche/src/quic/core/frames/quic_inlined_frame.h
38 +++ b/src/net/third_party/quiche/src/quic/core/frames/quic_inlined_frame.h
39 @@ -17,8 +17,15 @@ namespace quic {
40 template <typename DerivedT>
41 struct QUIC_EXPORT_PRIVATE QuicInlinedFrame {
42 QuicInlinedFrame(QuicFrameType type) : type(type) {
43 +#if defined(__GNUC__)
44 +#pragma GCC diagnostic push
45 +#pragma GCC diagnostic ignored "-Winvalid-offsetof"
47 static_assert(offsetof(DerivedT, type) == 0,
48 "type must be the first field.");
49 +#if defined(__GNUC__)
50 +#pragma GCC diagnostic pop
52 static_assert(sizeof(DerivedT) <= 24,
53 "Frames larger than 24 bytes should not be inlined.");