re PR c++/42056 (ICE with invalid use of auto in template)
authorPaolo Carlini <paolo.carlini@oracle.com>
Fri, 27 May 2011 14:21:33 +0000 (14:21 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 27 May 2011 14:21:33 +0000 (14:21 +0000)
/cp
2011-05-27  Paolo Carlini  <paolo.carlini@oracle.com>

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  <paolo.carlini@oracle.com>

PR c++/42056
* testsuite/g++.dg/cpp0x/auto25.C: New.

From-SVN: r174337

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

index ed758c4e050b0b1f1f652e0d46abd539c55bf137..cd2ff4723559a521022ff1ff294a99c0fc375a5e 100644 (file)
@@ -1,3 +1,9 @@
+2011-05-27  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       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  <jason@redhat.com>
 
        PR c++/47721
index c2eff9eb6c890f025d3f47a7aac57d455c415641..031f076863f0d85b1542f7fb1504fce27b61211b 100644 (file)
@@ -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 %<auto%>");
+      type = error_mark_node;
+    }
+
   if (processing_template_decl)
     {
       tree t;
index b11ddc230e8b9744b7fec92a64d8e3634e924ab4..61892232fffd790a7efd898721ef83ecbfd9e6aa 100644 (file)
@@ -1,3 +1,8 @@
+2011-05-27  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/42056
+       * testsuite/g++.dg/cpp0x/auto25.C: New.
+
 2011-05-27  Richard Guenther  <rguenther@suse.de>
 
        * 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 (file)
index 0000000..2917c0e
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/42056
+// { dg-options -std=c++0x }
+
+template<int> struct A
+{
+  int a[auto(1)]; // { dg-error "invalid use of" }
+};
+
+template<int> void foo()
+{
+  int a[auto(1)]; // { dg-error "invalid use of" }
+}