Commit 8d4bcc35 by Jason Merrill Committed by Jason Merrill

re PR c++/47851 ([C++0x] Incorrect decltype result for conditional operator)

	PR c++/47851
	* call.c (standard_conversion): Provide requested cv-quals on
	class rvalue conversion.

From-SVN: r170601
parent faa9e9bf
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.
......
......@@ -850,6 +850,7 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p,
enum tree_code fcode, tcode;
conversion *conv;
bool fromref = false;
tree qualified_to;
to = non_reference (to);
if (TREE_CODE (from) == REFERENCE_TYPE)
......@@ -857,6 +858,7 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p,
fromref = true;
from = TREE_TYPE (from);
}
qualified_to = to;
to = strip_top_quals (to);
from = strip_top_quals (from);
......@@ -918,7 +920,11 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p,
}
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>
......
// 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();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment