This is an archive of the discontinued LLVM Phabricator instance.

[clang] Fix wrong -Wunused-local-typedef warning if use is a dependent qualified identifier
Needs ReviewPublic

Authored by krisb on Nov 23 2021, 8:32 AM.

Details

Summary

Attempt to fix Tom Smeding's example from https://bugs.llvm.org/show_bug.cgi?id=24883.

Given the case like this one:

struct A {
  void f() const {}
};

template <typename T>
void handler(const T &item) {
  using a_type_t = A;
  item.a_type_t::f();
}

int main() {
  handler(A());
}

there is no way to know whether the typedef is used or not before
the templated context is instantiated.

Having this the patch proposes deffering all the diagnostics for
typedefs defined within a dependent context.

Diff Detail

Event Timeline

krisb requested review of this revision.Nov 23 2021, 8:32 AM
krisb created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptNov 23 2021, 8:32 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
krisb updated this revision to Diff 391312.Dec 2 2021, 6:43 AM

Simplified diagnostic condition in TemplateDeclInstantiator::InstantiateTypedefNameDecl().

krisb retitled this revision from [clang] Fix wrong -Wunused-local-typedef warning if use is a dependent qialified identifier to [clang] Fix wrong -Wunused-local-typedef warning if use is a dependent qualified identifier.Mar 21 2022, 3:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 21 2022, 3:27 AM