[Bug c/70436] [4.9/5/6 Regression] -Wparentheses missing ambiguous else warning

2016-04-15 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70436

--- Comment #19 from Jakub Jelinek  ---
Author: jakub
Date: Fri Apr 15 12:24:18 2016
New Revision: 235020

URL: https://gcc.gnu.org/viewcvs?rev=235020=gcc=rev
Log:
PR c/70436
c/
* c-parser.c (c_parser_pragma): Add IF_P argument, pass it down
where needed.
(c_parser_external_declaration, c_parser_struct_or_union_specifier,
c_parser_parameter_declaration, c_parser_compound_statement_nostart,
c_parser_objc_class_instance_variables, c_parser_objc_methodprotolist):
Adjust c_parser_pragma callers.
(c_parser_statement_after_labels): Likewise.  Adjust c_parser_cilk_for
caller.
(c_parser_omp_structured_block): Add IF_P argument, pass it down to
c_parser_statement.
(c_parser_oacc_data, c_parser_oacc_host_data, c_parser_oacc_loop,
c_parser_oacc_kernels_parallel, c_parser_omp_critical,
c_parser_omp_simd, c_parser_omp_for, c_parser_omp_master,
c_parser_omp_ordered, c_parser_omp_parallel, c_parser_omp_single,
c_parser_omp_task, c_parser_omp_taskgroup, c_parser_omp_distribute,
c_parser_omp_teams, c_parser_omp_target_data, c_parser_omp_target,
c_parser_omp_taskloop, c_parser_omp_construct, c_parser_cilk_grainsize,
c_parser_cilk_simd, c_parser_cilk_for): Add IF_P argument, pass it
down where needed.
(c_parser_omp_for_loop): Likewise.  Clear IF_P if nbraces.
(c_parser_omp_sections_scope): Adjust c_parser_omp_structured_block
calls.
cp/
* parser.c (cp_parser_pragma): Add IF_P argument, pass it down
where needed.
(cp_parser_declaration_seq_opt, cp_parser_member_specification_opt,
cp_parser_objc_interstitial_code, cp_parser_omp_declare_simd,
cp_parser_oacc_routine): Adjust cp_parser_pragma callers.
(cp_parser_statement): Likewise.  Adjust cp_parser_cilk_for caller.
(cp_parser_omp_structured_block): Add IF_P argument, pass it down to
cp_parser_statement.
(cp_parser_oacc_data, cp_parser_oacc_host_data, cp_parser_oacc_loop,
cp_parser_oacc_kernels_parallel, cp_parser_omp_critical,
cp_parser_omp_simd, cp_parser_omp_for, cp_parser_omp_master,
cp_parser_omp_ordered, cp_parser_omp_parallel, cp_parser_omp_single,
cp_parser_omp_task, cp_parser_omp_taskgroup, cp_parser_omp_distribute,
cp_parser_omp_teams, cp_parser_omp_target_data, cp_parser_omp_target,
cp_parser_omp_taskloop, cp_parser_omp_construct,
cp_parser_cilk_grainsize, cp_parser_cilk_simd, cp_parser_cilk_for):
Add IF_P argument, pass it down where needed.
(cp_parser_omp_for_loop): Likewise.  Clear IF_P if nbraces.
(cp_parser_omp_sections_scope): Adjust cp_parser_omp_structured_block
calls.
testsuite/
* c-c++-common/Wparentheses-1.c: New test.
* c-c++-common/gomp/Wparentheses-1.c: New test.
* c-c++-common/gomp/Wparentheses-2.c: New test.
* c-c++-common/gomp/Wparentheses-3.c: New test.
* c-c++-common/gomp/Wparentheses-4.c: New test.
* c-c++-common/cilk-plus/PS/Wparentheses-1.c: New test.
* c-c++-common/cilk-plus/CK/Wparentheses-1.c: New test.
* c-c++-common/goacc/Wparentheses-1.c: New test.

Added:
trunk/gcc/testsuite/c-c++-common/Wparentheses-1.c
trunk/gcc/testsuite/c-c++-common/cilk-plus/CK/Wparentheses-1.c
trunk/gcc/testsuite/c-c++-common/cilk-plus/PS/Wparentheses-1.c
trunk/gcc/testsuite/c-c++-common/goacc/Wparentheses-1.c
trunk/gcc/testsuite/c-c++-common/gomp/Wparentheses-1.c
trunk/gcc/testsuite/c-c++-common/gomp/Wparentheses-2.c
trunk/gcc/testsuite/c-c++-common/gomp/Wparentheses-3.c
trunk/gcc/testsuite/c-c++-common/gomp/Wparentheses-4.c
Modified:
trunk/gcc/c/ChangeLog
trunk/gcc/c/c-parser.c
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/parser.c
trunk/gcc/testsuite/ChangeLog

[Bug c/70436] [4.9/5/6 Regression] -Wparentheses missing ambiguous else warning

2016-04-15 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70436

--- Comment #18 from Jakub Jelinek  ---
Created attachment 38279
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38279=edit
gcc6-pr70436-omp.patch

Untested fix for OpenMP/OpenACC/Cilk+/#pragma GCC ivdep, both C and C++.

[Bug c/70436] [4.9/5/6 Regression] -Wparentheses missing ambiguous else warning

2016-04-13 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70436

Marek Polacek  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #17 from Marek Polacek  ---
Should be fixed now.

[Bug c/70436] [4.9/5/6 Regression] -Wparentheses missing ambiguous else warning

2016-04-13 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70436

--- Comment #16 from Marek Polacek  ---
Author: mpolacek
Date: Wed Apr 13 16:00:52 2016
New Revision: 234949

URL: https://gcc.gnu.org/viewcvs?rev=234949=gcc=rev
Log:
PR c/70436
* c-parser.c (c_parser_statement_after_labels): Add IF_P argument and
adjust callers.
(c_parser_statement): Likewise.
(c_parser_c99_block_statement): Likewise.
(c_parser_while_statement): Likewise.
(c_parser_for_statement): Likewise.
(c_parser_if_body): Don't set IF_P here.
(c_parser_if_statement): Add IF_P argument.  Set IF_P here.  Warn
about dangling else here.
* c-tree.h (c_finish_if_stmt): Adjust declaration.
* c-typeck.c (c_finish_if_stmt): Remove NESTED_IF parameter.  Don't
warn about dangling else here.

* testsuite/gcc.dg/Wparentheses-12.c: New test.
* testsuite/gcc.dg/Wparentheses-13.c: New test.

Added:
trunk/gcc/testsuite/gcc.dg/Wparentheses-12.c
trunk/gcc/testsuite/gcc.dg/Wparentheses-13.c
Modified:
trunk/gcc/c/ChangeLog
trunk/gcc/c/c-parser.c
trunk/gcc/c/c-tree.h
trunk/gcc/c/c-typeck.c
trunk/gcc/testsuite/ChangeLog

[Bug c/70436] [4.9/5/6 Regression] -Wparentheses missing ambiguous else warning

2016-04-08 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70436

Marek Polacek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org

--- Comment #15 from Marek Polacek  ---
It's now up to me to handle the C FE side.

[Bug c/70436] [4.9/5/6 Regression] -Wparentheses missing ambiguous else warning

2016-04-06 Thread ppalka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70436

--- Comment #14 from Patrick Palka  ---
Author: ppalka
Date: Wed Apr  6 23:10:14 2016
New Revision: 234802

URL: https://gcc.gnu.org/viewcvs?rev=234802=gcc=rev
Log:
Fix C++ side of PR c/70436 (missing -Wparentheses warnings)

gcc/cp/ChangeLog:

PR c/70436
* parser.c (cp_parser_iteration_statement): New parameter IF_P.
Pass it through to cp_parser_already_scoped_statement.
(cp_parser_already_scoped_statement): New parameter IF_P.  Pass
it through to cp_parser_statement.
(cp_parser_statement): Pass IF_P through to
cp_parser_iteration_statement.
(cp_parser_pragma): Adjust call to
cp_parser_iteration_statement.

gcc/testsuite/ChangeLog:

PR c/70436
* g++.dg/warn/Wparentheses-29.C: New test.


Added:
trunk/gcc/testsuite/g++.dg/warn/Wparentheses-29.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/cp/parser.c
trunk/gcc/testsuite/ChangeLog

[Bug c/70436] [4.9/5/6 Regression] -Wparentheses missing ambiguous else warning

2016-04-06 Thread ppalka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70436

--- Comment #13 from Patrick Palka  ---
Author: ppalka
Date: Wed Apr  6 23:07:21 2016
New Revision: 234801

URL: https://gcc.gnu.org/viewcvs?rev=234801=gcc=rev
Log:
Fix new -Wparentheses warnings encountered during bootstrap

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.
* tree-parloops.c (eliminate_local_variables): Likewise.

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/testsuite/ChangeLog:

PR c/70436
* g++.dg/plugin/pragma_plugin.c (handle_pragma_sayhello): Add
explicit braces to resolve a future -Wparentheses warning.


Modified:
trunk/gcc/ChangeLog
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/cp-tree.h
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/openmp.c
trunk/gcc/gimplify.c
trunk/gcc/omp-low.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/g++.dg/plugin/pragma_plugin.c
trunk/gcc/tree-parloops.c

[Bug c/70436] [4.9/5/6 Regression] -Wparentheses missing ambiguous else warning

2016-04-05 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70436

Richard Biener  changed:

   What|Removed |Added

   Keywords||diagnostic
   Priority|P3  |P2
   Target Milestone|--- |4.9.4

[Bug c/70436] [4.9/5/6 Regression] -Wparentheses missing ambiguous else warning

2016-03-31 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70436

--- Comment #12 from Jakub Jelinek  ---
They should be.
if (x)
#pragma omp for
  for (...)
if (y)
  ...
else
  ...
and #pragma omp simd and #pragma omp taskloop too.
For C++, perhaps we could just pass around if_p argument to a few more parsing
functions.

[Bug c/70436] [4.9/5/6 Regression] -Wparentheses missing ambiguous else warning

2016-03-31 Thread ppalka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70436

--- Comment #11 from Patrick Palka  ---
Should non-standard constructs be considered in this PR? I noticed that we also
don't warn on

  if (a)
  #pragma GCC ivdep
 while (1)
   if (b)
 bar ();
  else
baz ();

and

  if (a)
_Cilk_for (int i = 0; i < 10; i++)
  if (b)
bar ();
  else
baz ();

and probably other such constructs.

[Bug c/70436] [4.9/5/6 Regression] -Wparentheses missing ambiguous else warning

2016-03-29 Thread joseph at codesourcery dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70436

--- Comment #10 from joseph at codesourcery dot com  ---
I'd consider it a bug that the existing -Wparentheses warning for 
ambiguous "else" doesn't warn in this case.  As with the existing warning, 
that warning is only appropriate when there is in fact ambiguity (thus, 
not if there were two more "else" clauses in this example so that every 
"if" had one and there was no ambiguity), though the indentation could 
still be misleading without such ambiguity.  I think the existing warning, 
controlled by the existing option (or any new option that's a subset of 
-Wparentheses and enabled by it), should apply to all cases where the 
syntax for statements permits multiple parses differing in which "if" an 
"else" is associated with, and the rule associating it with the nearest 
has to be applied to select between those alternatives.

(Obviously global state as in the prototype is not a correct part of any 
sensible implementation of such a warning, as you need to keep track of 
arbitrarily many nested states for "if" statements currently being 
parsed.)

[Bug c/70436] [4.9/5/6 Regression] -Wparentheses missing ambiguous else warning

2016-03-29 Thread bernds at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70436

--- Comment #9 from Bernd Schmidt  ---
I suspect what broke it was git revision 0375a27521885.

[Bug c/70436] [4.9/5/6 Regression] -Wparentheses missing ambiguous else warning

2016-03-29 Thread bernds at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70436

Bernd Schmidt  changed:

   What|Removed |Added

 CC||bernds at gcc dot gnu.org
Summary|-Wmisleading-indentation|[4.9/5/6 Regression]
   |missing warning |-Wparentheses missing
   ||ambiguous else warning

--- Comment #8 from Bernd Schmidt  ---
This should be part of -Wparentheses, where we already have dangling else
warnings (called "ambiguous else"). Earlier versions of gcc warned for this
case.