[Bug c/105972] [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 since r12-4608-gb4702276615ff8d4

2023-01-11 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105972

--- Comment #7 from CVS Commits  ---
The master branch has been updated by Jakub Jelinek :

https://gcc.gnu.org/g:23b4ce18379cd336d99d7c71701be28118905b57

commit r13-5112-g23b4ce18379cd336d99d7c71701be28118905b57
Author: Jakub Jelinek 
Date:   Wed Jan 11 22:18:42 2023 +0100

c: Don't emit DEBUG_BEGIN_STMTs for K&R function argument declarations
[PR105972]

K&R function parameter declarations are handled by calling
recursively c_parser_declaration_or_fndef in a loop, where each such
call will add_debug_begin_stmt at the start.
Now, if the K&R function definition is not a nested function,
building_stmt_list_p () is false and so we don't emit the DEBUG_BEGIN_STMTs
anywhere, but if it is a nested function, we emit it in the containing
function at the point of the nested function definition.
As the following testcase shows, it can cause ICEs if the containing
function has var-tracking disabled but nested function has them enabled,
as the DEBUG_BEGIN_STMTs are added to the containing function which
shouldn't have them but MAY_HAVE_DEBUG_MARKER_STMTS is checked already
for the nested function, or just wrong experience in the debugger.

The following patch ensures we don't emit any such DEBUG_BEGIN_STMTs for
the
K&R function parameter declarations even in nested functions.

2023-01-11  Jakub Jelinek  

PR c/105972
* c-parser.cc (c_parser_declaration_or_fndef): Disable debug
non-bind
markers for K&R function parameter declarations of nested
functions.

* gcc.dg/pr105972.c: New test.

[Bug c/105972] [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 since r12-4608-gb4702276615ff8d4

2023-01-11 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105972

Jakub Jelinek  changed:

   What|Removed |Added

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

--- Comment #6 from Jakub Jelinek  ---
Created attachment 54246
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54246&action=edit
gcc13-pr105972.patch

Untested fix.

[Bug c/105972] [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 since r12-4608-gb4702276615ff8d4

2023-01-11 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105972

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org
   Priority|P4  |P2

--- Comment #5 from Jakub Jelinek  ---
This ICEs also on the valid
__attribute__((optimize(0))) int
foo ()
{
  int
  bar (x)
int x;
  {
return x;
  }
  return bar (0);
}
with -O2 -g.
If I comment out the optimize attribute, then with -O2 -g
-fdump-tree-gimple-lineno
one can see:
  [pr105972-2.c:5:3] # DEBUG BEGIN_STMT
  [pr105972-2.c:7:5] # DEBUG BEGIN_STMT
  [pr105972-2.c:11:3] # DEBUG BEGIN_STMT
statements in foo and
  [pr105972-2.c:9:5] # DEBUG BEGIN_STMT
in bar.  The line 7 statement is just incorrect, IMHO shouldn't be added at
all, when parsing the K&R parameter declarations, there is no reasonable code
point to emit those.
For normal K&R functions, they aren't just emitted because

[Bug c/105972] [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 since r12-4608-gb4702276615ff8d4

2023-01-11 Thread marxin at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105972

Martin Liška  changed:

   What|Removed |Added

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

--- Comment #4 from Martin Liška  ---
(In reply to Richard Biener from comment #1)
> Confirmed.  Somehow we get in .original
> 
> ;; Function f (null)
> ;; enabled by -tree-original
> 
> 
> {
>   static int g ();
> 
>   # DEBUG BEGIN STMT;
> static int g ();
> }

Hm, here we end up with a nested function whose parsing is probably skipped and
we end up with the wrong options.
Dunno why.

[Bug c/105972] [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 since r12-4608-gb4702276615ff8d4

2022-08-19 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105972

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|12.2|12.3

--- Comment #3 from Richard Biener  ---
GCC 12.2 is being released, retargeting bugs to GCC 12.3.

[Bug c/105972] [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 since r12-4608-gb4702276615ff8d4

2022-07-25 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105972

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2

[Bug c/105972] [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 since r12-4608-gb4702276615ff8d4

2022-07-25 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105972

Richard Biener  changed:

   What|Removed |Added

   Priority|P2  |P4

[Bug c/105972] [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 since r12-4608-gb4702276615ff8d4

2022-06-16 Thread marxin at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105972

Martin Liška  changed:

   What|Removed |Added

 CC||marxin at gcc dot gnu.org
   Keywords|needs-bisection |
 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |marxin at gcc dot 
gnu.org
Summary|[12/13 Regression] ICE in   |[12/13 Regression] ICE in
   |lower_stmt, at  |lower_stmt, at
   |gimple-low.cc:312   |gimple-low.cc:312 since
   ||r12-4608-gb4702276615ff8d4

--- Comment #2 from Martin Liška  ---
Started with my revision r12-4608-gb4702276615ff8d4, I'll take a look.