Skip to content

False positive of -Wunused-local-typedef in dependent code. #98878

Open
@hokein

Description

@hokein

Given the following code:

#define TYPE_OR_NONTYPE  typename
template<TYPE_OR_NONTYPE T>
struct BaseT {
  static int ff();
  void Foo();
};

template<TYPE_OR_NONTYPE T>
struct DerivedT : BaseT<T> {
  void Inner();
};

template<TYPE_OR_NONTYPE T>
void DerivedT<T>::Inner() {
  using K = BaseT<T>; 
  this->K::Foo(); 
}

clang emits a unused typedef warning.

⇒  ./bin/clang -Xclang  -fsyntax-only -Wunused-local-typedef  --std=c++20 /tmp/t2.cpp
/tmp/t2.cpp:15:9: warning: unused type alias 'K' [-Wunused-local-typedef]
   15 |   using K = BaseT<T>;
      |  

This is shown in abseil/abseil-cpp#1711.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second partyfalse-positiveWarning fires when it should not

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions