From patchwork Sat Nov 22 12:38:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 413294 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 275861400DE for ; Sat, 22 Nov 2014 23:38:25 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=NDOO86jVz6/luDZnhucit0wdkZnH0B1XfknyJ2n4asFwSb jzcv/WkYCvcueuQwlXrHhqeABwF0yoxj0GJZGd8sDMLAsW9IAbhuUM22UTthKxSn tQeO6IHlhyDSp8wLzzsCEQFDiGU7+/DLVuDMXwUT4A+1iXJuuZtXSClXcFseA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=UHbZfoTzKou0xGKbaIoL014N7KE=; b=H8ygmjA0YSAJAQfH1SzP EXIwtrJWsRuHYOU9hcktsCX4tym2lvyHKJQWW4WeQ1yJ+uSEEZ0oUPWWnzh7rLho ohnQabOYQ6sRWIFoSUakUHyQReW1BX5zB/zgyUuD2hqUaDdUu7Dp02NPBXZ0O0RB tf4GCTtgKk0G3RgRSvGEeDo= Received: (qmail 1822 invoked by alias); 22 Nov 2014 12:38:18 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 1811 invoked by uid 89); 22 Nov 2014 12:38:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mx02.qsc.de Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Sat, 22 Nov 2014 12:38:10 +0000 Received: from tux.net-b.de (port-92-194-114-130.dynamic.qsc.de [92.194.114.130]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx02.qsc.de (Postfix) with ESMTPSA id 86DEF276E6; Sat, 22 Nov 2014 13:38:06 +0100 (CET) Message-ID: <547083AD.3010504@net-b.de> Date: Sat, 22 Nov 2014 13:38:05 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: gcc-patches Subject: [Patch, option handling] optc-gen.awk - support || in EnabledBy() In fortran/*.opt, I'd like to use: Fortran Var(warn_tabs) Warning EnabledBy(Wall || Wpedantic) However, "||" is not supported by EnabledBy. This patch adds it. I checked that option.c remains the same after the patch. I attached the patch twice: Once with "-w -U16" to show the modification (minus re-indenting) and once with re-indenting. OK for the trunk? Tobias gcc/ 2014-11-22 Tobias Burnus * optc-gen.awk: Support || in EnabledBy. diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk index ecb225c..0707db2 100644 --- a/gcc/optc-gen.awk +++ b/gcc/optc-gen.awk @@ -38,36 +38,57 @@ for (i = 0; i < n_langs; i++) { for (i = 0; i < n_opts; i++) { enabledby_arg = opt_args("EnabledBy", flags[i]); if (enabledby_arg != "") { - n_enabledby_names = split(enabledby_arg, enabledby_names, " && "); - if (n_enabledby_names > 2) { - print "#error EnabledBy (Wfoo && Wbar && Wbaz) not currently supported" - } - for (j = 1; j <= n_enabledby_names; j++) { - enabledby_name = enabledby_names[j]; - enabledby_index = opt_numbers[enabledby_name]; - if (enabledby_index == "") { - print "#error Enabledby: " enabledby_name - } else { - condition = ""; - if (n_enabledby_names == 2) { - opt_var_name_1 = search_var_name(enabledby_names[1], opt_numbers, opts, flags, n_opts); - opt_var_name_2 = search_var_name(enabledby_names[2], opt_numbers, opts, flags, n_opts); - if (opt_var_name_1 == "") { - print "#error " enabledby_names[1] " does not have a Var() flag" + if (index(enabledby_arg, " && ") == 0) { + # Enabledby(arg) or Enabledby(arg1 || arg2 || arg3) + n_enabledby_names = split(enabledby_arg, enabledby_names, " \\|\\| "); + for (j = 1; j <= n_enabledby_names; j++) { + enabledby_name = enabledby_names[j]; + enabledby_index = opt_numbers[enabledby_name]; + if (enabledby_index == "") { + print "#error Enabledby: " enabledby_name + } else { + condition = ""; + if (enables[enabledby_name] == "") { + enabledby[n_enabledby] = enabledby_name; + n_enabledby++; } - if (opt_var_name_2 == "") { - print "#error " enabledby_names[2] " does not have a Var() flag" - } - condition = "opts->x_" opt_var_name_1 " && opts->x_" opt_var_name_2; + enables[enabledby_name] = enables[enabledby_name] opts[i] ";"; + enablesif[enabledby_name] = enablesif[enabledby_name] condition ";"; } - if (enables[enabledby_name] == "") { - enabledby[n_enabledby] = enabledby_name; - n_enabledby++; + } + } else { + # Enabledby(arg1 && arg2) + n_enabledby_names = split(enabledby_arg, enabledby_names, " && "); + if (n_enabledby_names > 2) { + print "#error EnabledBy (Wfoo && Wbar && Wbaz) not currently supported" + } + for (j = 1; j <= n_enabledby_names; j++) { + enabledby_name = enabledby_names[j]; + enabledby_index = opt_numbers[enabledby_name]; + if (enabledby_index == "") { + print "#error Enabledby: " enabledby_name + } else { + condition = ""; + if (n_enabledby_names == 2) { + opt_var_name_1 = search_var_name(enabledby_names[1], opt_numbers, opts, flags, n_opts); + opt_var_name_2 = search_var_name(enabledby_names[2], opt_numbers, opts, flags, n_opts); + if (opt_var_name_1 == "") { + print "#error " enabledby_names[1] " does not have a Var() flag" + } + if (opt_var_name_2 == "") { + print "#error " enabledby_names[2] " does not have a Var() flag" + } + condition = "opts->x_" opt_var_name_1 " && opts->x_" opt_var_name_2; + } + if (enables[enabledby_name] == "") { + enabledby[n_enabledby] = enabledby_name; + n_enabledby++; + } + enables[enabledby_name] = enables[enabledby_name] opts[i] ";"; + enablesif[enabledby_name] = enablesif[enabledby_name] condition ";"; } - enables[enabledby_name] = enables[enabledby_name] opts[i] ";"; - enablesif[enabledby_name] = enablesif[enabledby_name] condition ";"; } - } + } } enabledby_arg = opt_args("LangEnabledBy", flags[i]);