[PATCH] D126258: [Clang] Avoid misleading 'conflicting types' diagnostic with no-prototype decls.
Cyndy Ishida via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 24 08:46:38 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa1a14e817eeb: [Clang] Avoid misleading 'conflicting types' diagnostic with no-prototype decls. (authored by cishida).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126258/new/
https://reviews.llvm.org/D126258
Files:
clang/lib/Sema/SemaDecl.cpp
clang/test/Sema/prototype-redecls.c
Index: clang/test/Sema/prototype-redecls.c
===================================================================
--- clang/test/Sema/prototype-redecls.c
+++ clang/test/Sema/prototype-redecls.c
@@ -12,6 +12,10 @@
void blerp(short); // expected-note {{previous}}
void blerp(x) int x; {} // expected-error {{conflicting types for 'blerp'}}
+void foo(int); // expected-note {{previous}}
+void foo();
+void foo() {} // expected-error {{conflicting types for 'foo'}}
+
void glerp(int);
void glerp(x) short x; {} // Okay, promoted type is fine
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -3911,6 +3911,8 @@
// ASTContext::typesAreCompatible().
if (Old->hasPrototype() && !New->hasWrittenPrototype() && NewDeclIsDefn &&
Old->getNumParams() != New->getNumParams()) {
+ if (Old->hasInheritedPrototype())
+ Old = Old->getCanonicalDecl();
Diag(New->getLocation(), diag::err_conflicting_types) << New;
Diag(Old->getLocation(), PrevDiag) << Old << Old->getType();
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126258.431687.patch
Type: text/x-patch
Size: 1152 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220524/8d0fab5d/attachment.bin>
More information about the cfe-commits
mailing list