+2002-10-18 Jason Merrill <jason@redhat.com>
+
+ PR c++/8080
+ * semantics.c (finish_for_cond, finish_while_cond): Don't mess
+ with condition decls in a template.
+
2002-10-17 Nathan Sidwell <nathan@codesourcery.com>
* class.c (add_method): Compare template parms too.
tree while_stmt;
{
cond = maybe_convert_cond (cond);
- if (getdecls () == NULL_TREE)
+ if (processing_template_decl)
+ /* Don't mess with condition decls in a template. */
+ FINISH_COND (cond, while_stmt, WHILE_COND (while_stmt));
+ else if (getdecls () == NULL_TREE)
/* It was a simple condition; install it. */
WHILE_COND (while_stmt) = cond;
else
tree for_stmt;
{
cond = maybe_convert_cond (cond);
- if (getdecls () == NULL_TREE)
+ if (processing_template_decl)
+ /* Don't mess with condition decls in a template. */
+ FINISH_COND (cond, for_stmt, FOR_COND (for_stmt));
+ else if (getdecls () == NULL_TREE)
/* It was a simple condition; install it. */
FOR_COND (for_stmt) = cond;
else
--- /dev/null
+// PR c++/8080
+
+// Bug: the transformation in finish_while_stmt_cond produced something
+// that tsubst_expr handled badly. Fixed by not doing the transformation
+// while parsing a template.
+
+class TObject {};
+
+struct TIter {
+ TObject *operator()();
+};
+
+
+template<class T>
+void get_root_object(TIter& iobj) {
+ while ( TObject* pnew_obj = iobj() )
+ ;
+}
+
+void foo(TIter& iobj)
+{
+ get_root_object<int>(iobj);
+}