[clang] Avoid assert in substqualifier (PR #182707)

via cfe-commits cfe-commits at lists.llvm.org
Sat May 9 08:41:52 PDT 2026


TPPPP72 wrote:

Because this PR triggered a regrssion issue #195416 , I did some investigation.

So I don't think it is a correct fix.

For code
```cpp
template <typename T> int f(T) {
  struct A {
    static int B;
  };
  int A::B; 
}

int x = f(1);
```

The assertion still remain
```
repro.cpp:3:16: error: static data member 'B' not allowed in local struct 'A'
    3 |     static int B;
      |                ^
clang-23: /home/TPPPP/Documents/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:60: bool SubstQualifier(Sema &, const DeclT *, DeclT *, const MultiLevelTemplateArgumentList &) [DeclT = clang::DeclaratorDecl]: Assertion `(NewDecl->getFriendObjectKind() || !OldDecl->getLexicalDeclContext()->isDependentContext()) && "non-friend with qualified name defined in dependent context"' failed.
```

Current test `int MyClass::staticField = 42` misjudged the fundamental problem and the example I just provided would not trigger the modification involved in this PR.

https://github.com/llvm/llvm-project/pull/182707


More information about the cfe-commits mailing list