Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should #elifdef and #elifndef have a portability warning? #55306

Closed
AaronBallman opened this issue May 6, 2022 · 4 comments
Closed

Should #elifdef and #elifndef have a portability warning? #55306

AaronBallman opened this issue May 6, 2022 · 4 comments
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer clang:frontend Language frontend issues, e.g. anything involving "Sema" good first issue https://github.com/llvm/llvm-project/contribute

Comments

@AaronBallman
Copy link
Collaborator

These are new features of C2x, but they're supported as a conforming extension in older versions of Clang. However, there's no pedantic warning given about them being a Clang extension in older language modes, so users may be surprised when porting to another compiler. See https://godbolt.org/z/MdK476q7b as an example. Should we be issuing a pedantic warning here?

@AaronBallman AaronBallman added good first issue https://github.com/llvm/llvm-project/contribute clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer labels May 6, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented May 6, 2022

@llvm/issue-subscribers-clang-frontend

@llvmbot
Copy link
Collaborator

llvmbot commented May 6, 2022

@llvm/issue-subscribers-good-first-issue

@josephcsible
Copy link

I think this is a good idea, as long as the warning will only trigger when you're actually using the older language modes (unlike, e.g., -Wc++98-compat, where x = nullptr; triggers it even in newer language modes).

@AaronBallman
Copy link
Collaborator Author

-Wc++98-compat is intended to warn you about all code constructs that are not compatible with the given language version, so it's only purpose is to fire in newer language modes.

The plan is for this diagnostic to behave like our other pairs of compat/extension warnings. e.g., Given

#ifdef FOO
#elifdef BAR
#endif

in pedantic C17 mode, we'll issue a "use of this is a C2x extension" warning, and in C2x mode with -Wpre-c2x-compat (which is default ignored), we'll issue a "use of this feature is not compatible with standards before C2x" warning. (And similar for C++ modes.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer clang:frontend Language frontend issues, e.g. anything involving "Sema" good first issue https://github.com/llvm/llvm-project/contribute
Projects
None yet
Development

No branches or pull requests

3 participants