Clang has the following test cases:
#if 0
#ifdef D
#else 1 // Should not warn due to C99 6.10p4
#endif
#endif
#if 0
#else 1 // expected-warning {{extra tokens}}
#endif
The first #else 1 indeed is fine because it’s in a skipped group, but as far as I can see the second one should be an error – it doesn’t match what the standard specifies as the syntax for preprocessor directives – yet GCC and Microsoft C++ agree on only giving it a warning. What am I missing?
The standard does not have notions of “error” and “warning”, it only knows “diagnostic”. It is up to implementation to define what constitutes a diagnostic. Most implementations of C, including clang and gcc, define diagnostics to include both errors and warnings.