[PATCH] D126258: [Clang] Avoid misleading 'conflicting types' diagnostic with no-prototype decls.
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 24 06:17:00 PDT 2022
aaron.ballman added inline comments.
================
Comment at: clang/lib/Sema/SemaDecl.cpp:3914-3918
+ if (Old->hasInheritedPrototype())
+ Old = Old->getCanonicalDecl();
Diag(New->getLocation(), diag::err_conflicting_types) << New;
Diag(Old->getLocation(), PrevDiag) << Old << Old->getType();
return true;
----------------
cishida wrote:
> aaron.ballman wrote:
> > I don't think it's safe to assign this new value to `Old` as that object is what we eventually merge the declaration with (so we'll get the decl chain order wrong, I believe).
> Ah, I hadn't realized we still can merge decls together in a fatal error case.
Oh shoot, good point, we early return here anyway, so the assignment won't matter. So the code LGTM as-is, thank you!
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126258/new/
https://reviews.llvm.org/D126258
More information about the cfe-commits
mailing list