A function type with the x86 fastcall attribute is different from one
without it, but standard_conversion was ignoring attributes. Changed to
use same_type_p on the static function type rather than trying to
duplicate the logic here.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 9a052e2c5427f20378a2c683422c701b87532ad9
Author: Jason Merrill <ja...@redhat.com>
Date: Wed Jan 11 17:41:56 2012 -0500
PR c++/51565
* call.c (standard_conversion): For ptrmemfuncs, compare the
static_fn_types.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 57b1765..f7cfbd0 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -1274,10 +1274,8 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p,
tree tbase = class_of_this_parm (tofn);
if (!DERIVED_FROM_P (fbase, tbase)
- || !same_type_p (TREE_TYPE (fromfn), TREE_TYPE (tofn))
- || !compparms (TREE_CHAIN (TYPE_ARG_TYPES (fromfn)),
- TREE_CHAIN (TYPE_ARG_TYPES (tofn)))
- || cp_type_quals (fbase) != cp_type_quals (tbase))
+ || !same_type_p (static_fn_type (fromfn),
+ static_fn_type (tofn)))
return NULL;
from = build_memfn_type (fromfn, tbase, cp_type_quals (tbase));
diff --git a/gcc/testsuite/g++.dg/ext/attrib42.C b/gcc/testsuite/g++.dg/ext/attrib42.C
new file mode 100644
index 0000000..39b8e22
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/attrib42.C
@@ -0,0 +1,12 @@
+// { dg-do compile { target i?86-*-* } }
+
+struct A {
+ __attribute__((fastcall))
+ void f();
+};
+
+int main()
+{
+ typedef void (A::*FP)();
+ FP fp[] = {&A::f}; // { dg-error "cannot convert" }
+}