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) +{ +} + +