OSDN Git Service

* pt.c (unify) [TEMPLATE_TYPE_PARM]: Allow VLA for C++0x 'auto'.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 5 Aug 2011 19:12:01 +0000 (19:12 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 5 Aug 2011 19:12:01 +0000 (19:12 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177476 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/vla11.C [new file with mode: 0644]

index 9e2a01d..3d9b3b6 100644 (file)
@@ -1,3 +1,7 @@
+2011-08-05  Jason Merrill  <jason@redhat.com>
+
+       * pt.c (unify) [TEMPLATE_TYPE_PARM]: Allow VLA for C++0x 'auto'.
+
 2011-08-04  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/49905
index 571da6d..10fdced 100644 (file)
@@ -15932,10 +15932,11 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
             that were talking about variable-sized arrays (like
             `int[n]'), rather than arrays of unknown size (like
             `int[]').)  We'll get very confused by such a type since
-            the bound of the array will not be computable in an
-            instantiation.  Besides, such types are not allowed in
-            ISO C++, so we can do as we please here.  */
-         if (variably_modified_type_p (arg, NULL_TREE))
+            the bound of the array is not constant, and therefore
+            not mangleable.  Besides, such types are not allowed in
+            ISO C++, so we can do as we please here.  We do allow
+            them for 'auto' deduction, since that isn't ABI-exposed.  */
+         if (!is_auto (parm) && variably_modified_type_p (arg, NULL_TREE))
            return unify_vla_arg (explain_p, arg);
 
          /* Strip typedefs as in convert_template_argument.  */
index 7801705..24e145c 100644 (file)
@@ -1,3 +1,7 @@
+2011-08-05  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/ext/vla11.C: New.
+
 2011-08-05  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/49984
diff --git a/gcc/testsuite/g++.dg/ext/vla11.C b/gcc/testsuite/g++.dg/ext/vla11.C
new file mode 100644 (file)
index 0000000..8f3be9e
--- /dev/null
@@ -0,0 +1,8 @@
+// Test that auto works with VLAs.
+// { dg-options -std=c++0x }
+
+void bar(int n)
+{
+  float loc2[n];
+  auto&& range = loc2;
+}