From: Jason Merrill Date: Fri, 5 Aug 2011 19:12:01 +0000 (-0400) Subject: * pt.c (unify) [TEMPLATE_TYPE_PARM]: Allow VLA for C++0x 'auto'. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3bed46f67f40e6c3feaa5f02beebf4d52b3ffab5;p=gcc.git * pt.c (unify) [TEMPLATE_TYPE_PARM]: Allow VLA for C++0x 'auto'. From-SVN: r177476 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9e2a01d8acd..3d9b3b6f71e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2011-08-05 Jason Merrill + + * pt.c (unify) [TEMPLATE_TYPE_PARM]: Allow VLA for C++0x 'auto'. + 2011-08-04 Jakub Jelinek PR middle-end/49905 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 571da6ddb7f..10fdceda462 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 78017058ccb..24e145c09e9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-08-05 Jason Merrill + + * g++.dg/ext/vla11.C: New. + 2011-08-05 Richard Guenther 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 00000000000..8f3be9e56c2 --- /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; +}