Bug 31126 - Infinite loop on missing @end
Summary: Infinite loop on missing @end
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: objc++ (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Nicola Pero
URL:
Keywords: error-recovery, monitored
Depends on:
Blocks:
 
Reported: 2007-03-10 23:23 UTC by Volker Reichelt
Modified: 2010-10-05 19:27 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-10-05 12:54:20


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2007-03-10 23:23:28 UTC
The compiler enters an infinite loop since GCC 4.1.0 on the following
invalid code snippet:

===============
@interface A
===============

bug.mm:1: error: expected unqualified-id at end of input
bug.mm:1: error: expected unqualified-id at end of input
bug.mm:1: error: expected unqualified-id at end of input
bug.mm:1: error: expected unqualified-id at end of input
bug.mm:1: error: expected unqualified-id at end of input
...
Comment 1 Nicola Pero 2010-10-05 19:23:39 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 2 Nicola Pero 2010-10-05 19:27:36 UTC
Fixed in trunk.

Thanks