Ken Matsui a1545f51a9 Warn if using elifdef & elifndef in not C2x & C++2b mode
This adds an extension warning when using the preprocessor conditionals
in a language mode they're not officially supported in, and an opt-in
warning for compatibility with previous standards.

Fixes #55306
Differential Revision: https://reviews.llvm.org/D125178
2022-05-12 09:26:44 -04:00

35 lines
787 B
C

/* RUN: %clang_cc1 -E -verify %s
*/
/* expected-error@+1 {{macro name missing}} */
#ifdef
#endif
/* expected-error@+1 {{macro name must be an identifier}} */
#ifdef !
#endif
/* expected-error@+1 {{macro name missing}} */
#if defined
#endif
/* PR1936 */
/* expected-error@+2 {{unterminated function-like macro invocation}} expected-error@+2 {{expected value in expression}} expected-note@+1 {{macro 'f' defined here}} */
#define f(x) x
#if f(2
#endif
/* expected-error@+3 {{macro name missing}} */
/* expected-warning@+2 {{use of a '#elifdef' directive is a C2x extension}} */
#ifdef FOO
#elifdef
#endif
/* expected-error@+3 {{macro name must be an identifier}} */
/* expected-warning@+2 {{use of a '#elifdef' directive is a C2x extension}} */
#ifdef FOO
#elifdef !
#endif
int x;