From: Paolo Carlini Date: Fri, 27 May 2011 14:21:33 +0000 (+0000) Subject: re PR c++/42056 (ICE with invalid use of auto in template) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=efaa76b31d79af03bcd7291053f407357b4d35bb;p=gcc.git re PR c++/42056 (ICE with invalid use of auto in template) /cp 2011-05-27 Paolo Carlini PR c++/42056 * typeck2.c (build_functional_cast): Complain early for invalid uses of 'auto' and set type to error_mark_node. /testsuite 2011-05-27 Paolo Carlini PR c++/42056 * testsuite/g++.dg/cpp0x/auto25.C: New. From-SVN: r174337 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ed758c4e050..cd2ff472355 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-05-27 Paolo Carlini + + PR c++/42056 + * typeck2.c (build_functional_cast): Complain early for invalid uses + of 'auto' and set type to error_mark_node. + 2011-05-26 Jason Merrill PR c++/47721 diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index c2eff9eb6c8..031f076863f 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1599,6 +1599,13 @@ build_functional_cast (tree exp, tree parms, tsubst_flags_t complain) return error_mark_node; } + if (type_uses_auto (type)) + { + if (complain & tf_error) + error ("invalid use of %"); + type = error_mark_node; + } + if (processing_template_decl) { tree t; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b11ddc230e8..61892232fff 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-05-27 Paolo Carlini + + PR c++/42056 + * testsuite/g++.dg/cpp0x/auto25.C: New. + 2011-05-27 Richard Guenther * gcc.c-torture/execute/920711-1.x: Add -fwrapv. diff --git a/gcc/testsuite/g++.dg/cpp0x/auto25.C b/gcc/testsuite/g++.dg/cpp0x/auto25.C new file mode 100644 index 00000000000..2917c0e1978 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto25.C @@ -0,0 +1,12 @@ +// PR c++/42056 +// { dg-options -std=c++0x } + +template struct A +{ + int a[auto(1)]; // { dg-error "invalid use of" } +}; + +template void foo() +{ + int a[auto(1)]; // { dg-error "invalid use of" } +}