aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-08-05 15:12:01 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-08-05 15:12:01 -0400
commit3bed46f67f40e6c3feaa5f02beebf4d52b3ffab5 (patch)
tree46fecfa7f77fb6b434fdcad8acc5003d1655968b /gcc
parent2c331232e9ae426fc338928650355ecfab176290 (diff)
downloadgcc-3bed46f67f40e6c3feaa5f02beebf4d52b3ffab5.zip
gcc-3bed46f67f40e6c3feaa5f02beebf4d52b3ffab5.tar.gz
gcc-3bed46f67f40e6c3feaa5f02beebf4d52b3ffab5.tar.bz2
* pt.c (unify) [TEMPLATE_TYPE_PARM]: Allow VLA for C++0x 'auto'.
From-SVN: r177476
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/pt.c9
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/ext/vla11.C8
4 files changed, 21 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9e2a01d..3d9b3b6 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 571da6d..10fdced 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7801705..24e145c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..8f3be9e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/vla11.C
@@ -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;
+}