Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1927601ybl; Thu, 30 Jan 2020 08:26:12 -0800 (PST) X-Google-Smtp-Source: APXvYqzdHjwLPXKDrBW0/UxICgkWhYOQe+GmIwRIYA3ZoJoRTsWWJ+zobLr0d3xqPkvXMF5ON0Kl X-Received: by 2002:aca:5083:: with SMTP id e125mr3487243oib.96.1580401572141; Thu, 30 Jan 2020 08:26:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580401572; cv=none; d=google.com; s=arc-20160816; b=Z/19il/Z0M4WCvFpUi1PbijSg5WtdObx+ckuN4o5bh0CufzsfNBMbqBfIMq9XXwExW tapOXwpapeFwRexfJFefRPvpArHEcPJMnOk9Xo/0hkt2SdQRw4j4K891OqxkA98qJz4r TKKVGcAucVNxElM9E62koW3dNZUJ7WEgPz4TBZRzk21P00ONtIfci4J782x4i9Nn9LPE bD8W0iSsk2aEC8q8SPqA+wiO/oVc6Pi53ET3Aeg1d3mHEK5D8u/jv/fIhAn9SRM7y6eo tkmwUU97b8V/QXqa3R/oeJzlFBDtHvSBFNUq+dBnsMXWzo/91VRAhwuyQsh8yW9oTCUK XnBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=2gREjzEu+n1RGwcI4Ki/0u5ITWrtl7Q643uPluzcC6Q=; b=H+FRXbY3P/kp/oSc8uorpO5ldNbL67Fx58ZGoYCrMcRj6Eejvx/BrI9SfxzcL9QeeW aWH5yVseYViN4/MAJaelsbr5wlc+YknckRZQQCuDwpXmzjwuWqiLTNSScvurhUPSa+Eb pnm1hH4REBakgz29FNGnfVkSmu20wIB8fqkAZibyOP8tYPQisYqN1l1AnL4uC+R6Qlf7 SJ2NCkGdrYs/s2tDgBPM+kpgPxHRrmtmQn9lXsb/LUmgtFucChql3O3Kt5zB9IJGqSNm hiWZKcfGIU16Nb+1ChgYyUDpIqCeqWe+x6p89+iilU2NT1w9+r1mvuvygcUwRjVYefoT drbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Jrv0WHN7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 38si3557849otu.166.2020.01.30.08.26.00; Thu, 30 Jan 2020 08:26:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Jrv0WHN7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727401AbgA3QXr (ORCPT + 99 others); Thu, 30 Jan 2020 11:23:47 -0500 Received: from mail-io1-f68.google.com ([209.85.166.68]:40963 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727158AbgA3QXq (ORCPT ); Thu, 30 Jan 2020 11:23:46 -0500 Received: by mail-io1-f68.google.com with SMTP id m25so4653020ioo.8; Thu, 30 Jan 2020 08:23:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2gREjzEu+n1RGwcI4Ki/0u5ITWrtl7Q643uPluzcC6Q=; b=Jrv0WHN7yRVxfBnyMJ72ZzWz6N5sC8I1J6CH3a++mf5Dedod2NjdUrkqUU6KrccI6h 5xg/WqoB11z2trhDWikP2SxkNlMgZu2MjbbFqmg7QKquqqa7iUHYke0qa2AU39FRx2hD XzxM/Bof/YO9jGjxnwu0McGA8WAYbSgfZ0Qvos+A8e9pAvVUgG6uUONoBDSCU+zbAUNu 37TgqEtZEyv51BYDyEp5FO4LZeB7zpmZPf0Ow4dRC1aUiTq+wtFUkCziCj91ENmsTQtp UaoEe5highcynG0TZzsUYySaePbWu6B6IDTYtvuu1gAS37+peP54GXNchSBenEkvBwK+ F22A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2gREjzEu+n1RGwcI4Ki/0u5ITWrtl7Q643uPluzcC6Q=; b=VQjXFPand3XQmtWkg8Q1GZT3vZpkcBchokrBpWUp3DvIdGhyADsizQIMAq1xLfJ9MB kogJhdaWq+aXl0WXA+1UwBYLOAWcs1D+s4tXgcV54X6XhnZVHk5RcZUzmiFgbgbb+72K cH6wrcSBf0ILfETR+JNSE0psDex8PcACdE98xjRua7CZrvH7h370IlZq7U9DnlEfbZNx ASl4TC0n7t3jI/EbGEZDVUnfhZdTGQLjV+8Nq9e+q+uYTrh9NEcknj6rK/fuNxE6zyLd E1A4aECo8xRfbGtl7zcWagyyncf/5aNQJxqgt4XgGBnb1C/PEyBiJ2g6NmD76WQ1EkQj QRMA== X-Gm-Message-State: APjAAAV/BCjUy4q7p4NJKD8AylTbbvRI4oB/jh//8bl6nvAjrzx9DU8f CMaKpaMpDCZ4JyqgjaM68Ek= X-Received: by 2002:a5e:8a03:: with SMTP id d3mr4837467iok.269.1580401425755; Thu, 30 Jan 2020 08:23:45 -0800 (PST) Received: from localhost.localdomain ([216.249.49.11]) by smtp.googlemail.com with ESMTPSA id l2sm2035951ilo.6.2020.01.30.08.23.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2020 08:23:45 -0800 (PST) From: Ethan Sommer Cc: Ethan Sommer , Masahiro Yamada , Michal Marek , Nathan Chancellor , Nick Desaulniers , Sedat Dilek , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] make yacc usage POSIX-compliant Date: Thu, 30 Jan 2020 11:23:11 -0500 Message-Id: <20200130162314.31449-1-e5ten.arch@gmail.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org use -b and -d to generate correctly named source and header files, instead of bison-specific --defines and non-POSIX -o check that YACC command is found in path or is an executable file, instead of using bison-specific --version flag to display an error when it is missing explicitly define yyltype in scripts/genksyms/lex.l, instead of relying on bison automatically defining it replace bison-specific %destructor use in scripts/kconfig/parser.y dtc's yacc usage is not covered here, as its use of bison-specific features is much greater, and it is only built on certain architectures, unlike kconfig and genksyms Signed-off-by: Ethan Sommer --- scripts/Makefile.host | 2 +- scripts/genksyms/Makefile | 6 ++++-- scripts/genksyms/lex.l | 2 ++ scripts/kconfig/parser.y | 14 +++++++------- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/scripts/Makefile.host b/scripts/Makefile.host index 4c51c95d40f4..64e98e1d4825 100644 --- a/scripts/Makefile.host +++ b/scripts/Makefile.host @@ -11,7 +11,7 @@ $(obj)/%.lex.c: $(src)/%.l FORCE # YACC # --------------------------------------------------------------------------- quiet_cmd_bison = YACC $(basename $@).[ch] - cmd_bison = $(YACC) -o $(basename $@).c --defines=$(basename $@).h -t -l $< + cmd_bison = $(YACC) -b $(basename $(basename $@)) -d -t -l $< $(obj)/%.tab.c $(obj)/%.tab.h: $(src)/%.y FORCE $(call if_changed,bison) diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile index 78629f515e78..1e120328fa88 100644 --- a/scripts/genksyms/Makefile +++ b/scripts/genksyms/Makefile @@ -14,9 +14,11 @@ genksyms-objs := genksyms.o parse.tab.o lex.lex.o # so that 'bison: not found' will be displayed if it is missing. ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),) +ifeq ($(shell command -v $(YACC) || [ -x $(YACC) ] && echo y),) + $(error command not found: $(YACC)) +endif quiet_cmd_bison_no_warn = $(quiet_cmd_bison) - cmd_bison_no_warn = $(YACC) --version >/dev/null; \ - $(cmd_bison) 2>/dev/null + cmd_bison_no_warn = $(cmd_bison) 2>/dev/null $(obj)/pars%.tab.c $(obj)/pars%.tab.h: $(src)/pars%.y FORCE $(call if_changed,bison_no_warn) diff --git a/scripts/genksyms/lex.l b/scripts/genksyms/lex.l index e265c5d96861..0580c088527f 100644 --- a/scripts/genksyms/lex.l +++ b/scripts/genksyms/lex.l @@ -19,6 +19,8 @@ #include "genksyms.h" #include "parse.tab.h" +extern YYSTYPE yylval; + /* We've got a two-level lexer here. We let flex do basic tokenization and then we categorize those basic tokens in the second stage. */ #define YY_DECL static int yylex1(void) diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index b3eff9613cf8..9eb9a94a68e0 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -20,6 +20,8 @@ int cdebug = PRINTD; +int yynerrs = 0; + static void yyerror(const char *err); static void zconfprint(const char *err, ...); static void zconf_error(const char *err, ...); @@ -101,13 +103,6 @@ static struct menu *current_menu, *current_entry; %type word_opt assign_val %type assign_op -%destructor { - fprintf(stderr, "%s:%d: missing end statement for this entry\n", - $$->file->name, $$->lineno); - if (current_menu == $$) - menu_end_menu(); -} if_entry menu_entry choice_entry - %% input: mainmenu_stmt stmt_list | stmt_list; @@ -529,6 +524,11 @@ static bool zconf_endtoken(const char *tokenname, if (strcmp(tokenname, expected_tokenname)) { zconf_error("unexpected '%s' within %s block", tokenname, expected_tokenname); + if (!strcmp(tokenname, "if") || !strcmp(tokenname, "menu") || + !strcmp(tokenname, "choice")) + fprintf(stderr, "%s:%d: missing end statement for this entry\n", + current_menu->file->name, current_menu->lineno); + menu_end_menu(); yynerrs++; return false; } -- 2.25.0