diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 917457b18046..a6248b68735f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2004-01-26 Mark Mitchell + PR c++/13663 + * semantics.c (finish_for_expr): Check for unresolved overloaded + functions. + * class.c (add_method): Just check processing_template_decl to determine whether or not we are within a template. * decl2.c (maybe_retrofit_in_chrg): Likewise. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 69364d8f6738..deb5b820ed4a 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -678,6 +678,13 @@ finish_for_cond (tree cond, tree for_stmt) void finish_for_expr (tree expr, tree for_stmt) { + /* If EXPR is an overloaded function, issue an error; there is no + context available to use to perform overload resolution. */ + if (expr && type_unknown_p (expr)) + { + cxx_incomplete_type_error (expr, TREE_TYPE (expr)); + expr = error_mark_node; + } FOR_EXPR (for_stmt) = expr; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5618d1de3c45..3d25f199c216 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-01-26 Mark Mitchell + + PR c++/13363 + * g++.dg/expr/for1.C: New test. + 2004-01-26 Fariborz Jahanian PR middle-end/13779 diff --git a/gcc/testsuite/g++.dg/expr/for1.C b/gcc/testsuite/g++.dg/expr/for1.C new file mode 100644 index 000000000000..baffd424a411 --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/for1.C @@ -0,0 +1,14 @@ +// PR c++/13663 + +struct S { + void f(); +}; + +void g(int); +void g(double); + +void h () { + S s; + for (;;s.f); // { dg-error "" } + for (;;g); // { dg-error "" } +}