================
@@ -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
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to