GCC incorrectly accepts the following: #if 0 #elif __VA_ARGS__ #endif The same applies to __VA_OPT__. It is rejected in #if, so it should be rejected in #elif too if it was not skipped. Clang rejects it even in skipped #elif directives (replace 0 with 1 in the above), though I think that should not be done.
Are you sure this is not valid? 6.10.1/7 has: ``` When in a group that is skipped (6.10.2), the directive syntax is relaxed to allow any sequence of preprocessing tokens to occur between the directive name and the following new-line character. ``` But then 6.10.5/5 has: ``` The identifiers __VA_ARGS__ and __VA_OPT__ shall occur only in the replacement-list of a functionlike macro that uses the ellipsis notation in the parameters ``` I think GCC is correct here because "the directive syntax is relaxed to allow any sequence of preprocessing tokens". Note the use of any. Or there is defect in the standard. Because the way I am reading this is the identifiers should be allowed.
(In reply to Drea Pinski from comment #1) > Are you sure this is not valid? > > > 6.10.1/7 has: > ``` > When in a group that is skipped (6.10.2), the directive syntax is relaxed to > allow any sequence of > preprocessing tokens to occur between the directive name and the following > new-line character. > ``` > > But then 6.10.5/5 has: > ``` > The identifiers __VA_ARGS__ and __VA_OPT__ shall occur only in the > replacement-list of a functionlike macro that uses the ellipsis notation in > the parameters > ``` > > I think GCC is correct here because "the directive syntax is relaxed to > allow any sequence of preprocessing tokens". Note the use of any. Or there > is defect in the standard. Because the way I am reading this is the > identifiers should be allowed. But it is not skipped. For example, the following is rejected: #if 0 #elif 0/0 #endif
I misread the testcase.