[clang] [Clang][Sema] Diagnose use of template keyword after declarative nested-name-specifiers (PR #78595)

Jordan Rupprecht via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 7 13:08:24 PST 2024


rupprecht wrote:

It looks like this caused some new `-Wextra-qualification` warnings (playground: https://godbolt.org/z/3MbMjGYET)

```
namespace foo {
template <typename T>
struct Z {};

template <>
struct Z<bool> {}; // OK

template <>
struct foo::Z<int> {}; // New warning: extra qualification on member 'Z' [-Wextra-qualification]

template <>
struct ::foo::Z<double> {}; // New warning: extra qualification on member 'Z' [-Wextra-qualification]
}  // namespace foo
```

This doesn't use `template` in the way described in the commit or the release notes, so it doesn't seem like an intentional change. But GCC already errors on this (and downgrades to a warning with `-fpermissive`), so Clang isn't necessarily wrong to start warning about this now. Still, it's possible GCC and Clang are both wrong now, so I just want to make sure that's actually a desired side effect of this commit.

This behavior change is covered by the test diffs here in clang/test/CXX/drs/dr23xx.cpp and clang/test/SemaTemplate/class-template-spec.cpp.

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


More information about the cfe-commits mailing list