]> gcc.gnu.org Git - gcc.git/commitdiff
pt.c (check_template_shadow): Don't treat OVERLOADs as _DECL nodes.
authorMark Mitchell <mark@codesourcery.com>
Mon, 5 Apr 1999 01:34:46 +0000 (01:34 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 5 Apr 1999 01:34:46 +0000 (21:34 -0400)
* pt.c (check_template_shadow): Don't treat OVERLOADs as _DECL
nodes.  Tidy.

From-SVN: r26188

gcc/cp/ChangeLog
gcc/cp/pt.c

index 813cc218e614b968e052793a40b7b4cf2049fb33..e341bc2766be76ff1679543f224c794e6f6cd455 100644 (file)
@@ -1,3 +1,8 @@
+1999-04-04  Mark Mitchell  <mark@codesourcery.com>
+
+       * pt.c (check_template_shadow): Don't treat OVERLOADs as _DECL
+       nodes.  Tidy.
+
 1999-04-03  Jason Merrill  <jason@yorick.cygnus.com>
 
        * class.c (maybe_fixup_vptrs, build_class_init_list): Lose.
index 28161b11c31f740c042064ee040d85ab62d8dc04..a4060c0c4b8685877a3b40c6369788373a4f6a50 100644 (file)
@@ -1599,22 +1599,38 @@ check_template_shadow (decl)
 {
   tree olddecl;
 
+  /* If we're not in a template, we can't possibly shadow a template
+     parameter.  */
+  if (!current_template_parms)
+    return;
+
+  /* Figure out what we're shadowing.  */
   if (TREE_CODE (decl) == OVERLOAD)
     decl = OVL_CURRENT (decl);
   olddecl = IDENTIFIER_VALUE (DECL_NAME (decl));
 
-  if (current_template_parms && olddecl)
-    {
-      /* We check for decl != olddecl to avoid bogus errors for using a
-        name inside a class.  We check TPFI to avoid duplicate errors for
-        inline member templates.  */
-      if (decl != olddecl && DECL_TEMPLATE_PARM_P (olddecl)
-         && ! TEMPLATE_PARMS_FOR_INLINE (current_template_parms))
-       {
-         cp_error_at ("declaration of `%#D'", decl);
-         cp_error_at (" shadows template parm `%#D'", olddecl);
-       }
-    }
+  /* If there's no previous binding for this name, we're not shadowing
+     anything, let alone a template parameter.  */
+  if (!olddecl)
+    return;
+
+  /* If we're not shadowing a template parameter, we're done.  Note
+     that OLDDECL might be an OVERLOAD (or perhaps even an
+     ERROR_MARK), so we can't just blithely assume it to be a _DECL
+     node.  */
+  if (TREE_CODE_CLASS (TREE_CODE (olddecl)) != 'd'
+      || !DECL_TEMPLATE_PARM_P (olddecl))
+    return;
+
+  /* We check for decl != olddecl to avoid bogus errors for using a
+     name inside a class.  We check TPFI to avoid duplicate errors for
+     inline member templates.  */
+  if (decl == olddecl 
+      || TEMPLATE_PARMS_FOR_INLINE (current_template_parms))
+    return;
+
+  cp_error_at ("declaration of `%#D'", decl);
+  cp_error_at (" shadows template parm `%#D'", olddecl);
 }
 
 /* Return a new TEMPLATE_PARM_INDEX with the indicated INDEX, LEVEL,
This page took 0.099092 seconds and 5 git commands to generate.