[clang] [C2y] Allow static local variables in inline functions with external … (PR #167086)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 10 06:14:41 PST 2025
================
@@ -8120,8 +8125,15 @@ NamedDecl *Sema::ActOnVariableDeclarator(
!NewVD->getType().isConstQualified()) {
FunctionDecl *CurFD = getCurFunctionDecl();
if (CurFD && isFunctionDefinitionDiscarded(*this, CurFD)) {
- Diag(D.getDeclSpec().getStorageClassSpecLoc(),
- diag::warn_static_local_in_extern_inline);
+ unsigned DiagID;
+ if (getLangOpts().C2y)
+ DiagID = diag::warn_c2y_compat_static_local_in_extern_inline;
+ else if (getSourceManager().isInMainFile(D.getBeginLoc()))
+ DiagID = diag::ext_static_local_in_extern_inline_quiet;
----------------
AaronBallman wrote:
I don't think we need this diagnostic in this case; I think that's specific to the case where we were calling a function, not using a variable.
https://github.com/llvm/llvm-project/pull/167086
More information about the cfe-commits
mailing list