From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id BCB05385842A for ; Mon, 14 Aug 2023 11:17:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BCB05385842A 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-out2.suse.de (Postfix) with ESMTPS id EEF211FD63 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=3J21AozGzwkS6mjMUTQIGz2hsn3gJjstNAesifR84cU=; b=mbWfz0PMOGGHiUKOzGNjHxNjoRPDit45nOZX6X6GoHGWt4vK95R4R8RXh1i9oGOz79Y/yA oxa20RbIdQoCYW7kVi2QldC4l0XlVAA/B9RMWxj/wQppXKooP6WlaTd93OmgPeWYEZ7uUD uWMJKbH+H69xikZwaIDVgwfd8ZrJ7Vs= 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=3J21AozGzwkS6mjMUTQIGz2hsn3gJjstNAesifR84cU=; b=6scJ6nGaGcSFm7pjzE7ihaN7nmNxxJYHyZslkXtBlsYY1SFIWfbsrC//U+kjwnCyvSfuQd 2hHA+ZiuSTppM7Cw== 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 DCCA613AA6 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 EHTENEcN2mQvHwAAMHmgww (envelope-from ) for ; Mon, 14 Aug 2023 11:17:27 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 4/4] [gdb/build] Fix struct token odr violation Date: Mon, 14 Aug 2023 13:17:21 +0200 Message-Id: <20230814111721.31402-4-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=-11.9 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 building gdb with -O2 -flto I run into: ... /data/vries/gdb/src/gdb/c-exp.y:2450:8: warning: type 'struct token' \ violates the C++ One Definition Rule [-Wodr] struct token ^ /data/vries/gdb/src/gdb/d-exp.y:939:8: note: a different type is defined in \ another translation unit struct token ^ ... Fix this by renaming to c_token and d_token. Likewise in: - fortran-exp.y, renaming to f_token, - go-exp.y, renaming to go_token, and - p-exp.y, renaming to p_token. Tested on x86_64-linux. --- gdb/c-exp.y | 8 ++++---- gdb/d-exp.y | 8 ++++---- gdb/f-exp.y | 8 ++++---- gdb/go-exp.y | 8 ++++---- gdb/p-exp.y | 6 +++--- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 032ba25274e..a27dbfa608f 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -2447,7 +2447,7 @@ enum token_flag }; DEF_ENUM_FLAGS_TYPE (enum token_flag, token_flags); -struct token +struct c_token { const char *oper; int token; @@ -2455,7 +2455,7 @@ struct token token_flags flags; }; -static const struct token tokentab3[] = +static const struct c_token tokentab3[] = { {">>=", ASSIGN_MODIFY, BINOP_RSH, 0}, {"<<=", ASSIGN_MODIFY, BINOP_LSH, 0}, @@ -2463,7 +2463,7 @@ static const struct token tokentab3[] = {"...", DOTDOTDOT, OP_NULL, 0} }; -static const struct token tokentab2[] = +static const struct c_token tokentab2[] = { {"+=", ASSIGN_MODIFY, BINOP_ADD, 0}, {"-=", ASSIGN_MODIFY, BINOP_SUB, 0}, @@ -2494,7 +2494,7 @@ static const struct token tokentab2[] = multi-word type names (for example 'double' can appear in 'long double') need to be listed here. type-specifiers that are only ever single word (like 'char') are handled by the classify_name function. */ -static const struct token ident_tokens[] = +static const struct c_token ident_tokens[] = { {"unsigned", UNSIGNED, OP_NULL, 0}, {"template", TEMPLATE, OP_NULL, FLAG_CXX}, diff --git a/gdb/d-exp.y b/gdb/d-exp.y index 8620a67e04a..6c5569a1c8d 100644 --- a/gdb/d-exp.y +++ b/gdb/d-exp.y @@ -936,21 +936,21 @@ parse_string_or_char (const char *tokptr, const char **outptr, return quote == '\'' ? CHARACTER_LITERAL : STRING_LITERAL; } -struct token +struct d_token { const char *oper; int token; enum exp_opcode opcode; }; -static const struct token tokentab3[] = +static const struct d_token tokentab3[] = { {"^^=", ASSIGN_MODIFY, BINOP_EXP}, {"<<=", ASSIGN_MODIFY, BINOP_LSH}, {">>=", ASSIGN_MODIFY, BINOP_RSH}, }; -static const struct token tokentab2[] = +static const struct d_token tokentab2[] = { {"+=", ASSIGN_MODIFY, BINOP_ADD}, {"-=", ASSIGN_MODIFY, BINOP_SUB}, @@ -975,7 +975,7 @@ static const struct token tokentab2[] = }; /* Identifier-like tokens. */ -static const struct token ident_tokens[] = +static const struct d_token ident_tokens[] = { {"is", IDENTITY, OP_NULL}, {"!is", NOTIDENTITY, OP_NULL}, diff --git a/gdb/f-exp.y b/gdb/f-exp.y index 19e4c702c14..18566afd67f 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -1219,7 +1219,7 @@ convert_to_kind_type (struct type *basetype, int kind) return nullptr; } -struct token +struct f_token { /* The string to match against. */ const char *oper; @@ -1237,7 +1237,7 @@ struct token /* List of Fortran operators. */ -static const struct token fortran_operators[] = +static const struct f_token fortran_operators[] = { { ".and.", BOOL_AND, OP_NULL, false }, { ".or.", BOOL_OR, OP_NULL, false }, @@ -1278,7 +1278,7 @@ static const struct f77_boolean_val boolean_values[] = { ".false.", 0 } }; -static const struct token f_intrinsics[] = +static const struct f_token f_intrinsics[] = { /* The following correspond to actual functions in Fortran and are case insensitive. */ @@ -1300,7 +1300,7 @@ static const struct token f_intrinsics[] = { "sizeof", SIZEOF, OP_NULL, false }, }; -static const token f_keywords[] = +static const f_token f_keywords[] = { /* Historically these have always been lowercase only in GDB. */ { "character", CHARACTER, OP_NULL, true }, diff --git a/gdb/go-exp.y b/gdb/go-exp.y index 92abd95a159..28bf3f0ab33 100644 --- a/gdb/go-exp.y +++ b/gdb/go-exp.y @@ -898,14 +898,14 @@ parse_string_or_char (const char *tokptr, const char **outptr, return quote == '\'' ? CHAR : STRING; } -struct token +struct go_token { const char *oper; int token; enum exp_opcode opcode; }; -static const struct token tokentab3[] = +static const struct go_token tokentab3[] = { {">>=", ASSIGN_MODIFY, BINOP_RSH}, {"<<=", ASSIGN_MODIFY, BINOP_LSH}, @@ -913,7 +913,7 @@ static const struct token tokentab3[] = {"...", DOTDOTDOT, OP_NULL}, }; -static const struct token tokentab2[] = +static const struct go_token tokentab2[] = { {"+=", ASSIGN_MODIFY, BINOP_ADD}, {"-=", ASSIGN_MODIFY, BINOP_SUB}, @@ -939,7 +939,7 @@ static const struct token tokentab2[] = }; /* Identifier-like tokens. */ -static const struct token ident_tokens[] = +static const struct go_token ident_tokens[] = { {"true", TRUE_KEYWORD, OP_NULL}, {"false", FALSE_KEYWORD, OP_NULL}, diff --git a/gdb/p-exp.y b/gdb/p-exp.y index b086bf73a0e..2360a500476 100644 --- a/gdb/p-exp.y +++ b/gdb/p-exp.y @@ -994,14 +994,14 @@ pop_current_type (void) } } -struct token +struct p_token { const char *oper; int token; enum exp_opcode opcode; }; -static const struct token tokentab3[] = +static const struct p_token tokentab3[] = { {"shr", RSH, OP_NULL}, {"shl", LSH, OP_NULL}, @@ -1014,7 +1014,7 @@ static const struct token tokentab3[] = {"xor", XOR, OP_NULL} }; -static const struct token tokentab2[] = +static const struct p_token tokentab2[] = { {"or", OR, OP_NULL}, {"<>", NOTEQUAL, OP_NULL}, -- 2.35.3