aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-04-17 20:50:31 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-04-17 20:50:31 -0400
commit4ddd8a74ba5c23b5dd69d7b501a1d8c4ad053b4b (patch)
treecbdcad160c4dcac6149cddb741dbdbd9a60c22f1 /gcc
parent991e015686a39b50e4a756b463d250aeb07267f6 (diff)
downloadgcc-4ddd8a74ba5c23b5dd69d7b501a1d8c4ad053b4b.zip
gcc-4ddd8a74ba5c23b5dd69d7b501a1d8c4ad053b4b.tar.gz
gcc-4ddd8a74ba5c23b5dd69d7b501a1d8c4ad053b4b.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/init.c6
-rw-r--r--gcc/cp/typeck2.c9
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/sfinae16.C17
5 files changed, 38 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 04812d1..9364d01 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
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.
2011-04-17 Jan Hubicka <jh@suse.cz>
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index fad7f0c..3280d9b 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -369,6 +369,8 @@ build_value_init (tree type, tsubst_flags_t complain)
tree
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))
{
gcc_assert (!TYPE_NEEDS_CONSTRUCTING (type));
@@ -450,7 +452,9 @@ build_value_init_noctor (tree type, tsubst_flags_t complain)
if (ce->value == 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
&& TREE_CODE (ce->value) != AGGR_INIT_EXPR);
}
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 20b47d5..f0b67f7 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -1534,6 +1534,15 @@ build_functional_cast (tree exp, tree parms, tsubst_flags_t complain)
else
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)
{
tree t;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fa74ad2..5a28f60 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2011-04-17 Jason Merrill <jason@redhat.com>
+
+ * g++.dg/cpp0x/sfinae16.C: New.
+
2011-04-17 Richard Sandiford <rdsandiford@googlemail.com>
* gcc.target/mips/reg-var-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae16.C b/gcc/testsuite/g++.dg/cpp0x/sfinae16.C
new file mode 100644
index 0000000..6470567
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/sfinae16.C
@@ -0,0 +1,17 @@
+// 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);