+2010-03-22 Jason Merrill <jason@redhat.com>
+
+ PR c++/43281
+ * pt.c (contains_auto_r): New fn.
+ (do_auto_deduction): Use it.
+ (tsubst): Don't look at TREE_TYPE of a TEMPLATE_TYPE_PARM.
+
2010-03-20 Simon Martin <simartin@users.sourceforge.net>
PR c++/43081:
if (type
&& TREE_CODE (t) != TYPENAME_TYPE
+ && TREE_CODE (t) != TEMPLATE_TYPE_PARM
&& TREE_CODE (t) != IDENTIFIER_NODE
&& TREE_CODE (t) != FUNCTION_TYPE
&& TREE_CODE (t) != METHOD_TYPE)
return tsubst (type, argvec, tf_warning_or_error, NULL_TREE);
}
+/* walk_tree helper for do_auto_deduction. */
+
+static tree
+contains_auto_r (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
+ void *type)
+{
+ /* Is this a variable with the type we're looking for? */
+ if (DECL_P (*tp)
+ && TREE_TYPE (*tp) == type)
+ return *tp;
+ else
+ return NULL_TREE;
+}
+
/* Replace occurrences of 'auto' in TYPE with the appropriate type deduced
from INIT. AUTO_NODE is the TEMPLATE_TYPE_PARM used for 'auto' in TYPE. */
{
tree parms, tparms, targs;
tree args[1];
+ tree decl;
int val;
+ /* The name of the object being declared shall not appear in the
+ initializer expression. */
+ decl = cp_walk_tree_without_duplicates (&init, contains_auto_r, type);
+ if (decl)
+ {
+ error ("variable %q#D with %<auto%> type used in its own "
+ "initializer", decl);
+ return error_mark_node;
+ }
+
/* [dcl.spec.auto]: Obtain P from T by replacing the occurrences of auto
with either a new invented type template parameter U or, if the
initializer is a braced-init-list (8.5.4), with
2010-03-22 Jason Merrill <jason@redhat.com>
+ PR c++/43281
+ * g++.dg/cpp0x/auto18.C: New.
+
* gcc.dg/pr36997.c: Adjust error message.
* g++.dg/ext/vector9.C: Likewise.
* g++.dg/conversion/simd3.C: Likewise.