public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Pedro Alves <palves@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Fix GDB build with GCC 4.8 & 4.9 Date: Fri, 17 Jun 2022 10:41:38 +0000 (GMT) [thread overview] Message-ID: <20220617104138.33104386C5A3@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=dfea48fc0f040e87c5d7d4fc34c0610dc0039ad1 commit dfea48fc0f040e87c5d7d4fc34c0610dc0039ad1 Author: Pedro Alves <pedro@palves.net> Date: Fri Jun 17 11:10:40 2022 +0100 Fix GDB build with GCC 4.8 & 4.9 With gcc 4.8/4.9, we run into this build failure (and other similar ones): /home/palves/gdb/binutils-gdb/src/gdb/location.h:224:59: error: could not convert ‘{0, LINE_OFFSET_UNKNOWN}’ from ‘<brace-enclosed initializer list>’ to ‘line_offset’ struct line_offset line_offset = {0, LINE_OFFSET_UNKNOWN}; ^ 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. 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. 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 = string; - struct line_offset line_offset = {0, LINE_OFFSET_NONE}; + struct line_offset line_offset; if (*string == '+') { @@ -1674,6 +1674,8 @@ linespec_parse_line_offset (const char *string) line_offset.sign = LINE_OFFSET_MINUS; ++string; } + else + line_offset.sign = LINE_OFFSET_NONE; if (*string != '\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); - line_offset unknown_offset = { 0, LINE_OFFSET_UNKNOWN }; + line_offset unknown_offset; try { @@ -4062,7 +4064,7 @@ linespec_parse_variable (struct linespec_state *self, const char *variable) { int index = 0; const char *p; - struct line_offset offset = {0, LINE_OFFSET_NONE}; + line_offset offset; p = (variable[1] == '$') ? variable + 2 : variable + 1; if (*p == '$') @@ -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 = value_as_long (val_history); + offset.sign = LINE_OFFSET_NONE; } else { @@ -4092,11 +4095,10 @@ linespec_parse_variable (struct linespec_state *self, 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 = lookup_only_internalvar (variable + 1); - if (ivar == 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 = 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 != 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 = valx; + { + offset.offset = valx; + offset.sign = LINE_OFFSET_NONE; + } } } 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 = {0, LINE_OFFSET_UNKNOWN}; + struct line_offset line_offset; protected: explicit_location_spec (const explicit_location_spec &other);
reply other threads:[~2022-06-17 10:41 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220617104138.33104386C5A3@sourceware.org \ --to=palves@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).