Bug 36320 - Required diagnosis of syntax error missed
: Required diagnosis of syntax error missed
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: preprocessor
: 4.1.3
: P3 normal
: 4.4.0
Assigned To: Tom Tromey
:
:
: 36453
:
  Show dependency treegraph
 
Reported: 2008-05-24 10:55 UTC by Neil Booth
Modified: 2008-06-06 20:03 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-05-24 18:04:32


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Neil Booth 2008-05-24 10:55:37 UTC
The syntax error in #elif below is not diagnosed with (say) --std=c99
-pedantic-errors.

int z;
#if 1
#elif
#endif

Syntax is:

elif-group:
        # elif constant-expression new-line groupopt

and constant expression cannot be empty.  The syntax relaxation of 6.10p4 does
not apply as the group that the #elif lies in (beginning with the #if) is not
skipped.
Comment 1 Tom Tromey 2008-05-24 16:21:05 UTC
Confirmed.  This seems like a weird design to me, but my reading of the
standard text agrees with yours.
Comment 2 Tom Tromey 2008-05-24 18:04:32 UTC
Testing a patch.
Comment 3 Tom Tromey 2008-05-30 14:25:55 UTC
Subject: Bug 36320

Author: tromey
Date: Fri May 30 14:25:09 2008
New Revision: 136209

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=136209
Log:
gcc/testsuite
    PR preprocessor/36320:
    * gcc.dg/cpp/pr36320.c: New file.
libcpp
    PR preprocessor/36320:
    * internal.h (_cpp_parse_expr): Update.
    * expr.c (_cpp_parse_expr): Add 'is_if' argument.  Update error
    messages.
    * directives.c (do_if): Update.
    (do_elif): Require expression if processing group.

Added:
    trunk/gcc/testsuite/gcc.dg/cpp/pr36320.c
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/libcpp/ChangeLog
    trunk/libcpp/directives.c
    trunk/libcpp/expr.c
    trunk/libcpp/internal.h
Comment 4 Tom Tromey 2008-05-30 15:07:04 UTC
Fixed on trunk.