2015-04-14 Jason Merrill <jason@redhat.com>
+ PR c++/65695
+ * cvt.c (cp_fold_convert): Avoid wrapping PTRMEM_CST in NOP_EXPR.
+
PR c++/65721
* name-lookup.c (do_class_using_decl): Complain about specifying
the current class even if there are dependent bases.
tree
cp_fold_convert (tree type, tree expr)
{
- tree conv = fold_convert (type, expr);
- conv = ignore_overflows (conv, expr);
+ tree conv;
+ if (TREE_TYPE (expr) == type)
+ conv = expr;
+ else if (TREE_CODE (expr) == PTRMEM_CST)
+ {
+ /* Avoid wrapping a PTRMEM_CST in NOP_EXPR. */
+ conv = copy_node (expr);
+ TREE_TYPE (conv) = type;
+ }
+ else
+ {
+ conv = fold_convert (type, expr);
+ conv = ignore_overflows (conv, expr);
+ }
return conv;
}
--- /dev/null
+// PR c++/65695
+// { dg-do compile { target c++11 } }
+
+struct Foo;
+
+struct Bar
+{
+ using MemberFuncT = int (Foo::*)();
+
+ MemberFuncT h_;
+ constexpr Bar(MemberFuncT h) : h_{h}
+ {
+ }
+};
+
+struct Foo
+{
+ int test()
+ {
+ return -1;
+ }
+
+ static constexpr Bar bar {&Foo::test};
+};
+
+constexpr Bar Foo::bar;