2011-03-01 Jason Merrill <jason@redhat.com>
+ PR c++/47851
+ * call.c (standard_conversion): Provide requested cv-quals on
+ class rvalue conversion.
+
PR c++/46282
* decl2.c (grokbitfield): Handle type-dependent width.
enum tree_code fcode, tcode;
conversion *conv;
bool fromref = false;
+ tree qualified_to;
to = non_reference (to);
if (TREE_CODE (from) == REFERENCE_TYPE)
fromref = true;
from = TREE_TYPE (from);
}
+ qualified_to = to;
to = strip_top_quals (to);
from = strip_top_quals (from);
}
if (same_type_p (from, to))
- return conv;
+ {
+ if (CLASS_TYPE_P (to) && conv->kind == ck_rvalue)
+ conv->type = qualified_to;
+ return conv;
+ }
/* [conv.ptr]
A null pointer constant can be converted to a pointer type; ... A
2011-03-01 Jason Merrill <jason@redhat.com>
+ * g++.dg/cpp0x/decltype25.C: New.
+
* g++.dg/cpp0x/regress/bitfield-err1.C: New.
2011-03-01 Richard Guenther <rguenther@suse.de>
--- /dev/null
+// PR c++/47851
+// { dg-options -std=c++0x }
+
+struct Type {
+ void display_type();
+ void display_type() const { }
+};
+
+typedef Type const ConstType;
+
+struct ConvertibleToType {
+ operator Type&() { return *reinterpret_cast<Type*>(this); }
+};
+
+int main ()
+{
+ // Both lines should call the const variant.
+ (true ? ConvertibleToType() : ConstType()).display_type();
+ decltype((true ? ConvertibleToType() : ConstType()))().display_type();
+}