re PR c++/48531 ([C++0x][SFINAE] Hard errors with arrays of unknown bound)
authorJason Merrill <jason@redhat.com>
Thu, 14 Apr 2011 15:00:15 +0000 (11:00 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 14 Apr 2011 15:00:15 +0000 (11:00 -0400)
PR c++/48531
* init.c (build_value_init_noctor): Check complain consistently.

From-SVN: r172434

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/sfinae15.C [new file with mode: 0644]

index 1b60dd439dd95b4c87caf1c5f7974ac17e67350f..64ea98e1febea51bf99f21f0b02ba6929ae870af 100644 (file)
@@ -1,5 +1,8 @@
 2011-04-14  Jason Merrill  <jason@redhat.com>
 
+       PR c++/48531
+       * init.c (build_value_init_noctor): Check complain consistently.
+
        PR c++/48557
        * typeck.c (cp_build_binary_op): Don't decay void operands.
 
index 32afa03f53885a6adb3720fe4a0d9b161ecd6b70..fad7f0c3004af0eb2663378e6e4f3bd54a7784dd 100644 (file)
@@ -422,7 +422,9 @@ build_value_init_noctor (tree type, tsubst_flags_t complain)
         as we don't know the size of the array yet.  */
       if (max_index == error_mark_node)
        {
-         error ("cannot value-initialize array of unknown bound %qT", type);
+         if (complain & tf_error)
+           error ("cannot value-initialize array of unknown bound %qT",
+                  type);
          return error_mark_node;
        }
       gcc_assert (TREE_CODE (max_index) == INTEGER_CST);
index 8a5f5ae90695f8e3f4069d74f19ca9f64ba6bffb..3eca0d403931448fd808c4ac349ec897cc1b7c48 100644 (file)
@@ -1,5 +1,7 @@
 2011-04-14  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/sfinae15.C: New.
+
        * g++.dg/cpp0x/sfinae14.C: New.
 
        * g++.dg/ext/vla10.C: New.
diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae15.C b/gcc/testsuite/g++.dg/cpp0x/sfinae15.C
new file mode 100644 (file)
index 0000000..595ca40
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/48531
+// { dg-options -std=c++0x }
+
+template<class T,
+  class = decltype(T())
+>
+char f(int);
+
+template<class>
+char (&f(...))[2];
+
+static_assert(sizeof(f<int[]>(0)) != 1, "Error");