From: Mark Mitchell Date: Mon, 4 Apr 2005 19:11:07 +0000 (+0000) Subject: re PR c++/20679 (Parse error when accessing attributes of an inner class. Enclosing... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d58a2b8348d629d857d93297ba944e903d2f7115;p=gcc.git re PR c++/20679 (Parse error when accessing attributes of an inner class. Enclosing class is template and have methods with the same name.) PR c++/20679 * parser.c (cp_parser_template_name): Fix thinko. PR c++/20679 * g++.dg/template/overload4.C: New test. From-SVN: r97569 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f38b03dda30..ac3c3bcdb99 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2005-04-04 Mark Mitchell + + PR c++/20679 + * parser.c (cp_parser_template_name): Fix thinko. + 2005-04-04 Nathan Sidwell PR c++/20746 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index d682f3a38aa..cb1623d681e 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 ddb7ae2d510..cca0e181801 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-04-04 Mark Mitchell + + PR c++/20679 + * g++.dg/template/overload4.C: New test. + 2005-04-04 Nathan Sidwell 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 00000000000..1a294eb3c05 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/overload4.C @@ -0,0 +1,20 @@ +// PR c++/20679 + +template +struct foo +{ + struct bar + { + int m; + }; + + void m() const {} + void m() {} + + bool n() const { return b->m < 42; } + + bar *b; +}; + + +