Open llvmbot opened 7 years ago
Assume you place the code into the file testcpp.cpp
clang++ testcpp.cpp
No error is present
clang++ -DBADTEST=1 testcpp.cpp
testcpp.cpp:3:2: error: invalid preprocessing directive
In various dialects of C and C++, the
is not a diagnosable error, or is indeed specified to not be an error.
For dialects with "non-directive"s or "conditionally-supported-directive"s, the
is considered to be such a directive.
A provision, present since ISO C90 (in subclause 6.8.1), specifies that directives in groups that are skipped are only processed up to the "name" for tracking nested conditionals. This appears to erase the question of the semantics for a non-directive.
In ISO C90, there are no non-directives; so, I read
as a violation of a syntax rules (requiring a diagnostic).
In the C++17 DIS, it appears that
shall be diagnosed as an error if the implementation does not document it as a supported conditionally-supported-directive.
Please provide the compiler invocation commands. In particular the description provided does not indicate whether BADTEST is defined via the command line, what language dialect is being used, and whether warnings or pedantic checking is enabled.
Extended Description
The following has a bad keyword, yet clang will parse it just fine.
if BADTEST
include
ele
include
endif
include
int main(int, char **) { exit(0); }