* cp-gimplify.c (cp_gimplify_expr) [MODIFY_EXPR]: Use
VIEW_CONVERT_EXPR for conversions between structural equality types
that the back end can't tell are the same.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156793
138bc75d-0d04-0410-961f-
82ee72b054a4
2010-02-16 Jason Merrill <jason@redhat.com>
+ PR c++/43031
+ * cp-gimplify.c (cp_gimplify_expr) [MODIFY_EXPR]: Use
+ VIEW_CONVERT_EXPR for conversions between structural equality types
+ that the back end can't tell are the same.
+
PR c++/43036
* tree.c (build_cplus_array_type): Set TYPE_MAIN_VARIANT to strip
cv-quals from element here.
25979. */
case INIT_EXPR:
cp_gimplify_init_expr (expr_p, pre_p, post_p);
+ /* Fall through. */
+ case MODIFY_EXPR:
+ {
+ /* If the back end isn't clever enough to know that the lhs and rhs
+ types are the same, add an explicit conversion. */
+ tree op0 = TREE_OPERAND (*expr_p, 0);
+ tree op1 = TREE_OPERAND (*expr_p, 1);
+
+ if ((TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (op0))
+ || TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (op1)))
+ && !useless_type_conversion_p (TREE_TYPE (op1), TREE_TYPE (op0)))
+ TREE_OPERAND (*expr_p, 1) = build1 (VIEW_CONVERT_EXPR,
+ TREE_TYPE (op0), op1);
+ }
ret = GS_OK;
break;
2010-02-16 Jason Merrill <jason@redhat.com>
+ PR c++/43031
+ * g++.dg/ext/attrib36.C: New.
+
PR c++/43036
* g++.dg/other/array6.C: New.
--- /dev/null
+// PR c++/43031
+// { dg-do compile { target i?86-*-* x86_64-*-* } }
+
+class T;
+class L { };
+class P : public L
+{
+ typedef void (__attribute__((__stdcall__)) T::*F) (L*);
+ void f(bool aAdd);
+};
+class T
+{
+public:
+ virtual void __attribute__((__stdcall__)) A(L *listener) = 0;
+ virtual void __attribute__((__stdcall__)) R(L *listener) = 0;
+};
+void P::f(bool aAdd)
+{
+ F addRemoveEventListener = (aAdd ? &T::A : &T::R);
+}