Bug 28050 - ICE on invalid initializer
Summary: ICE on invalid initializer
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: objc++ (show other bugs)
Version: 4.2.0
: P4 normal
Target Milestone: ---
Assignee: Nicola Pero
URL:
Keywords: error-recovery, ice-on-invalid-code, monitored
: 40507 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-06-16 02:09 UTC by Volker Reichelt
Modified: 2010-10-05 19:25 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.3.3, 4.4.0
Last reconfirmed: 2009-03-31 22:22:36


Attachments
Robustify C/objC parser (511 bytes, patch)
2008-01-12 22:03 UTC, Steven Bosscher
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2006-06-16 02:09:32 UTC
The following invalid code snippet causes an ICE since GCC 4.1.0:

======================
int i = [0];
======================

bug.m:1: error: expected ':' before ']' token
bug.m:1: internal compiler error: Segmentation fault
Please submit a full bug report, [etc.]

This also happens with the objc++ frontend.
Comment 1 Andrew Pinski 2006-06-17 02:24:59 UTC
Confirmed:
#0  0x000000000040c9ff in objc_build_message_expr (mess=0x2aaaaaf3b900)
    at /home/pinskia/src/gcc-4.1/gcc/gcc/objc/objc-act.c:6178
#1  0x0000000000472de9 in c_parser_postfix_expression (parser=0x2aaaaae03410)
    at /home/pinskia/src/gcc-4.1/gcc/gcc/c-parser.c:5172
#2  0x0000000000471a31 in c_parser_unary_expression (parser=0x2aaaaae03410) at /home/pinskia/src/gcc-4.1/gcc/gcc/c-parser.c:4622
#3  0x0000000000471350 in c_parser_cast_expression (parser=0x2aaaaae03410, after=0x0)
    at /home/pinskia/src/gcc-4.1/gcc/gcc/c-parser.c:4498
Comment 2 Steven Bosscher 2008-01-12 22:03:23 UTC
Created attachment 14932 [details]
Robustify C/objC parser

Tested (objc only) on cygwin.
Comment 3 Joseph S. Myers 2008-07-04 21:24:36 UTC
Closing 4.1 branch.
Comment 4 Joseph S. Myers 2009-03-31 19:38:34 UTC
Closing 4.2 branch.  The C part of the attached patch is OK.
Comment 5 ayers 2009-03-31 22:22:34 UTC
Technically this doesn't ICE anymore, yet I've been told that an "confused by earlier errors, bailing out" is equivalent... so I'll reconfirm this.

The patch from looks sane to me.  Has there been an official RFA for this?

I could post it together with the test case if you like?
Comment 6 Andrew Pinski 2009-03-31 22:43:37 UTC
(In reply to comment #5)
> Technically this doesn't ICE anymore, yet I've been told that an "confused by
> earlier errors, bailing out" is equivalent... so I'll reconfirm this.

That is an ICE if you have checking enabled.
Comment 7 Andrew Pinski 2009-06-21 23:18:47 UTC
*** Bug 40507 has been marked as a duplicate of this bug. ***
Comment 8 Steven Bosscher 2009-06-22 08:12:04 UTC
Re. Comment #5:
I have no plans to sumbit this patch. But do feel free to foster-parent it ;-)
Comment 9 Matthias Klose 2009-06-22 15:18:56 UTC
Subject: Bug 28050

Author: doko
Date: Mon Jun 22 15:18:38 2009
New Revision: 148804

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=148804
Log:
gcc/
2009-06-22  Steven Bosscher  <steven@gcc.gnu.org>

        PR objc/28050
        * c-parser.c (c_parser_objc_message_args): Return error_mark_node
        instead of NULL if a parser error occurs.

gcc/objc/
2009-06-22  Steven Bosscher  <steven@gcc.gnu.org>

        PR objc/28050
        * objc-act.c (objc_build_message_args): Return if ARGS is the
        error_mark_node.

gcc/testsuite/
2009-06-22  Matthias Klose  <doko@ubuntu.com>

        PR objc/28050
        * pr28050.m: New testcase.

Added:
    trunk/gcc/testsuite/objc.dg/pr28050.m
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-parser.c
    trunk/gcc/objc/ChangeLog
    trunk/gcc/objc/objc-act.c
    trunk/gcc/testsuite/ChangeLog

Comment 10 Steven Bosscher 2009-06-22 16:14:57 UTC
Note that we usually add the name of the committer to the ChangeLog too, like so:

2009-06-22  Steven Bosscher  <...>
            Matthias Klose <...>

etc.

But thanks for handling the patch. Fixed on trunk.
Comment 11 Matthias Klose 2009-06-22 22:21:46 UTC
Subject: Bug 28050

Author: doko
Date: Mon Jun 22 22:21:17 2009
New Revision: 148819

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=148819
Log:
gcc/
2009-06-22  Steven Bosscher  <steven@gcc.gnu.org>
            Matthias Klose  <doko@ubuntu.com>

        PR objc/28050
        * c-parser.c (c_parser_objc_message_args): Return error_mark_node
        instead of NULL if a parser error occurs.

gcc/objc/
2009-06-22  Steven Bosscher  <steven@gcc.gnu.org>
            Matthias Klose  <doko@ubuntu.com>

        PR objc/28050
        * objc-act.c (objc_build_message_args): Return if ARGS is the
        error_mark_node.

gcc/testsuite/
2009-06-22  Matthias Klose  <doko@ubuntu.com>

        PR objc/28050
        * pr28050.m: New testcase.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/objc.dg/pr28050.m
      - copied unchanged from r148804, trunk/gcc/testsuite/objc.dg/pr28050.m
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/c-parser.c
    branches/gcc-4_3-branch/gcc/objc/ChangeLog
    branches/gcc-4_3-branch/gcc/objc/objc-act.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 12 Matthias Klose 2009-06-22 22:25:49 UTC
Subject: Bug 28050

Author: doko
Date: Mon Jun 22 22:25:38 2009
New Revision: 148820

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=148820
Log:
gcc/
2009-06-22  Steven Bosscher  <steven@gcc.gnu.org>
            Matthias Klose  <doko@ubuntu.com>

        PR objc/28050
        * c-parser.c (c_parser_objc_message_args): Return error_mark_node
        instead of NULL if a parser error occurs.

gcc/objc/
2009-06-22  Steven Bosscher  <steven@gcc.gnu.org>
            Matthias Klose  <doko@ubuntu.com>

        PR objc/28050
        * objc-act.c (objc_build_message_args): Return if ARGS is the
        error_mark_node.

gcc/testsuite/
2009-06-22  Matthias Klose  <doko@ubuntu.com>

        PR objc/28050
        * pr28050.m: New testcase.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/objc.dg/pr28050.m
      - copied unchanged from r148804, trunk/gcc/testsuite/objc.dg/pr28050.m
Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/c-parser.c
    branches/gcc-4_4-branch/gcc/objc/ChangeLog
    branches/gcc-4_4-branch/gcc/objc/objc-act.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog

Comment 13 Volker Reichelt 2009-07-18 10:54:06 UTC
The objc++ isn't fixed yet, but this is not a regression.
Comment 14 Nicola Pero 2010-10-05 16:48:47 UTC
ObjC is already fixed; I have a patch (pending approval) that fixes this for ObjC++ as well.

Thanks
Comment 15 Nicola Pero 2010-10-05 19:23:40 UTC
Author: nicola
Date: Tue Oct  5 19:23:33 2010
New Revision: 164997

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=164997
Log:
In gcc/:
2010-10-05  Nicola Pero  <nicola.pero@meta-innovation.com>

        * c-parser.c (c_parser_objc_method_definition): Updated comment.

In gcc/cp/:
2010-10-05  Nicola Pero  <nicola.pero@meta-innovation.com>

        PR objc++/31125
        * parser.c (cp_parser_objc_class_interface): If no identifier
        follows an @interface token, stop parsing the interface after
        printing an error.
        (cp_parser_objc_class_implementation): If no identifier follows an
        @implementation token, stop parsing the implementation after
        printing an error.

2010-10-05  Nicola Pero  <nicola.pero@meta-innovation.com>

        PR objc++/23707
        * parser.c (cp_parser_objc_method_keyword_params): If the required
        colon is not found while parsing parameters, stop parsing them.

2010-10-05  Nicola Pero  <nicola.pero@meta-innovation.com>

        PR objc++/31126
        * parser.c (cp_parser_objc_class_ivars): Do not eat the EOF or
        @end after detecting it.  Print an error if @end is found without
        a '}'.
        (cp_parser_objc_method_prototype_list): Do not eat the EOF after
        detecting it.  Fixed reading the next token when continuing
        because of an error in a method signature.  Print an error if EOF
        is found without an '@end'.
        (cp_parser_objc_method_definition_list): Same change.

2010-10-05  Nicola Pero  <nicola.pero@meta-innovation.com>

        Merge from apple/trunk branch on FSF servers:

        2005-10-17  Fariborz Jahanian <fjahanian@apple.com>

        Radar 4290840
        * parser.c (cp_parser_objc_method_keyword_params): Check for valid
        method parameters and issue error.
        (cp_parser_objc_method_definition_list): Check for invalid tokens
        which cannot start a function definition.

        2005-10-14  Fariborz Jahanian <fjahanian@apple.com>

        Radar 4294425
        * parser.c (cp_parser_objc_message_args): Check for missing message
        arguments and syntax error.

        2005-10-13  Fariborz Jahanian <fjahanian@apple.com>

        Radar 4261146
        * parser.c (cp_parser_objc_class_ivars): Check for @end/eof while
        looking for '}'.

        2005-08-15  Ziemowit Laski  <zlaski@apple.com>

        Radar 4093475
        * parser.c (cp_parser_objc_interstitial_code): Catch stray
        '{' and '}' tokens and issue appropriate errors.

        2005-08-02  Ziemowit Laski  <zlaski@apple.com>

        Radar 4185810
        (cp_parser_statement_seq_opt): In addition to '}' and
        end-of-file, a statement sequence may also be terminated
        by a stray '@end'.

In gcc/objc/:
2010-10-05  Nicola Pero  <nicola.pero@meta-innovation.com>

        Merge from 'apple/trunk' branch on FSF servers.

        2005-10-17  Fariborz Jahanian <fjahanian@apple.com>

        Radar 4290840
        * objc-act.c (objc_start_method_definition): Check for error_mark_node for
        the selector name and make a quick exit.

In gcc/testsuite/:
2010-10-05  Nicola Pero  <nicola.pero@meta-innovation.com>

        PR objc++/28050
        * obj-c++.dg/syntax-error-10.mm: New.

2010-10-05  Nicola Pero  <nicola.pero@meta-innovation.com>

        PR objc++/23707
        * obj-c++.dg/syntax-error-9.mm: New.

2010-10-05  Nicola Pero  <nicola.pero@meta-innovation.com>

        PR objc++/31126
        * obj-c++.dg/syntax-error-8.mm: New.

2010-10-05  Nicola Pero  <nicola.pero@meta-innovation.com>

        Merge from 'apple/trunk' branch on FSF servers.

        2005-10-17  Fariborz Jahanian <fjahanian@apple.com>

        Radar 4290840
        * obj-c++.dg/syntax-error-7.mm: New

        2005-10-14  Fariborz Jahanian <fjahanian@apple.com>

        Radar 4294425
        * obj-c++.dg/syntax-error-6.mm: New

        2005-10-13  Fariborz Jahanian <fjahanian@apple.com>

        Radar 4261146
        * obj-c++.dg/syntax-error-5.mm: New

        2005-08-15  Ziemowit Laski  <zlaski@apple.com>

        Radar 4093475
        * obj-c++.dg/syntax-error-[3-4].mm: New.

        2005-08-02  Ziemowit Laski  <zlaski@apple.com>

        Radar 4185810
        * obj-c++.dg/syntax-error-[1-2].mm: New.

Added:
    trunk/gcc/testsuite/obj-c++.dg/syntax-error-1.mm
    trunk/gcc/testsuite/obj-c++.dg/syntax-error-10.mm
    trunk/gcc/testsuite/obj-c++.dg/syntax-error-2.mm
    trunk/gcc/testsuite/obj-c++.dg/syntax-error-3.mm
    trunk/gcc/testsuite/obj-c++.dg/syntax-error-4.mm
    trunk/gcc/testsuite/obj-c++.dg/syntax-error-5.mm
    trunk/gcc/testsuite/obj-c++.dg/syntax-error-6.mm
    trunk/gcc/testsuite/obj-c++.dg/syntax-error-7.mm
    trunk/gcc/testsuite/obj-c++.dg/syntax-error-8.mm
    trunk/gcc/testsuite/obj-c++.dg/syntax-error-9.mm
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-parser.c
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/objc/ChangeLog
    trunk/gcc/objc/objc-act.c
    trunk/gcc/testsuite/ChangeLog
Comment 16 Nicola Pero 2010-10-05 19:25:32 UTC
Fixed in trunk.

Thanks