Files
clang-p2996/clang/test/Preprocessor/if_warning.c
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
730 B
C

// RUN: %clang_cc1 %s -Eonly -Werror=undef -verify
extern int x;
#if foo // expected-error {{'foo' is not defined, evaluates to 0}}
#endif
// expected-warning@+2 {{use of a '#elifdef' directive is a C2x extension}}
#ifdef foo
#elifdef foo
#endif
#if defined(foo)
#endif
// PR3938
// expected-warning@+3 {{use of a '#elifdef' directive is a C2x extension}}
#if 0
#ifdef D
#elifdef D
#else 1 // Should not warn due to C99 6.10p4
#endif
#endif
// rdar://9475098
#if 0
#else 1 // expected-warning {{extra tokens}}
#endif
// PR6852
#if 'somesillylongthing' // expected-warning {{character constant too long for its type}} \
// expected-warning {{multi-character character constant}}
#endif