public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Fix new -Wparentheses warnings encountered during bootstrap
@ 2016-03-31 20:54 Patrick Palka
  2016-03-31 20:57 ` Patrick Palka
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Patrick Palka @ 2016-03-31 20:54 UTC (permalink / raw)
  To: gcc-patches; +Cc: fortran, jason, Patrick Palka

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.
---
 gcc/cp/cp-tree.h                            |  13 ++--
 gcc/fortran/openmp.c                        |  36 +++++-----
 gcc/gimplify.c                              | 108 ++++++++++++++--------------
 gcc/omp-low.c                               |  28 ++++----
 gcc/testsuite/g++.dg/plugin/pragma_plugin.c |  12 ++--
 5 files changed, 103 insertions(+), 94 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,12 +2526,13 @@ struct GTY(()) lang_decl {
 
   */
 #define FOR_EACH_CLONE(CLONE, FN)			\
-  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);			\
-	  CLONE && DECL_CLONED_FUNCTION_P (CLONE);	\
-	  CLONE = DECL_CHAIN (CLONE))
+  if (!(TREE_CODE (FN) == FUNCTION_DECL			\
+	&& (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (FN)	\
+	    || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (FN))))\
+    ;							\
+  else for (CLONE = DECL_CHAIN (FN);			\
+	    CLONE && DECL_CLONED_FUNCTION_P (CLONE);	\
+	    CLONE = DECL_CHAIN (CLONE))
 
 /* Nonzero if NODE has DECL_DISCRIMINATOR and not DECL_ACCESS.  */
 #define DECL_DISCRIMINATOR_P(NODE)	\
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,24 +175,26 @@ 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;
-	  else if (gfc_compare_types (&omp_udr->ts, ts))
-	    {
-	      if (ts->type == BT_CHARACTER)
-		{
-		  if (omp_udr->ts.u.cl->length == NULL)
-		    return omp_udr;
-		  if (ts->u.cl->length == NULL)
-		    continue;
-		  if (gfc_compare_expr (omp_udr->ts.u.cl->length,
-					ts->u.cl->length,
-					INTRINSIC_EQ) != 0)
-		    continue;
-		}
+	{
+	  for (omp_udr = st->n.omp_udr; omp_udr; omp_udr = omp_udr->next)
+	    if (ts == NULL)
 	      return omp_udr;
-	    }
+	    else if (gfc_compare_types (&omp_udr->ts, ts))
+	      {
+		if (ts->type == BT_CHARACTER)
+		  {
+		    if (omp_udr->ts.u.cl->length == NULL)
+		      return omp_udr;
+		    if (ts->u.cl->length == NULL)
+		      continue;
+		    if (gfc_compare_expr (omp_udr->ts.u.cl->length,
+					  ts->u.cl->length,
+					  INTRINSIC_EQ) != 0)
+		      continue;
+		  }
+		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,64 +9878,66 @@ 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 ()
-	  && (OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SINK
-	      || OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SOURCE))
-	{
-	  error_at (OMP_CLAUSE_LOCATION (c),
-		    "%<ordered%> construct with %<depend%> clause must be "
-		    "closely nested inside a loop with %<ordered%> clause "
-		    "with a parameter");
-	  failures++;
-	}
-      else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
-	       && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SINK)
-	{
-	  bool fail = false;
-	  for (decls = OMP_CLAUSE_DECL (c), i = 0;
-	       decls && TREE_CODE (decls) == TREE_LIST;
-	       decls = TREE_CHAIN (decls), ++i)
-	    if (i >= gimplify_omp_ctxp->loop_iter_var.length () / 2)
-	      continue;
-	    else if (TREE_VALUE (decls)
-		     != gimplify_omp_ctxp->loop_iter_var[2 * i])
+    {
+      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 ()
+	    && (OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SINK
+		|| OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SOURCE))
+	  {
+	    error_at (OMP_CLAUSE_LOCATION (c),
+		      "%<ordered%> construct with %<depend%> clause must be "
+		      "closely nested inside a loop with %<ordered%> clause "
+		      "with a parameter");
+	    failures++;
+	  }
+	else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
+		 && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SINK)
+	  {
+	    bool fail = false;
+	    for (decls = OMP_CLAUSE_DECL (c), i = 0;
+		 decls && TREE_CODE (decls) == TREE_LIST;
+		 decls = TREE_CHAIN (decls), ++i)
+	      if (i >= gimplify_omp_ctxp->loop_iter_var.length () / 2)
+		continue;
+	      else if (TREE_VALUE (decls)
+		       != gimplify_omp_ctxp->loop_iter_var[2 * i])
+		{
+		  error_at (OMP_CLAUSE_LOCATION (c),
+			    "variable %qE is not an iteration "
+			    "of outermost loop %d, expected %qE",
+			    TREE_VALUE (decls), i + 1,
+			    gimplify_omp_ctxp->loop_iter_var[2 * i]);
+		  fail = true;
+		  failures++;
+		}
+	      else
+		TREE_VALUE (decls)
+		  = gimplify_omp_ctxp->loop_iter_var[2 * i + 1];
+	    if (!fail && i != gimplify_omp_ctxp->loop_iter_var.length () / 2)
+	      {
+		error_at (OMP_CLAUSE_LOCATION (c),
+			  "number of variables in %<depend(sink)%> "
+			  "clause does not match number of "
+			  "iteration variables");
+		failures++;
+	      }
+	    sink_c = c;
+	  }
+	else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
+		 && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SOURCE)
+	  {
+	    if (source_c)
 	      {
 		error_at (OMP_CLAUSE_LOCATION (c),
-			  "variable %qE is not an iteration "
-			  "of outermost loop %d, expected %qE",
-			  TREE_VALUE (decls), i + 1,
-			  gimplify_omp_ctxp->loop_iter_var[2 * i]);
-		fail = true;
+			  "more than one %<depend(source)%> clause on an "
+			  "%<ordered%> construct");
 		failures++;
 	      }
 	    else
-	      TREE_VALUE (decls)
-		= gimplify_omp_ctxp->loop_iter_var[2 * i + 1];
-	  if (!fail && i != gimplify_omp_ctxp->loop_iter_var.length () / 2)
-	    {
-	      error_at (OMP_CLAUSE_LOCATION (c),
-			"number of variables in %<depend(sink)%> "
-			"clause does not match number of "
-			"iteration variables");
-	      failures++;
-	    }
-	  sink_c = c;
-	}
-      else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
-	       && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SOURCE)
-	{
-	  if (source_c)
-	    {
-	      error_at (OMP_CLAUSE_LOCATION (c),
-			"more than one %<depend(source)%> clause on an "
-			"%<ordered%> construct");
-	      failures++;
-	    }
-	  else
-	    source_c = c;
-	}
+	      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,19 +2379,21 @@ 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))
-	{
-	  scan_omp (&OMP_CLAUSE_REDUCTION_GIMPLE_INIT (c), ctx);
-	  scan_omp (&OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (c), ctx);
-	}
-      else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE
-	       && OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (c))
-	scan_omp (&OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (c), ctx);
-      else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINEAR
-	       && OMP_CLAUSE_LINEAR_GIMPLE_SEQ (c))
-	scan_omp (&OMP_CLAUSE_LINEAR_GIMPLE_SEQ (c), ctx);
+    {
+      for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
+	if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
+	    && OMP_CLAUSE_REDUCTION_PLACEHOLDER (c))
+	  {
+	    scan_omp (&OMP_CLAUSE_REDUCTION_GIMPLE_INIT (c), ctx);
+	    scan_omp (&OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (c), ctx);
+	  }
+	else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE
+		 && OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (c))
+	  scan_omp (&OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (c), ctx);
+	else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINEAR
+		 && 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
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,14 +32,16 @@ handle_pragma_sayhello (cpp_reader *dummy)
       return;
     }
   if (TREE_STRING_LENGTH (message) > 1)
-    if (cfun)
-      warning (OPT_Wpragmas, 
-	      "%<pragma GCCPLUGIN sayhello%> from function %qE: %s",
-	      cfun->decl, TREE_STRING_POINTER (message));
+    {
+      if (cfun)
+        warning (OPT_Wpragmas, 
+	        "%<pragma GCCPLUGIN sayhello%> from function %qE: %s",
+	        cfun->decl, TREE_STRING_POINTER (message));
       else
-	warning (OPT_Wpragmas, 
+        warning (OPT_Wpragmas, 
 	    "%<pragma GCCPLUGIN sayhello%> outside of function: %s",
 	    TREE_STRING_POINTER (message));
+    }
 }
 
 /* Plugin callback called during pragma registration */
-- 
2.8.0.rc3.27.gade0865

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] Fix new -Wparentheses warnings encountered during bootstrap
  2016-03-31 20:54 [PATCH 1/2] Fix new -Wparentheses warnings encountered during bootstrap Patrick Palka
@ 2016-03-31 20:57 ` Patrick Palka
  2016-03-31 21:10 ` Patrick Palka
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Patrick Palka @ 2016-03-31 20:57 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gcc-patches, fortran, jason

[-- Attachment #1: Type: text/plain, Size: 6737 bytes --]

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, 
 	        "%<pragma GCCPLUGIN sayhello%> from function %qE: %s",
@@ -41,6 +42,7 @@ handle_pragma_sayhello (cpp_reader *dummy)
 	    "%<pragma GCCPLUGIN sayhello%> outside of function: %s",
 	    TREE_STRING_POINTER (message));
     }
+}
 
 /* Plugin callback called during pragma registration */
 
-- 
2.8.0.rc3.27.gade0865

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] Fix new -Wparentheses warnings encountered during bootstrap
  2016-03-31 20:54 [PATCH 1/2] Fix new -Wparentheses warnings encountered during bootstrap Patrick Palka
  2016-03-31 20:57 ` Patrick Palka
@ 2016-03-31 21:10 ` Patrick Palka
  2016-03-31 21:14 ` Bernd Schmidt
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Patrick Palka @ 2016-03-31 21:10 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gcc-patches, fortran, jason

[-- Attachment #1: Type: text/plain, Size: 4384 bytes --]

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.

Forgot about a tree-parloops.c change:

diff:

diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index e498e5b..2e55b79 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -767,14 +767,16 @@ eliminate_local_variables (edge entry, edge exit)
 
   FOR_EACH_VEC_ELT (body, i, bb)
     if (bb != entry_bb && bb != exit_bb)
-      for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
-	if (is_gimple_debug (gsi_stmt (gsi)))
-	  {
-	    if (gimple_debug_bind_p (gsi_stmt (gsi)))
-	      has_debug_stmt = true;
-	  }
-	else
-	  eliminate_local_variables_stmt (entry, &gsi, &decl_address);
+      {
+        for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+	  if (is_gimple_debug (gsi_stmt (gsi)))
+	    {
+	      if (gimple_debug_bind_p (gsi_stmt (gsi)))
+	        has_debug_stmt = true;
+	    }
+	  else
+	    eliminate_local_variables_stmt (entry, &gsi, &decl_address);
+      }
 
   if (has_debug_stmt)
     FOR_EACH_VEC_ELT (body, i, bb)


diff -w:

diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index e498e5b..2e55b79 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -767,6 +767,7 @@ eliminate_local_variables (edge entry, edge exit)
 
   FOR_EACH_VEC_ELT (body, i, bb)
     if (bb != entry_bb && bb != exit_bb)
+      {
         for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	  if (is_gimple_debug (gsi_stmt (gsi)))
 	    {
@@ -775,6 +776,7 @@ eliminate_local_variables (edge entry, edge exit)
 	    }
 	  else
 	    eliminate_local_variables_stmt (entry, &gsi, &decl_address);
+      }
 
   if (has_debug_stmt)
     FOR_EACH_VEC_ELT (body, i, bb)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] Fix new -Wparentheses warnings encountered during bootstrap
  2016-03-31 20:54 [PATCH 1/2] Fix new -Wparentheses warnings encountered during bootstrap Patrick Palka
  2016-03-31 20:57 ` Patrick Palka
  2016-03-31 21:10 ` Patrick Palka
@ 2016-03-31 21:14 ` Bernd Schmidt
  2016-03-31 21:18   ` Patrick Palka
  2016-03-31 21:30 ` Jakub Jelinek
  2016-03-31 22:38 ` Trevor Saunders
  4 siblings, 1 reply; 8+ messages in thread
From: Bernd Schmidt @ 2016-03-31 21:14 UTC (permalink / raw)
  To: Patrick Palka, gcc-patches; +Cc: fortran, jason

On 03/31/2016 10:53 PM, 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?

I think this is OK, now or in stage1 depending on whether the warning 
improvements go in now or later.

I see a patch for the C++ side fixing the warning, do you also intend to 
do C?


Bernd

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] Fix new -Wparentheses warnings encountered during bootstrap
  2016-03-31 21:14 ` Bernd Schmidt
@ 2016-03-31 21:18   ` Patrick Palka
  2016-04-01 11:46     ` Marek Polacek
  0 siblings, 1 reply; 8+ messages in thread
From: Patrick Palka @ 2016-03-31 21:18 UTC (permalink / raw)
  To: Bernd Schmidt; +Cc: Patrick Palka, gcc-patches, fortran, jason

[-- Attachment #1: Type: text/plain, Size: 2767 bytes --]

On Thu, 31 Mar 2016, Bernd Schmidt wrote:

> On 03/31/2016 10:53 PM, 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?
> 
> I think this is OK, now or in stage1 depending on whether the warning
> improvements go in now or later.
> 
> I see a patch for the C++ side fixing the warning, do you also intend to do C?
> 
> 
> Bernd
> 
> 

I hope someone else could do it since I'm not very familiar with the C
parser :)  I think Marek said he would take care of it.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] Fix new -Wparentheses warnings encountered during bootstrap
  2016-03-31 20:54 [PATCH 1/2] Fix new -Wparentheses warnings encountered during bootstrap Patrick Palka
                   ` (2 preceding siblings ...)
  2016-03-31 21:14 ` Bernd Schmidt
@ 2016-03-31 21:30 ` Jakub Jelinek
  2016-03-31 22:38 ` Trevor Saunders
  4 siblings, 0 replies; 8+ messages in thread
From: Jakub Jelinek @ 2016-03-31 21:30 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gcc-patches, fortran, jason

On Thu, Mar 31, 2016 at 04:53:45PM -0400, Patrick Palka wrote:
> @@ -2526,12 +2526,13 @@ struct GTY(()) lang_decl {
>  
>    */
>  #define FOR_EACH_CLONE(CLONE, FN)			\
> -  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);			\
> -	  CLONE && DECL_CLONED_FUNCTION_P (CLONE);	\
> -	  CLONE = DECL_CHAIN (CLONE))
> +  if (!(TREE_CODE (FN) == FUNCTION_DECL			\
> +	&& (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (FN)	\
> +	    || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (FN))))\
> +    ;							\
> +  else for (CLONE = DECL_CHAIN (FN);			\
> +	    CLONE && DECL_CLONED_FUNCTION_P (CLONE);	\
> +	    CLONE = DECL_CHAIN (CLONE))

Can you please do
+  else							\
+    for (CLONE = DECL_CHAIN (FN);			\
...
instead?

> --- a/gcc/testsuite/g++.dg/plugin/pragma_plugin.c
> +++ b/gcc/testsuite/g++.dg/plugin/pragma_plugin.c
> @@ -32,14 +32,16 @@ handle_pragma_sayhello (cpp_reader *dummy)
>        return;
>      }
>    if (TREE_STRING_LENGTH (message) > 1)
> -    if (cfun)
> -      warning (OPT_Wpragmas, 
> -	      "%<pragma GCCPLUGIN sayhello%> from function %qE: %s",
> -	      cfun->decl, TREE_STRING_POINTER (message));
> +    {
> +      if (cfun)
> +        warning (OPT_Wpragmas, 
> +	        "%<pragma GCCPLUGIN sayhello%> from function %qE: %s",
> +	        cfun->decl, TREE_STRING_POINTER (message));
>        else
> -	warning (OPT_Wpragmas, 
> +        warning (OPT_Wpragmas, 
>  	    "%<pragma GCCPLUGIN sayhello%> outside of function: %s",
>  	    TREE_STRING_POINTER (message));
> +    }

Several lines with 8 spaces instead of tab above.  Can you also indent
the last warning's following lines to be below OPT_?

Otherwise LGTM.

	Jakub

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] Fix new -Wparentheses warnings encountered during bootstrap
  2016-03-31 20:54 [PATCH 1/2] Fix new -Wparentheses warnings encountered during bootstrap Patrick Palka
                   ` (3 preceding siblings ...)
  2016-03-31 21:30 ` Jakub Jelinek
@ 2016-03-31 22:38 ` Trevor Saunders
  4 siblings, 0 replies; 8+ messages in thread
From: Trevor Saunders @ 2016-03-31 22:38 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gcc-patches, fortran, jason

On Thu, Mar 31, 2016 at 04:53:45PM -0400, 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)
>       ^

I imagine you noticed, but these warnings aren't that friendly, it seems
like it would be nice to point at the else, and maybe what it is an else
for  and the thing it might seem to be an else for?

Trev

> 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.
> ---
>  gcc/cp/cp-tree.h                            |  13 ++--
>  gcc/fortran/openmp.c                        |  36 +++++-----
>  gcc/gimplify.c                              | 108 ++++++++++++++--------------
>  gcc/omp-low.c                               |  28 ++++----
>  gcc/testsuite/g++.dg/plugin/pragma_plugin.c |  12 ++--
>  5 files changed, 103 insertions(+), 94 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,12 +2526,13 @@ struct GTY(()) lang_decl {
>  
>    */
>  #define FOR_EACH_CLONE(CLONE, FN)			\
> -  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);			\
> -	  CLONE && DECL_CLONED_FUNCTION_P (CLONE);	\
> -	  CLONE = DECL_CHAIN (CLONE))
> +  if (!(TREE_CODE (FN) == FUNCTION_DECL			\
> +	&& (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (FN)	\
> +	    || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (FN))))\
> +    ;							\
> +  else for (CLONE = DECL_CHAIN (FN);			\
> +	    CLONE && DECL_CLONED_FUNCTION_P (CLONE);	\
> +	    CLONE = DECL_CHAIN (CLONE))
>  
>  /* Nonzero if NODE has DECL_DISCRIMINATOR and not DECL_ACCESS.  */
>  #define DECL_DISCRIMINATOR_P(NODE)	\
> 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,24 +175,26 @@ 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;
> -	  else if (gfc_compare_types (&omp_udr->ts, ts))
> -	    {
> -	      if (ts->type == BT_CHARACTER)
> -		{
> -		  if (omp_udr->ts.u.cl->length == NULL)
> -		    return omp_udr;
> -		  if (ts->u.cl->length == NULL)
> -		    continue;
> -		  if (gfc_compare_expr (omp_udr->ts.u.cl->length,
> -					ts->u.cl->length,
> -					INTRINSIC_EQ) != 0)
> -		    continue;
> -		}
> +	{
> +	  for (omp_udr = st->n.omp_udr; omp_udr; omp_udr = omp_udr->next)
> +	    if (ts == NULL)
>  	      return omp_udr;
> -	    }
> +	    else if (gfc_compare_types (&omp_udr->ts, ts))
> +	      {
> +		if (ts->type == BT_CHARACTER)
> +		  {
> +		    if (omp_udr->ts.u.cl->length == NULL)
> +		      return omp_udr;
> +		    if (ts->u.cl->length == NULL)
> +		      continue;
> +		    if (gfc_compare_expr (omp_udr->ts.u.cl->length,
> +					  ts->u.cl->length,
> +					  INTRINSIC_EQ) != 0)
> +		      continue;
> +		  }
> +		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,64 +9878,66 @@ 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 ()
> -	  && (OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SINK
> -	      || OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SOURCE))
> -	{
> -	  error_at (OMP_CLAUSE_LOCATION (c),
> -		    "%<ordered%> construct with %<depend%> clause must be "
> -		    "closely nested inside a loop with %<ordered%> clause "
> -		    "with a parameter");
> -	  failures++;
> -	}
> -      else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
> -	       && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SINK)
> -	{
> -	  bool fail = false;
> -	  for (decls = OMP_CLAUSE_DECL (c), i = 0;
> -	       decls && TREE_CODE (decls) == TREE_LIST;
> -	       decls = TREE_CHAIN (decls), ++i)
> -	    if (i >= gimplify_omp_ctxp->loop_iter_var.length () / 2)
> -	      continue;
> -	    else if (TREE_VALUE (decls)
> -		     != gimplify_omp_ctxp->loop_iter_var[2 * i])
> +    {
> +      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 ()
> +	    && (OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SINK
> +		|| OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SOURCE))
> +	  {
> +	    error_at (OMP_CLAUSE_LOCATION (c),
> +		      "%<ordered%> construct with %<depend%> clause must be "
> +		      "closely nested inside a loop with %<ordered%> clause "
> +		      "with a parameter");
> +	    failures++;
> +	  }
> +	else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
> +		 && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SINK)
> +	  {
> +	    bool fail = false;
> +	    for (decls = OMP_CLAUSE_DECL (c), i = 0;
> +		 decls && TREE_CODE (decls) == TREE_LIST;
> +		 decls = TREE_CHAIN (decls), ++i)
> +	      if (i >= gimplify_omp_ctxp->loop_iter_var.length () / 2)
> +		continue;
> +	      else if (TREE_VALUE (decls)
> +		       != gimplify_omp_ctxp->loop_iter_var[2 * i])
> +		{
> +		  error_at (OMP_CLAUSE_LOCATION (c),
> +			    "variable %qE is not an iteration "
> +			    "of outermost loop %d, expected %qE",
> +			    TREE_VALUE (decls), i + 1,
> +			    gimplify_omp_ctxp->loop_iter_var[2 * i]);
> +		  fail = true;
> +		  failures++;
> +		}
> +	      else
> +		TREE_VALUE (decls)
> +		  = gimplify_omp_ctxp->loop_iter_var[2 * i + 1];
> +	    if (!fail && i != gimplify_omp_ctxp->loop_iter_var.length () / 2)
> +	      {
> +		error_at (OMP_CLAUSE_LOCATION (c),
> +			  "number of variables in %<depend(sink)%> "
> +			  "clause does not match number of "
> +			  "iteration variables");
> +		failures++;
> +	      }
> +	    sink_c = c;
> +	  }
> +	else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
> +		 && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SOURCE)
> +	  {
> +	    if (source_c)
>  	      {
>  		error_at (OMP_CLAUSE_LOCATION (c),
> -			  "variable %qE is not an iteration "
> -			  "of outermost loop %d, expected %qE",
> -			  TREE_VALUE (decls), i + 1,
> -			  gimplify_omp_ctxp->loop_iter_var[2 * i]);
> -		fail = true;
> +			  "more than one %<depend(source)%> clause on an "
> +			  "%<ordered%> construct");
>  		failures++;
>  	      }
>  	    else
> -	      TREE_VALUE (decls)
> -		= gimplify_omp_ctxp->loop_iter_var[2 * i + 1];
> -	  if (!fail && i != gimplify_omp_ctxp->loop_iter_var.length () / 2)
> -	    {
> -	      error_at (OMP_CLAUSE_LOCATION (c),
> -			"number of variables in %<depend(sink)%> "
> -			"clause does not match number of "
> -			"iteration variables");
> -	      failures++;
> -	    }
> -	  sink_c = c;
> -	}
> -      else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
> -	       && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SOURCE)
> -	{
> -	  if (source_c)
> -	    {
> -	      error_at (OMP_CLAUSE_LOCATION (c),
> -			"more than one %<depend(source)%> clause on an "
> -			"%<ordered%> construct");
> -	      failures++;
> -	    }
> -	  else
> -	    source_c = c;
> -	}
> +	      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,19 +2379,21 @@ 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))
> -	{
> -	  scan_omp (&OMP_CLAUSE_REDUCTION_GIMPLE_INIT (c), ctx);
> -	  scan_omp (&OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (c), ctx);
> -	}
> -      else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE
> -	       && OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (c))
> -	scan_omp (&OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (c), ctx);
> -      else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINEAR
> -	       && OMP_CLAUSE_LINEAR_GIMPLE_SEQ (c))
> -	scan_omp (&OMP_CLAUSE_LINEAR_GIMPLE_SEQ (c), ctx);
> +    {
> +      for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
> +	if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
> +	    && OMP_CLAUSE_REDUCTION_PLACEHOLDER (c))
> +	  {
> +	    scan_omp (&OMP_CLAUSE_REDUCTION_GIMPLE_INIT (c), ctx);
> +	    scan_omp (&OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (c), ctx);
> +	  }
> +	else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE
> +		 && OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (c))
> +	  scan_omp (&OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (c), ctx);
> +	else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINEAR
> +		 && 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
> 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,14 +32,16 @@ handle_pragma_sayhello (cpp_reader *dummy)
>        return;
>      }
>    if (TREE_STRING_LENGTH (message) > 1)
> -    if (cfun)
> -      warning (OPT_Wpragmas, 
> -	      "%<pragma GCCPLUGIN sayhello%> from function %qE: %s",
> -	      cfun->decl, TREE_STRING_POINTER (message));
> +    {
> +      if (cfun)
> +        warning (OPT_Wpragmas, 
> +	        "%<pragma GCCPLUGIN sayhello%> from function %qE: %s",
> +	        cfun->decl, TREE_STRING_POINTER (message));
>        else
> -	warning (OPT_Wpragmas, 
> +        warning (OPT_Wpragmas, 
>  	    "%<pragma GCCPLUGIN sayhello%> outside of function: %s",
>  	    TREE_STRING_POINTER (message));
> +    }
>  }
>  
>  /* Plugin callback called during pragma registration */
> -- 
> 2.8.0.rc3.27.gade0865
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] Fix new -Wparentheses warnings encountered during bootstrap
  2016-03-31 21:18   ` Patrick Palka
@ 2016-04-01 11:46     ` Marek Polacek
  0 siblings, 0 replies; 8+ messages in thread
From: Marek Polacek @ 2016-04-01 11:46 UTC (permalink / raw)
  To: Patrick Palka; +Cc: Bernd Schmidt, gcc-patches, fortran, jason

On Thu, Mar 31, 2016 at 05:18:13PM -0400, Patrick Palka wrote:
> I hope someone else could do it since I'm not very familiar with the C
> parser :)  I think Marek said he would take care of it.

Sure, happy to.

	Marek

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-04-01 11:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-31 20:54 [PATCH 1/2] Fix new -Wparentheses warnings encountered during bootstrap Patrick Palka
2016-03-31 20:57 ` Patrick Palka
2016-03-31 21:10 ` Patrick Palka
2016-03-31 21:14 ` Bernd Schmidt
2016-03-31 21:18   ` Patrick Palka
2016-04-01 11:46     ` Marek Polacek
2016-03-31 21:30 ` Jakub Jelinek
2016-03-31 22:38 ` Trevor Saunders

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).