diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f38b03dda3040945ace093ec80b2d9772c57c944..ac3c3bcdb99c76fa7288f942fd049654db20035c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2005-04-04 Mark Mitchell <mark@codesourcery.com> + + PR c++/20679 + * parser.c (cp_parser_template_name): Fix thinko. + 2005-04-04 Nathan Sidwell <nathan@codesourcery.com> PR c++/20746 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index d682f3a38aa366dd917c91b6deae51c6da6665c6..cb1623d681e3abc03385c1ae62893a05c0b7d152 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -8731,6 +8731,8 @@ cp_parser_template_name (cp_parser* parser, ; else { + tree fn = NULL_TREE; + /* The standard does not explicitly indicate whether a name that names a set of overloaded declarations, some of which are templates, is a template-name. However, such a name should @@ -8738,16 +8740,13 @@ cp_parser_template_name (cp_parser* parser, template-id for the overloaded templates. */ fns = BASELINK_P (decl) ? BASELINK_FUNCTIONS (decl) : decl; if (TREE_CODE (fns) == OVERLOAD) - { - tree fn; + for (fn = fns; fn; fn = OVL_NEXT (fn)) + if (TREE_CODE (OVL_CURRENT (fn)) == TEMPLATE_DECL) + break; - for (fn = fns; fn; fn = OVL_NEXT (fn)) - if (TREE_CODE (OVL_CURRENT (fn)) == TEMPLATE_DECL) - break; - } - else + if (!fn) { - /* Otherwise, the name does not name a template. */ + /* The name does not name a template. */ cp_parser_error (parser, "expected template-name"); return error_mark_node; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ddb7ae2d5103f0b1fe55a92b1aeaa41b322df02e..cca0e181801c579b875f52a7b0bdecb597c1f161 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-04-04 Mark Mitchell <mark@codesourcery.com> + + PR c++/20679 + * g++.dg/template/overload4.C: New test. + 2005-04-04 Nathan Sidwell <nathan@codesourcery.com> PR c++/20746 diff --git a/gcc/testsuite/g++.dg/template/overload4.C b/gcc/testsuite/g++.dg/template/overload4.C new file mode 100644 index 0000000000000000000000000000000000000000..1a294eb3c054991b5f7e1992381bb562c3e2b612 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/overload4.C @@ -0,0 +1,20 @@ +// PR c++/20679 + +template <class T> +struct foo +{ + struct bar + { + int m; + }; + + void m() const {} + void m() {} + + bool n() const { return b->m < 42; } + + bar *b; +}; + + +