Issue 169166
Summary clang-tidy 22 check readability-redundant-typename triggers a false-positive result
Labels clang-tidy, false-positive
Assignees
Reporter pkl97
    In clang-tidy 22 this code fragment triggers a "Class.cpp:15:11: warning: redundant 'typename' [readability-redundant-typename]" warning.
```c++
#include <list>

template<typename T>
class Class
{
public:
    using Argument=std::list<T>;

 std::list<Argument> getArguments() const;
    
    std::list<Argument> arguments;
};

template<typename T>
std::list<typename Class<T>::Argument> Class<T>::getArguments() const // <-- the typename in question
{
    return arguments;
}
```

However if the "typename" keyword is removed from line 15, clang (and MSVC) refuse to compile the code.
clang (21.1.6/stable and 22/main) reports this error message:
```
Class.cpp:15:11: error: template argument for template type parameter must be a type; did you forget 'typename'?
```

It seems that the initial clang-tidy warning is a false-positive result.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to