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.
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
Created attachment 14932 [details] Robustify C/objC parser Tested (objc only) on cygwin.
Closing 4.1 branch.
Closing 4.2 branch. The C part of the attached patch is OK.
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?
(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.
*** Bug 40507 has been marked as a duplicate of this bug. ***
Re. Comment #5: I have no plans to sumbit this patch. But do feel free to foster-parent it ;-)
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
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.
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
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
The objc++ isn't fixed yet, but this is not a regression.
ObjC is already fixed; I have a patch (pending approval) that fixes this for ObjC++ as well. Thanks
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
Fixed in trunk. Thanks