From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1551) id 33104386C5A3; Fri, 17 Jun 2022 10:41:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 33104386C5A3 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Pedro Alves To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Fix GDB build with GCC 4.8 & 4.9 X-Act-Checkin: binutils-gdb X-Git-Author: Pedro Alves X-Git-Refname: refs/heads/master X-Git-Oldrev: dac9773e17261f905d51684fe35da036e82c69cd X-Git-Newrev: dfea48fc0f040e87c5d7d4fc34c0610dc0039ad1 Message-Id: <20220617104138.33104386C5A3@sourceware.org> Date: Fri, 17 Jun 2022 10:41:38 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2022 10:41:38 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Ddfea48fc0f04= 0e87c5d7d4fc34c0610dc0039ad1 commit dfea48fc0f040e87c5d7d4fc34c0610dc0039ad1 Author: Pedro Alves Date: Fri Jun 17 11:10:40 2022 +0100 Fix GDB build with GCC 4.8 & 4.9 =20 With gcc 4.8/4.9, we run into this build failure (and other similar ones): =20 /home/palves/gdb/binutils-gdb/src/gdb/location.h:224:59: error: could= not convert =E2=80=98{0, LINE_OFFSET_UNKNOWN}=E2=80=99 from =E2=80=98=E2=80=99 to =E2=80=98line_offset=E2=80=99 struct line_offset line_offset =3D {0, LINE_OFFSET_UNKNOWN}; ^ =20 The issue is that at around the GCC 4.8/4.9 era, a default member initializer prevented the struct from being an aggregate, so you cannot use aggregate initialization on them. That rule changed after GCC 4.9 and GCC 5 & later uses new rules. =20 Fix this by not using aggregate initialization for struct line_offset. The default member initization already leaves line_offset as {0, LINE_OFFSET_UNKNOWN}, so initialization to those values can just go away. The remaining cases are of the form {0, LINE_OFFSET_NONE}, and those cases can be better rewritten to delay setting the sign field until we know we have a valid offset. =20 Change-Id: I0506ea4a83c5fa2f15e159569db68b3b0a7509b4 Diff: --- gdb/linespec.c | 23 ++++++++++++++--------- gdb/location.h | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/gdb/linespec.c b/gdb/linespec.c index 10dca95e767..3db35998f7e 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -1662,7 +1662,7 @@ struct line_offset linespec_parse_line_offset (const char *string) { const char *start =3D string; - struct line_offset line_offset =3D {0, LINE_OFFSET_NONE}; + struct line_offset line_offset; =20 if (*string =3D=3D '+') { @@ -1674,6 +1674,8 @@ linespec_parse_line_offset (const char *string) line_offset.sign =3D LINE_OFFSET_MINUS; ++string; } + else + line_offset.sign =3D LINE_OFFSET_NONE; =20 if (*string !=3D '\0' && !isdigit (*string)) error (_("malformed line offset: \"%s\""), start); @@ -2844,7 +2846,7 @@ linespec_complete_label (completion_tracker &tracker, { linespec_parser parser (0, language, NULL, NULL, 0, NULL); =20 - line_offset unknown_offset =3D { 0, LINE_OFFSET_UNKNOWN }; + line_offset unknown_offset; =20 try { @@ -4062,7 +4064,7 @@ linespec_parse_variable (struct linespec_state *self,= const char *variable) { int index =3D 0; const char *p; - struct line_offset offset =3D {0, LINE_OFFSET_NONE}; + line_offset offset; =20 p =3D (variable[1] =3D=3D '$') ? variable + 2 : variable + 1; if (*p =3D=3D '$') @@ -4081,6 +4083,7 @@ linespec_parse_variable (struct linespec_state *self,= const char *variable) error (_("History values used in line " "specs must have integer values.")); offset.offset =3D value_as_long (val_history); + offset.sign =3D LINE_OFFSET_NONE; } else { @@ -4092,11 +4095,10 @@ linespec_parse_variable (struct linespec_state *sel= f, const char *variable) /* Try it as a convenience variable. If it is not a convenience variable, return and allow normal symbol lookup to occur. */ ivar =3D lookup_only_internalvar (variable + 1); - if (ivar =3D=3D NULL) - /* No internal variable with that name. Mark the offset - as unknown to allow the name to be looked up as a symbol. */ - offset.sign =3D LINE_OFFSET_UNKNOWN; - else + /* If there's no internal variable with that name, let the + offset remain as unknown to allow the name to be looked up + as a symbol. */ + if (ivar !=3D nullptr) { /* We found a valid variable name. If it is not an integer, throw an error. */ @@ -4104,7 +4106,10 @@ linespec_parse_variable (struct linespec_state *self= , const char *variable) error (_("Convenience variables used in line " "specs must have integer values.")); else - offset.offset =3D valx; + { + offset.offset =3D valx; + offset.sign =3D LINE_OFFSET_NONE; + } } } =20 diff --git a/gdb/location.h b/gdb/location.h index fd0b320628d..f9d0f95136c 100644 --- a/gdb/location.h +++ b/gdb/location.h @@ -221,7 +221,7 @@ struct explicit_location_spec : public location_spec /* A line offset relative to the start of the symbol identified by the above fields or the current symtab if the other fields are NULL. */ - struct line_offset line_offset =3D {0, LINE_OFFSET_UNKNOWN}; + struct line_offset line_offset; =20 protected: explicit_location_spec (const explicit_location_spec &other);