From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 41606 invoked by alias); 31 Mar 2016 20:57:20 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 41575 invoked by uid 89); 31 Mar 2016 20:57:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=1756, 1936, H*c:HHHH, registration X-HELO: mail-qg0-f66.google.com Received: from mail-qg0-f66.google.com (HELO mail-qg0-f66.google.com) (209.85.192.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 31 Mar 2016 20:57:08 +0000 Received: by mail-qg0-f66.google.com with SMTP id j35so9070149qge.1 for ; Thu, 31 Mar 2016 13:57:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=Q9mxwxP7RMNSE02sWo5T+yl0fHABrdk1eTyJvEWhmtg=; b=a8OYQ2jwM3aAbGDplLdn0/DMhcyQoE3kpTFAALgMJg7R/sF/68z5eFv09dUvuhGll0 n0xnPoMViXR30STkGZjHHrZZ54jMGWrmu8jvJz/J0VRVLvilEf7+22yR3N4ZtujIku0h qUL+BUDD2tZRvZAqckqghQUtVtrsx161mgF1LJBiZinzjYT+esnqzy01sBo5XfR/1hga PKUs6YfrVSs6PGO3EBAM/AWekJesMyLk7sBNpBrmSGuEz0eAQ36aZM3Cf+jDg/7Ovkm+ bbskNMnqIhp7/7sK52VD4TjkYBayfGTRDw3zzllKfGbpsiGq/lC5bxLHPE7/QWP/uEjf wGrw== X-Gm-Message-State: AD7BkJIJxT7UC95Sd1CmD8TThE9VoWveDOAOsqGq6PDBwyLdQtXM0gmQKKHOtp8ScKcEUw== X-Received: by 10.140.201.130 with SMTP id w124mr2343617qha.57.1459457825875; Thu, 31 Mar 2016 13:57:05 -0700 (PDT) Received: from [192.168.1.130] (ool-4353abbc.dyn.optonline.net. [67.83.171.188]) by smtp.gmail.com with ESMTPSA id v65sm4682991qhc.6.2016.03.31.13.57.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Mar 2016 13:57:05 -0700 (PDT) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Thu, 31 Mar 2016 20:57:00 -0000 To: Patrick Palka cc: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org, jason@redhat.com Subject: Re: [PATCH 1/2] Fix new -Wparentheses warnings encountered during bootstrap In-Reply-To: <1459457625-20610-1-git-send-email-patrick@parcs.ath.cx> Message-ID: References: <1459457625-20610-1-git-send-email-patrick@parcs.ath.cx> User-Agent: Alpine 2.20.11 (DEB 116 2015-12-14) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1620266724-1459457825=:1308" X-SW-Source: 2016-03/txt/msg00076.txt.bz2 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1620266724-1459457825=:1308 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Content-length: 6683 On Thu, 31 Mar 2016, Patrick Palka wrote: > This patch fixes the new -Wparentheses warnings (implemented by the > subsequent patch) that are encountered during bootstrap: > > /home/patrick/code/gcc/gcc/omp-low.c: In function ‘void scan_sharing_clauses(tree, omp_context*, bool)’: > /home/patrick/code/gcc/gcc/omp-low.c:2381:6: error: suggest explicit braces to avoid ambiguous ‘else’ [-Werror=parentheses] > if (scan_array_reductions) > ^ > /home/patrick/code/gcc/gcc/gimplify.c: In function ‘gimple* gimplify_omp_ordered(tree, gimple_seq)’: > /home/patrick/code/gcc/gcc/gimplify.c:9880:6: error: suggest explicit braces to avoid ambiguous ‘else’ [-Werror=parentheses] > if (gimplify_omp_ctxp) > ^ > In file included from /home/patrick/code/gcc/gcc/cp/optimize.c:25:0: > /home/patrick/code/gcc/gcc/cp/optimize.c: In function ‘void populate_clone_array(tree, tree_node**)’: > /home/patrick/code/gcc/gcc/cp/cp-tree.h:2529:6: error: suggest explicit braces to avoid ambiguous ‘else’ [-Werror=parentheses] > if (TREE_CODE (FN) == FUNCTION_DECL \ > ^ > /home/patrick/code/gcc/gcc/cp/optimize.c:222:3: note: in expansion of macro ‘FOR_EACH_CLONE’ > FOR_EACH_CLONE (clone, fn) > ^~~~~~~~~~~~~~ > /home/patrick/code/gcc/gcc/fortran/openmp.c: In function ‘gfc_omp_udr* gfc_find_omp_udr(gfc_namespace*, const char*, gfc_typespec*)’: > /home/patrick/code/gcc/gcc/fortran/openmp.c:177:10: error: suggest explicit braces to avoid ambiguous ‘else’ [-Werror=parentheses] > if (st != NULL) > ^ > > In each case I think the warning is harmless since the indentation of > the code in question corresponds to how the "else" is actually parsed > so I fixed each case simply by enclosing the entire body of the outer > "if" in braces. > > The FOR_EACH_CLONE change resolves the cp/optimize.c warning. It > adjusts the layout of the macro from > > if (p) > for (...) > > to > > if (!p) > ; > else for (...) > > so that an "else" encountered in the body of the for-statement can no > longer possibly bind to the outer "if (p)" conditional. > > Is this OK to commit after bootstrap + regtesting? > > gcc/cp/ChangeLog: > > PR c/70436 > * cp-tree.h (FOR_EACH_CLONE): Restructure macro to avoid > potentially generating a future -Wparentheses warning in its > callers. > > gcc/fortran/ChangeLog: > > PR c/70436 > * openmp.c (gfc_find_omp_udr): Add explicit braces to resolve a > future -Wparentheses warning. > > gcc/ChangeLog: > > PR c/70436 > * gimplify.c (gimplify_omp_ordered): Add explicit braces to > resolve a future -Wparentheses warning. > * omp-low.c (scan_sharing_clauses): Likewise. > > gcc/testsuite/ChangeLog: > > PR c/70436 > * g++.dg/plugin/pragma_plugin.c (handle_pragma_sayhello): Add > explicit braces to resolve a future -Wparentheses warning. Here's a diff -w of the same patch: --- gcc/cp/cp-tree.h | 7 ++++--- gcc/fortran/openmp.c | 2 ++ gcc/gimplify.c | 2 ++ gcc/omp-low.c | 2 ++ gcc/testsuite/g++.dg/plugin/pragma_plugin.c | 2 ++ 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index b7b770f..65f5693 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -2526,10 +2526,11 @@ struct GTY(()) lang_decl { */ #define FOR_EACH_CLONE(CLONE, FN) \ - if (TREE_CODE (FN) == FUNCTION_DECL \ + if (!(TREE_CODE (FN) == FUNCTION_DECL \ && (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (FN) \ - || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (FN))) \ - for (CLONE = DECL_CHAIN (FN); \ + || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (FN))))\ + ; \ + else for (CLONE = DECL_CHAIN (FN); \ CLONE && DECL_CLONED_FUNCTION_P (CLONE); \ CLONE = DECL_CHAIN (CLONE)) diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index a6c39cd..0dd1a92 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -175,6 +175,7 @@ gfc_find_omp_udr (gfc_namespace *ns, const char *name, gfc_typespec *ts) st = gfc_find_symtree (ns->omp_udr_root, name); if (st != NULL) + { for (omp_udr = st->n.omp_udr; omp_udr; omp_udr = omp_udr->next) if (ts == NULL) return omp_udr; @@ -193,6 +194,7 @@ gfc_find_omp_udr (gfc_namespace *ns, const char *name, gfc_typespec *ts) } return omp_udr; } + } /* Don't escape an interface block. */ if (ns && !ns->has_import_set diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 26b5a10..1c824fa 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -9878,6 +9878,7 @@ gimplify_omp_ordered (tree expr, gimple_seq body) tree sink_c = NULL_TREE; if (gimplify_omp_ctxp) + { for (c = OMP_ORDERED_CLAUSES (expr); c; c = OMP_CLAUSE_CHAIN (c)) if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND && gimplify_omp_ctxp->loop_iter_var.is_empty () @@ -9936,6 +9937,7 @@ gimplify_omp_ordered (tree expr, gimple_seq body) else source_c = c; } + } if (source_c && sink_c) { error_at (OMP_CLAUSE_LOCATION (source_c), diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 3fd6eb3..df328f9 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -2379,6 +2379,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx, gcc_checking_assert (!scan_array_reductions || !is_gimple_omp_oacc (ctx->stmt)); if (scan_array_reductions) + { for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c)) if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION && OMP_CLAUSE_REDUCTION_PLACEHOLDER (c)) @@ -2393,6 +2394,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx, && OMP_CLAUSE_LINEAR_GIMPLE_SEQ (c)) scan_omp (&OMP_CLAUSE_LINEAR_GIMPLE_SEQ (c), ctx); } +} /* Create a new name for omp child function. Returns an identifier. If IS_CILK_FOR is true then the suffix for the child function is diff --git a/gcc/testsuite/g++.dg/plugin/pragma_plugin.c b/gcc/testsuite/g++.dg/plugin/pragma_plugin.c index 940c302..6794c95 100644 --- a/gcc/testsuite/g++.dg/plugin/pragma_plugin.c +++ b/gcc/testsuite/g++.dg/plugin/pragma_plugin.c @@ -32,6 +32,7 @@ handle_pragma_sayhello (cpp_reader *dummy) return; } if (TREE_STRING_LENGTH (message) > 1) + { if (cfun) warning (OPT_Wpragmas, "% from function %qE: %s", @@ -41,6 +42,7 @@ handle_pragma_sayhello (cpp_reader *dummy) "% outside of function: %s", TREE_STRING_POINTER (message)); } +} /* Plugin callback called during pragma registration */ -- 2.8.0.rc3.27.gade0865 --8323329-1620266724-1459457825=:1308--