On 05/27/2011 03:57 PM, Jason Merrill wrote:
OK, but please combine those tests into one file.
Thanks. As applied.

Paolo.

//////////////
/cp
2011-05-27  Paolo Carlini  <[email protected]>

        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  <[email protected]>

        PR c++/42056
        * testsuite/g++.dg/cpp0x/auto25.C: New.
Index: testsuite/g++.dg/cpp0x/auto25.C
===================================================================
--- testsuite/g++.dg/cpp0x/auto25.C     (revision 0)
+++ testsuite/g++.dg/cpp0x/auto25.C     (revision 0)
@@ -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" }
+}
Index: cp/typeck2.c
===================================================================
--- cp/typeck2.c        (revision 174324)
+++ cp/typeck2.c        (working copy)
@@ -1599,6 +1599,13 @@ build_functional_cast (tree exp, tree parms, tsubs
       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;

Reply via email to