* Fix PR69824, crash in C frontend
[not found] <56DA1DD9.5090608@t-online.de>
@ 2016-03-04 23:49 ` Bernd Schmidt
2016-03-05 0:08 ` Joseph Myers
0 siblings, 1 reply; 3+ messages in thread
From: Bernd Schmidt @ 2016-03-04 23:49 UTC (permalink / raw)
To: GCC Patches, Joseph Myers
[-- Attachment #1: Type: text/plain, Size: 356 bytes --]
This is a crash encountered with an implicit declaration inside an
argument list. In the PR, Jakub identified a place where we change the
DECL_CONTEXT for such decls, and I think I agree with him that this
seems wrong. The following patch ensures they aren't placed on the list
in the first place.
Bootstrapped and tested on x86_64-linux, ok?
Bernd
[-- Attachment #2: implicit-crash.diff --]
[-- Type: text/x-patch, Size: 1834 bytes --]
c/
PR c/69824
* c-decl.c (get_parm_info): Don't queue implicit function declarations
for later.
testsuite/
PR c/69824
* gcc.dg/pr69824.c: New test.
Index: gcc/c/c-decl.c
===================================================================
--- gcc/c/c-decl.c (revision 233451)
+++ gcc/c/c-decl.c (working copy)
@@ -7050,25 +7050,28 @@ get_parm_info (bool ellipsis, tree expr)
vec_safe_push (tags, tag);
break;
+ case FUNCTION_DECL:
+ /* FUNCTION_DECLs appear when there is an implicit function
+ declaration in the parameter list. */
+ gcc_assert (b->nested);
+ goto set_shadowed;
+
case CONST_DECL:
case TYPE_DECL:
- case FUNCTION_DECL:
/* CONST_DECLs appear here when we have an embedded enum,
and TYPE_DECLs appear here when we have an embedded struct
or union. No warnings for this - we already warned about the
- type itself. FUNCTION_DECLs appear when there is an implicit
- function declaration in the parameter list. */
+ type itself. */
/* When we reinsert this decl in the function body, we need
to reconstruct whether it was marked as nested. */
- gcc_assert (TREE_CODE (decl) == FUNCTION_DECL
- ? b->nested
- : !b->nested);
+ gcc_assert (!b->nested);
DECL_CHAIN (decl) = others;
others = decl;
/* fall through */
case ERROR_MARK:
+ set_shadowed:
/* error_mark_node appears here when we have an undeclared
variable. Just throw it away. */
if (b->id)
Index: gcc/testsuite/gcc.dg/pr69824.c
===================================================================
--- gcc/testsuite/gcc.dg/pr69824.c (revision 0)
+++ gcc/testsuite/gcc.dg/pr69824.c (working copy)
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-w" } */
+int bar() { return foo(); }
+void baz(int c[foo()]) { return; }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Fix PR69824, crash in C frontend
2016-03-04 23:49 ` Fix PR69824, crash in C frontend Bernd Schmidt
@ 2016-03-05 0:08 ` Joseph Myers
2016-03-05 5:23 ` Jeff Law
0 siblings, 1 reply; 3+ messages in thread
From: Joseph Myers @ 2016-03-05 0:08 UTC (permalink / raw)
To: Bernd Schmidt; +Cc: GCC Patches
On Sat, 5 Mar 2016, Bernd Schmidt wrote:
> This is a crash encountered with an implicit declaration inside an argument
> list. In the PR, Jakub identified a place where we change the DECL_CONTEXT for
> such decls, and I think I agree with him that this seems wrong. The following
> patch ensures they aren't placed on the list in the first place.
>
> Bootstrapped and tested on x86_64-linux, ok?
OK.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Fix PR69824, crash in C frontend
2016-03-05 0:08 ` Joseph Myers
@ 2016-03-05 5:23 ` Jeff Law
0 siblings, 0 replies; 3+ messages in thread
From: Jeff Law @ 2016-03-05 5:23 UTC (permalink / raw)
To: Joseph Myers, Bernd Schmidt; +Cc: GCC Patches
On 03/04/2016 05:08 PM, Joseph Myers wrote:
> On Sat, 5 Mar 2016, Bernd Schmidt wrote:
>
>> This is a crash encountered with an implicit declaration inside an argument
>> list. In the PR, Jakub identified a place where we change the DECL_CONTEXT for
>> such decls, and I think I agree with him that this seems wrong. The following
>> patch ensures they aren't placed on the list in the first place.
>>
>> Bootstrapped and tested on x86_64-linux, ok?
>
> OK.
I went ahead and committed this to the trunk and removed the the gcc-6
regression marker in the BZ. Bernd's call if/when to backport to the
existing release branches.
jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-03-05 5:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <56DA1DD9.5090608@t-online.de>
2016-03-04 23:49 ` Fix PR69824, crash in C frontend Bernd Schmidt
2016-03-05 0:08 ` Joseph Myers
2016-03-05 5:23 ` Jeff Law
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).