[clang] [Sema] Don't call isNonConstantStorage on incomplete variable types (PR #161590)
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 6 10:23:19 PDT 2025
================
@@ -14919,7 +14919,7 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl *var) {
// Apply section attributes and pragmas to global variables.
if (GlobalStorage && var->isThisDeclarationADefinition() &&
- !inTemplateInstantiation()) {
+ !var->getDeclContext()->isDependentContext()) {
----------------
ahatanak wrote:
Yes, clang computes the section and emits the diagnostic for `b` without instantiation if `!type->isDependentType() ` is called instead of `!var->getDeclContext()->isDependentContext()`.
```
struct B1 { void *p; };
template <class T>
struct A1 {
__attribute__((section("non_trivial_ctor")))
static constexpr B1 b{nullptr};
};
// auto *p = &A1<int>::b;
```
https://github.com/llvm/llvm-project/pull/161590
More information about the cfe-commits
mailing list