re PR c++/15774 (Conflicting function decls not diagnosed)
authorKai Tietz <kai.tietz@onevision.com>
Sat, 25 Dec 2010 10:41:05 +0000 (10:41 +0000)
committerKai Tietz <ktietz@gcc.gnu.org>
Sat, 25 Dec 2010 10:41:05 +0000 (11:41 +0100)
2010-12-25  Kai Tietz  <kai.tietz@onevision.com>

PR c++/15774
* decl.c (decls_match): Check for FUNCTION_DECL
also for identity of compatible attributes.

ChangeLog gcc/testsuite

2010-12-25  Kai Tietz  <kai.tietz@onevision.com>

PR c++/15774
* g++.dg/warn/pr15774-1.C: New test.
* g++.dg/warn/pr15774-2.C: New test.

From-SVN: r168241

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/pr15774-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/pr15774-2.C [new file with mode: 0644]

index 5bdfa436820b9e24dbcaa84531178b2ac84b747c..09e43530ca8b4e799705384a9ffbdc45176b7580 100644 (file)
@@ -1,3 +1,9 @@
+2010-12-25  Kai Tietz  <kai.tietz@onevision.com>
+
+       PR c++/15774
+       * decl.c (decls_match): Check for FUNCTION_DECL
+       also for identity of compatible attributes.
+
 2010-12-22  Nathan Froyd  <froydnj@codesourcery.com>
 
        * decl.c (decls_match, duplicate_decls): Use prototype_p.
index f74b0c22917a8634f926f38eadd2a54878b04bc8..f7bf1bfdb402250edc2016112a92f47fe6c00c00 100644 (file)
@@ -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 2f07ea6c7ff95293f84244a4a48649b52ef566f3..db09e3963fef3b5a4f5b03aed171de6636c84074 100644 (file)
@@ -1,3 +1,9 @@
+2010-12-25  Kai Tietz  <kai.tietz@onevision.com>
+
+       PR c++/15774
+       * g++.dg/warn/pr15774-1.C: New test.
+       * g++.dg/warn/pr15774-2.C: New test.
+
 2010-12-24  Nicola Pero  <nicola.pero@meta-innovation.com>
 
        * objc.dg/gnu-api-2-sel.m: Test calling sel_getUid,
diff --git a/gcc/testsuite/g++.dg/warn/pr15774-1.C b/gcc/testsuite/g++.dg/warn/pr15774-1.C
new file mode 100644 (file)
index 0000000..efd4dae
--- /dev/null
@@ -0,0 +1,15 @@
+// { dg-do compile { target { { i?86-*-* x86_64-*-* } && ilp32 } } }
+// 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" }
+{
+}
+
+
diff --git a/gcc/testsuite/g++.dg/warn/pr15774-2.C b/gcc/testsuite/g++.dg/warn/pr15774-2.C
new file mode 100644 (file)
index 0000000..f890b7a
--- /dev/null
@@ -0,0 +1,15 @@
+// { dg-do compile { target { { i?86-*-* x86_64-*-* } && ilp32 } } }
+// 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)
+{
+}
+
+