OSDN Git Service

PR c++/20679
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 4 Apr 2005 19:11:07 +0000 (19:11 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 4 Apr 2005 19:11:07 +0000 (19:11 +0000)
* parser.c (cp_parser_template_name): Fix thinko.

PR c++/20679
* g++.dg/template/overload4.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@97569 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/overload4.C [new file with mode: 0644]

index f38b03d..ac3c3bc 100644 (file)
@@ -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
index d682f3a..cb1623d 100644 (file)
@@ -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;
        }
index ddb7ae2..cca0e18 100644 (file)
@@ -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 (file)
index 0000000..1a294eb
--- /dev/null
@@ -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;
+};
+
+
+