Commit 4ddd8a74 by Jason Merrill Committed by Jason Merrill

re PR c++/48531 ([C++0x][SFINAE] Hard errors with arrays of unknown bound)

	PR c++/48531
	* typeck2.c (build_functional_cast): Disallow array type.

From-SVN: r172632
parent 991e0156
2011-04-17 Jason Merrill <jason@redhat.com> 2011-04-17 Jason Merrill <jason@redhat.com>
PR c++/48531
* typeck2.c (build_functional_cast): Disallow array type.
* tree.c (get_target_expr): Handle VEC_INIT_EXPR. * tree.c (get_target_expr): Handle VEC_INIT_EXPR.
2011-04-17 Jan Hubicka <jh@suse.cz> 2011-04-17 Jan Hubicka <jh@suse.cz>
......
...@@ -369,6 +369,8 @@ build_value_init (tree type, tsubst_flags_t complain) ...@@ -369,6 +369,8 @@ build_value_init (tree type, tsubst_flags_t complain)
tree tree
build_value_init_noctor (tree type, tsubst_flags_t complain) build_value_init_noctor (tree type, tsubst_flags_t complain)
{ {
/* FIXME the class and array cases should just use digest_init once it is
SFINAE-enabled. */
if (CLASS_TYPE_P (type)) if (CLASS_TYPE_P (type))
{ {
gcc_assert (!TYPE_NEEDS_CONSTRUCTING (type)); gcc_assert (!TYPE_NEEDS_CONSTRUCTING (type));
...@@ -450,7 +452,9 @@ build_value_init_noctor (tree type, tsubst_flags_t complain) ...@@ -450,7 +452,9 @@ build_value_init_noctor (tree type, tsubst_flags_t complain)
if (ce->value == error_mark_node) if (ce->value == error_mark_node)
return error_mark_node; return error_mark_node;
/* The gimplifier can't deal with a RANGE_EXPR of TARGET_EXPRs. */ /* We shouldn't have gotten here for anything that would need
non-trivial initialization, and gimplify_init_ctor_preeval
would need to be fixed to allow it. */
gcc_assert (TREE_CODE (ce->value) != TARGET_EXPR gcc_assert (TREE_CODE (ce->value) != TARGET_EXPR
&& TREE_CODE (ce->value) != AGGR_INIT_EXPR); && TREE_CODE (ce->value) != AGGR_INIT_EXPR);
} }
......
...@@ -1534,6 +1534,15 @@ build_functional_cast (tree exp, tree parms, tsubst_flags_t complain) ...@@ -1534,6 +1534,15 @@ build_functional_cast (tree exp, tree parms, tsubst_flags_t complain)
else else
type = exp; type = exp;
/* We need to check this explicitly, since value-initialization of
arrays is allowed in other situations. */
if (TREE_CODE (type) == ARRAY_TYPE)
{
if (complain & tf_error)
error ("functional cast to array type %qT", type);
return error_mark_node;
}
if (processing_template_decl) if (processing_template_decl)
{ {
tree t; tree t;
......
2011-04-17 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/sfinae16.C: New.
2011-04-17 Richard Sandiford <rdsandiford@googlemail.com> 2011-04-17 Richard Sandiford <rdsandiford@googlemail.com>
* gcc.target/mips/reg-var-1.c: New test. * gcc.target/mips/reg-var-1.c: New test.
......
// PR c++/48531
// { dg-options -std=c++0x }
template<class T,
class = decltype(T())
>
char f(int);
template<class>
double f(...);
struct B2 {
B2(...);
};
#define SA(X) static_assert ((X), #X);
SA(sizeof(f<B2[2]>(0)) != 1);
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