From patchwork Thu Mar 31 20:57:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 604493 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 3qbcK84yC3z9s9Y for ; Fri, 1 Apr 2016 07:57:32 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=WZu9MvDT; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :date:to:cc:subject:in-reply-to:message-id:references :mime-version:content-type; q=dns; s=default; b=M34Fj3HR4/RT1yiS GbgWPC9I/+4E+lDrunGsv9k4D/kaMTwfTePnULma7n4N3tQYHI7sR/LdqqDmLMxR 4vsXoKfMn9PI7tZu5deXciQZ5sggCH7O3H1zXWYHQQLmvc8XquM4MlxCqtWKggX9 6rTUg2jaQ07RQQUEdoATB1PVCtM= 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:from :date:to:cc:subject:in-reply-to:message-id:references :mime-version:content-type; s=default; bh=rsQHrve9qUKM4sSvsSMFL+ 5gFQo=; b=WZu9MvDTD7l08yZqpDWFAuX1rWI68mhslTIRr+BbpK1SYyMEpwrydv 2yMePGsDukc3OGg9VgP8yUawLMx8cz9IDwfuYdS9RqQ5oEmHt5ZUgxPugXR9IHlO 3osqnCkp64+eTexTdlBbBQXBgp18x9Jq4/e7ecwFOarvIOk5Pjy6I= Received: (qmail 41605 invoked by alias); 31 Mar 2016 20:57:20 -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 41572 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 n34so9096004qge.3 for ; Thu, 31 Mar 2016 13:57:08 -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=TSYt9j/MpGeOcbOCxVnoddFzEBw8vGQVvEuvs7CKsh7oL1F9RJ7VPhCulzqG2RaQkz tIBjX7tqEgg6hFlQq4PVBxAGVsxj9ldcVjv7nVFrLvofnZnqhyWHyHAVsxXIroQ2Z+1f bwLucq8YLcnCXPdtmf8WHdgW6BhTIeCxXJf3x34eexXpN/lVhM4oE77x21bgnlw1q/WH kSYRxMKXFfuXUusDm8vvg8ZhVI7GePf7zXeZcKjMzEOiYeCJk1eI9NHi5d0YBC5mlFMr L1M/Y3iilEHH3saXNYbAzvflrnp34nEFC4ZtwcePtyrq+/A1YhZYJHF2Aea+9ooOonpc Ee5g== X-Gm-Message-State: AD7BkJLMhzntn0iGKMVDHBEwZoXybXb4FEZRA/7Un1VD1RAv9xiA9ppJf/OGJxQ0Ia0WmQ== 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 16:57:04 -0400 (EDT) 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 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 */