From: Kai Tietz Date: Sat, 25 Dec 2010 10:41:05 +0000 (+0000) Subject: re PR c++/15774 (Conflicting function decls not diagnosed) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bc30fc12b1cbcd1942d93b5e555a1ed7195a73b8;p=gcc.git re PR c++/15774 (Conflicting function decls not diagnosed) 2010-12-25 Kai Tietz 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 PR c++/15774 * g++.dg/warn/pr15774-1.C: New test. * g++.dg/warn/pr15774-2.C: New test. From-SVN: r168241 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5bdfa436820..09e43530ca8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2010-12-25 Kai Tietz + + PR c++/15774 + * decl.c (decls_match): Check for FUNCTION_DECL + also for identity of compatible attributes. + 2010-12-22 Nathan Froyd * decl.c (decls_match, duplicate_decls): Use prototype_p. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index f74b0c22917..f7bf1bfdb40 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2f07ea6c7ff..db09e3963fe 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2010-12-25 Kai Tietz + + PR c++/15774 + * g++.dg/warn/pr15774-1.C: New test. + * g++.dg/warn/pr15774-2.C: New test. + 2010-12-24 Nicola Pero * 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 index 00000000000..efd4daeb6f8 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/pr15774-1.C @@ -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 index 00000000000..f890b7af7d9 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/pr15774-2.C @@ -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) +{ +} + +