On Thu, Oct 21, 2021 at 2:40 PM Richard Smith - zygoloid via Phabricator <revi...@reviews.llvm.org> wrote: > > rsmith added a comment. > > > In this version of the patch, I am supporting the feature in all C and C++ > > modes. This seems like more useful functionality than diagnosing an unknown > > preprocessor directive in older language modes, and is a conforming > > extension in those modes anyway as use of an unknown directive is undefined > > behavior. > > Is this really true? I think: > > #define X > #if 0 > #elifdef X > #error > #endif > > ... is a valid translation unit in C++ and is strictly conforming in C11 and > earlier; any //conditionally-supported-directive// (using the C++ > terminology) within a //group// is ignored when skipping that //group//. > > That said... applying this to all language modes does seem like the right > choice, even though it may be technically non-conforming.
Hrmmm. You're correct that processing within a skipped group is special. C2x 6.10.1p9 says "...is skipped: directives are processed only through the name that determines the directive in order to keep track of the level of nested conditionals; the rest of the directives' preprocessing tokens are ignored." 6.10p9 says "The execution of a non-directive preprocessing directive results in undefined behavior." I believe we don't *execute* the directive as part of "directives are processed" because in order to execute the directive, we need to know the remaining preprocessing tokens for it. I was originally thinking that merely hitting the name was sufficient for us to enter into UB. So I think you're correct that this is technically nonconforming. That said, I still think it's the right decision because the alternative is worse. ~Aaron _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits