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.
Confirmed. This seems like a weird design to me, but my reading of the standard text agrees with yours.
Testing a patch.
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
Fixed on trunk.