[patch c++]:PR/15774 - Conflicting function decls not diagnosed (this time really for 15774)
Kai Tietz
ktietz70@googlemail.com
Thu Dec 23 12:33:00 GMT 2010
Hello,
as we discussed yesterday on IRC, I simplified patch by doing checks
for compatible attributes directly within decl, but take care the
newdecl possibly can omit attributes.
ChangeLog gcc/cp
2010-12-23 Kai Tietz
* decl.c (decls_match): Check for FUNCTION_DECL
also for identity of compatible attributes.
ChangeLog gcc/testsuite
2010-12-23 Kai Tietz
* g++.dg/pr15774-1.C: New test.
* g++.dg/pr15774-2.C: New test.
Tested for x86_64-w64-mingw32, i686-pc-cygwin, and i686-pc-mingw32. Ok
for apply?
Regards,
Kai
-------------- next part --------------
Index: gcc/gcc/cp/decl.c
===================================================================
--- gcc.orig/gcc/cp/decl.c 2010-12-23 11:16:30.063178000 +0100
+++ gcc/gcc/cp/decl.c 2010-12-23 11:18:59.781928200 +0100
@@ -1009,7 +1009,11 @@ decls_match (tree newdecl, tree olddecl)
}
#endif
else
- types_match = compparms (p1, p2);
+ types_match =
+ compparms (p1, p2)
+ && (TYPE_ATTRIBUTES (TREE_TYPE (newdecl)) == NULL_TREE
+ || targetm.comp_type_attributes (TREE_TYPE (newdecl),
+ TREE_TYPE (olddecl)) != 0);
}
else
types_match = 0;
Index: gcc/gcc/testsuite/g++.dg/pr15774-1.C
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gcc/gcc/testsuite/g++.dg/pr15774-1.C 2010-12-23 11:18:59.813178200 +0100
@@ -0,0 +1,15 @@
+// { dg-do compile { target i?86-*-* } }
+// Test that an new declartion with different attributes then old one fail.
+extern void foo (int); // { dg-error "ambiguates old declaration" }
+
+void
+bar (void)
+{
+ foo (1);
+}
+
+void __attribute__((stdcall)) foo (int i) // { dg-error "new declaration" }
+{
+}
+
+
Index: gcc/gcc/testsuite/g++.dg/pr15774-2.C
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gcc/gcc/testsuite/g++.dg/pr15774-2.C 2010-12-23 11:18:59.813178200 +0100
@@ -0,0 +1,15 @@
+// { dg-do compile { target i?86-*-* } }
+// Test that old declaration is used, if new one has no attributes.
+extern void __attribute__((stdcall)) foo (int);
+
+void
+bar (void)
+{
+ foo (1);
+}
+
+void foo (int i)
+{
+}
+
+
More information about the Gcc-patches
mailing list