Commit f33e4dd7 by Jason Merrill Committed by Jason Merrill

re PR c++/42013 (cv-qualification of conditional expression type depending on…

re PR c++/42013 (cv-qualification of conditional expression type depending on the value of its first expression?!?)

	PR c++/42013
	* call.c (build_conditional_expr): Don't fold a TREE_SIDE_EFFECTS
	COND_EXPR in unevaluated context.

From-SVN: r154124
parent 9d324dde
2009-11-12 Jason Merrill <jason@redhat.com>
PR c++/42013
* call.c (build_conditional_expr): Don't fold a TREE_SIDE_EFFECTS
COND_EXPR in unevaluated context.
2009-11-12 Jan Hubicka <jh@suse.cz> 2009-11-12 Jan Hubicka <jh@suse.cz>
* decl2.c (constrain_visibility): Clear WEAK and COMMON flags. * decl2.c (constrain_visibility): Clear WEAK and COMMON flags.
......
...@@ -3991,8 +3991,13 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3, ...@@ -3991,8 +3991,13 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3,
} }
valid_operands: valid_operands:
result = fold_if_not_in_template (build3 (COND_EXPR, result_type, arg1, result = build3 (COND_EXPR, result_type, arg1, arg2, arg3);
arg2, arg3));
if (cp_unevaluated_operand && TREE_SIDE_EFFECTS (result))
/* Avoid folding a ?: of two calls within decltype (c++/42013). */;
else
result = fold_if_not_in_template (result);
/* We can't use result_type below, as fold might have returned a /* We can't use result_type below, as fold might have returned a
throw_expr. */ throw_expr. */
......
2009-11-12 Jason Merrill <jason@redhat.com>
PR c++/42013
* g++.dg/cpp0x/decltype19.C: New.
2009-11-11 Jason Merrill <jason@redhat.com> 2009-11-11 Jason Merrill <jason@redhat.com>
PR c++/39131 PR c++/39131
......
// PR c++/42013
template<typename _Tp>
_Tp
declval();
template<typename _Tp, typename _Up>
struct common_type
{
typedef __decltype(true ? declval<_Tp>() : declval<_Up>()) typet;
typedef __decltype(false ? declval<_Tp>() : declval<_Up>()) typef;
};
template<typename, typename> struct is_same;
template<typename _Tp> struct is_same<_Tp, _Tp> { typedef _Tp type; };
void f()
{
typedef common_type<int, const int>::typet typet;
typedef common_type<int, const int>::typef typef;
typedef is_same<typet, typef>::type 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