From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id WWcJLceZm2pc4SsAWB0awg (envelope-from ) for ; Sat, 05 Sep 2026 00:25:43 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=S6NhkdF1; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B2EF71E09E; Sat, 05 Sep 2026 00:25:43 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 3A2C61E091 for ; Sat, 05 Sep 2026 00:25:42 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C3B404BB58DF for ; Sat, 5 Sep 2026 04:25:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C3B404BB58DF Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=S6NhkdF1 Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 2A7D14BB58E8 for ; Sat, 5 Sep 2026 04:24:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2A7D14BB58E8 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2A7D14BB58E8 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788582245; cv=none; b=SCBJ8XoLDVO2XFc6bBb0P9AhSIe+uUOZ5h9q104bCdd/qoFCeoS6Nl4u53w2nOW7nqCp+NUR3S//TC6UUZwI28aallqwr+eD0eCRdciBsdhyxWFm7NlY44sXWU9vzqEBFZITdmkHf6rLJPjNIwhYrUQNDqmQUeAMvQXxmtzHNxU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788582245; c=relaxed/simple; bh=OZWNv8LvwrCt0NfDBM2CUiF9n9odB3QwLegCREVP4wo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=C7GQ/W3OvnMLUQmu6dAOrAxhbPHnEOp1phgfBqyvUC1N53LkasDqKZI1ClrcfBqSss3sv47hj1AWGQBTs4gKHQgg+g9o0ZhHmcWX+OiISlu+vjfO19BkXP/N92O+J3MtK/uxAJXV/g0pyWs27c99Fl7GxPgLQoowHwOAZmVOAyY= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=S6NhkdF1 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A7D14BB58E8 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 6854NwpT081227 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 5 Sep 2026 00:24:03 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 6854NwpT081227 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1788582243; bh=XF4vSFxTHme5lvxSSGSgd3k/y8i+Wpb0Z5+jH5l+NO8=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=S6NhkdF1liqnZFDLIkwEx/AzwrDW6fWidhoaV0E64gSQVj7oPU+5JcnbC1GdnhLBg MAY83s1z7EPZuY0KA+tC/AnYEc0zc1jD8ckJUHtzDCzi8xrxFleIwr2P9lXB+Jyo2z nNrZikjdMxsZwQ4xHgZAiNJ9TQT/2v1N2MwJ9tuRVHp/up9kF7fbgExFEHc3gAn21w hfF8AInPdpr5U4eCh9RHgTW+6owds0X1Gm6IifGyU+1/OBRpFzaDi7uuAXQDTnWJzQ C4KXU5k1IeSV6lD1HnYBgieLpo/leBAZ+6VxbJAUu4lzJxsqLhmcgVm2kH40AEaqxh t3IABnw6fAw9A== Received: by simark.ca (Postfix) id 6B79D1E167; Sat, 05 Sep 2026 00:23:57 -0400 (EDT) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v2 03/19] gdb: suffix flex/bison output files with -gen.c Date: Sat, 5 Sep 2026 00:23:06 -0400 Message-ID: <20260905042353.1702204-4-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260905042353.1702204-1-simon.marchi@polymtl.ca> References: <20260905042353.1702204-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Sat, 5 Sep 2026 04:23:58 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org From: Simon Marchi We already have some generated files using the -gen.c suffix. I think it's useful to quickly spot that a file is generated and should generally not be modified by hand. Change the output bison files to use that suffix too, as well as ada-lex.c while at it. The other reason I want to do this change is that I want to move as much C++ code out of the .y files, into dedicated C++ files. Logically, I would move code out from foo-exp.y into a new file called foo-exp.c. Naming the generated file foo-exp-gen.c instead of foo-exp.c allows me to do this. Until now, our own %.c: %.y and %.c: %.l pattern rules overrode make's built-in rules of the same name. Renaming ours to %-gen.c re-enables the built-in ones, which is a problem for my intended use case of having a hand-written /foo-exp.c, as make would generate /foo-exp.c from /foo-exp.y, thus hiding /foo-exp.c. Cancel the built-in rules to avoid this. Change-Id: I2a80e9e4c73c6a19b0e5a86b1eb2e28b9e9ee6bb --- gdb/.gitignore | 18 ++++++++--------- gdb/Makefile.in | 53 ++++++++++++++++++++++++++++--------------------- gdb/ada-exp.y | 4 ++-- 3 files changed, 41 insertions(+), 34 deletions(-) diff --git a/gdb/.gitignore b/gdb/.gitignore index a68ed4e33178..c4d0f0595448 100644 --- a/gdb/.gitignore +++ b/gdb/.gitignore @@ -5,16 +5,16 @@ /version.c /xml-builtin.c -/ada-exp.c -/ada-lex.c -/c-exp.c -/cp-name-parser.c -/d-exp.c -/f-exp.c +/ada-exp-gen.c +/ada-lex-gen.c +/c-exp-gen.c +/cp-name-parser-gen.c +/d-exp-gen.c +/f-exp-gen.c /gdb /gcore -/go-exp.c +/go-exp-gen.c /init.c /jit-reader.h -/m2-exp.c -/p-exp.c +/m2-exp-gen.c +/p-exp-gen.c diff --git a/gdb/Makefile.in b/gdb/Makefile.in index d1574ec2d2cb..aeafb9394d7b 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -128,8 +128,8 @@ COMPILE = $(ECHO_CXX) $(COMPILE.pre) $(INTERNAL_CFLAGS) $(CXXFLAGS) \ YACC = @YACC@ -# This is used to rebuild ada-lex.c from ada-lex.l. If the program is -# not defined, but ada-lex.c is present, compilation will continue, +# This is used to rebuild ada-lex-gen.c from ada-lex.l. If the program +# is not defined, but ada-lex-gen.c is present, compilation will continue, # possibly with a warning. FLEX = flex @@ -2058,19 +2058,19 @@ REQUIRED_SUBDIRS = doc | testsuite | data-directory # Parser intermediate files. YYFILES = \ - ada-exp.c \ - ada-lex.c \ - c-exp.c \ - cp-name-parser.c \ - d-exp.c \ - f-exp.c \ - go-exp.c \ - m2-exp.c \ - p-exp.c - -# ada-lex.c is included by another file, so it shouldn't wind up as a -# .o itself. -YYOBJ = $(filter-out ada-lex.o,$(patsubst %.c,%.o,$(YYFILES))) + ada-exp-gen.c \ + ada-lex-gen.c \ + c-exp-gen.c \ + cp-name-parser-gen.c \ + d-exp-gen.c \ + f-exp-gen.c \ + go-exp-gen.c \ + m2-exp-gen.c \ + p-exp-gen.c + +# ada-lex-gen.c is included by another file, so it shouldn't wind up as +# a .o itself. +YYOBJ = $(filter-out ada-lex-gen.o,$(patsubst %.c,%.o,$(YYFILES))) # Things which need to be built when making a distribution. @@ -2079,7 +2079,7 @@ DISTSTUFF = $(YYFILES) # All generated files which can be included by another file. generated_files = \ - ada-lex.c \ + ada-lex-gen.c \ config.h \ jit-reader.h \ $(NAT_GENERATED_FILES) \ @@ -2339,7 +2339,7 @@ INIT_FILES_FILTER_OUT = \ INIT_FILES = \ $(patsubst %.o,%.c, \ - $(patsubst %-exp.o,%-exp.y, \ + $(patsubst %-exp-gen.o,%-exp.y, \ $(filter-out $(INIT_FILES_FILTER_OUT), $(COMMON_OBS)))) init.c: stamp-init; @true @@ -2678,15 +2678,22 @@ po/$(PACKAGE).pot: force # # YACC/LEX dependencies # -# LANG-exp.c is generated in objdir from LANG-exp.y if it doesn't -# exist in srcdir, then compiled in objdir to LANG-exp.o. If we -# said LANG-exp.c rather than ./c-exp.c some makes would -# sometimes re-write it into $(srcdir)/c-exp.c. Remove bogus +# LANG-exp-gen.c is generated in objdir from LANG-exp.y if it doesn't +# exist in srcdir, then compiled in objdir to LANG-exp-gen.o. If we +# said LANG-exp-gen.c rather than ./c-exp-gen.c some makes would +# sometimes re-write it into $(srcdir)/c-exp-gen.c. Remove bogus # decls for malloc/realloc/free which conflict with everything else. -# Strictly speaking c-exp.c should therefore depend on +# Strictly speaking c-exp-gen.c should therefore depend on # Makefile.in, but that was a pretty big annoyance. +# Cancel make's built-in rules for producing a .c file from a .y or .l +# file, to avoid them producing a /foo-exp.c file from +# /foo-exp.y, when we also have a hand-written /foo-exp.c +# file. %.c: %.y +%.c: %.l + +%-gen.c: %.y $(ECHO_YACC) $(SHELL) $(YLWRAP) $< y.tab.c $@.tmp -- \ $(YACC) $(YFLAGS) || (rm -f $@.tmp; false) @sed -e '/extern.*malloc/d' \ @@ -2705,7 +2712,7 @@ po/$(PACKAGE).pot: force < $@.tmp > $@.new && \ rm -f $@.tmp && \ mv $@.new $@ -%.c: %.l +%-gen.c: %.l $(ECHO_LEX) $(FLEX) -t $< > $@.tmp || (rm -f $@.tmp; false) @sed -e '/extern.*malloc/d' \ -e '/extern.*realloc/d' \ diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 7fd0e6d7c7db..bffe94a8de9b 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -1234,7 +1234,7 @@ primary : '*' primary %prec '.' %% -/* yylex defined in ada-lex.c: Reads one token, getting characters */ +/* yylex defined in ada-lex-gen.c: Reads one token, getting characters */ /* through lexptr. */ /* Remap normal flex interface names (yylex) as well as gratuitously */ @@ -1254,7 +1254,7 @@ primary : '*' primary %prec '.' /* The following kludge was found necessary to prevent conflicts between */ /* defs.h and non-standard stdlib.h files. */ #define qsort __qsort__dummy -#include "ada-lex.c" +#include "ada-lex-gen.c" int ada_parse (struct parser_state *par_state) -- 2.55.0