From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id B191F3858422 for ; Mon, 14 Aug 2023 11:17:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B191F3858422 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E3B4321996 for ; Mon, 14 Aug 2023 11:17:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1692011847; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eTKmmTcYcA2B/BlsU1NqC/X74ji8C1GNZ7tuj884UKk=; b=orNfMBN0pVWHOMMWc7+DDUNCRBDQZHlwtOV5+waLzI/o8XnoJz7XSTYdbXbVvXbQrGehLp ws1lG4u1xDL3KYb38+jAZwqSAYPV9RNXii/RK5Xt7JdaDYPV4Q0gcCnUBYMtd98zbQeRKv EbiANyEzUFXAqLnr0hgsmXXWmg8Vcvo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1692011847; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eTKmmTcYcA2B/BlsU1NqC/X74ji8C1GNZ7tuj884UKk=; b=dAs+wPgqdNx5Fn2DV8ajBDROwpSA9wK/mKxNZ8l/EfClzecVLU8AQwWg1PlluJBtvAzr7K rPvH+QG4edUdmADQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C64CB138E2 for ; Mon, 14 Aug 2023 11:17:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ANZjL0cN2mQvHwAAMHmgww (envelope-from ) for ; Mon, 14 Aug 2023 11:17:27 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 3/4] [gdb/build] Fix struct token_and_value odr violation Date: Mon, 14 Aug 2023 13:17:20 +0200 Message-Id: <20230814111721.31402-3-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230814111721.31402-1-tdevries@suse.de> References: <20230814111721.31402-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: When build gdb with -O2 -flto I run into: ... gdb/c-exp.y:3003:8: warning: type 'struct token_and_value' violates the C++ \ One Definition Rule [-Wodr] struct token_and_value ^ gdb/d-exp.y:1310:8: note: a different type is defined in another translation \ unit struct token_and_value ^ ... Fix this by renaming to c_token_and_value and d_token_and_value. Likewise in gdb/go-exp.y, renaming to go_token_and_value. Tested on x86_64-linux. --- gdb/c-exp.y | 8 ++++---- gdb/d-exp.y | 10 +++++----- gdb/go-exp.y | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gdb/c-exp.y b/gdb/c-exp.y index a8c78414253..032ba25274e 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -3000,7 +3000,7 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name) } /* An object of this type is pushed on a FIFO by the "outer" lexer. */ -struct token_and_value +struct c_token_and_value { int token; YYSTYPE value; @@ -3008,7 +3008,7 @@ struct token_and_value /* A FIFO of tokens that have been read but not yet returned to the parser. */ -static std::vector token_fifo; +static std::vector token_fifo; /* Non-zero if the lexer should return tokens from the FIFO. */ static int popping; @@ -3230,7 +3230,7 @@ classify_inner_name (struct parser_state *par_state, static int yylex (void) { - token_and_value current; + c_token_and_value current; int first_was_coloncolon, last_was_coloncolon; struct type *context_type = NULL; int last_to_examine, next_to_examine, checkpoint; @@ -3306,7 +3306,7 @@ yylex (void) while (next_to_examine <= last_to_examine) { - token_and_value next; + c_token_and_value next; next = token_fifo[next_to_examine]; ++next_to_examine; diff --git a/gdb/d-exp.y b/gdb/d-exp.y index b0f2c0d1c10..8620a67e04a 100644 --- a/gdb/d-exp.y +++ b/gdb/d-exp.y @@ -1307,7 +1307,7 @@ lex_one_token (struct parser_state *par_state) } /* An object of this type is pushed on a FIFO by the "outer" lexer. */ -struct token_and_value +struct d_token_and_value { int token; YYSTYPE value; @@ -1316,7 +1316,7 @@ struct token_and_value /* A FIFO of tokens that have been read but not yet returned to the parser. */ -static std::vector token_fifo; +static std::vector token_fifo; /* Non-zero if the lexer should return tokens from the FIFO. */ static int popping; @@ -1404,7 +1404,7 @@ classify_inner_name (struct parser_state *par_state, static int yylex (void) { - token_and_value current; + d_token_and_value current; int last_was_dot; struct type *context_type = NULL; int last_to_examine, next_to_examine, checkpoint; @@ -1467,7 +1467,7 @@ yylex (void) while (next_to_examine <= last_to_examine) { - token_and_value next; + d_token_and_value next; next = token_fifo[next_to_examine]; ++next_to_examine; @@ -1531,7 +1531,7 @@ yylex (void) while (next_to_examine <= last_to_examine) { - token_and_value next; + d_token_and_value next; next = token_fifo[next_to_examine]; ++next_to_examine; diff --git a/gdb/go-exp.y b/gdb/go-exp.y index 5c213f138f0..92abd95a159 100644 --- a/gdb/go-exp.y +++ b/gdb/go-exp.y @@ -1245,7 +1245,7 @@ lex_one_token (struct parser_state *par_state) } /* An object of this type is pushed on a FIFO by the "outer" lexer. */ -struct token_and_value +struct go_token_and_value { int token; YYSTYPE value; @@ -1253,7 +1253,7 @@ struct token_and_value /* A FIFO of tokens that have been read but not yet returned to the parser. */ -static std::vector token_fifo; +static std::vector token_fifo; /* Non-zero if the lexer should return tokens from the FIFO. */ static int popping; @@ -1445,11 +1445,11 @@ classify_name (struct parser_state *par_state, const struct block *block) static int yylex (void) { - token_and_value current, next; + go_token_and_value current, next; if (popping && !token_fifo.empty ()) { - token_and_value tv = token_fifo[0]; + go_token_and_value tv = token_fifo[0]; token_fifo.erase (token_fifo.begin ()); yylval = tv.value; /* There's no need to fall through to handle package.name @@ -1474,7 +1474,7 @@ yylex (void) if (next.token == '.') { - token_and_value name2; + go_token_and_value name2; name2.token = lex_one_token (pstate); name2.value = yylval; -- 2.35.3