cp-tree.h: Declare.
authorBenjamin Kosnik <bkoz@gcc.gnu.org>
Mon, 24 Aug 1998 11:57:04 +0000 (11:57 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Mon, 24 Aug 1998 11:57:04 +0000 (11:57 +0000)
h
1998-08-24  Benjamin Kosnik  <bkoz@cygnus.com>
* cp-tree.h: Declare.
* pt.c (decl_template_parm_p): New function.
* decl.c (pushdecl): Check decls for redeclaring template parms.
(xref_tag): Make redeclaration an error, print decl.
* decl2.c (grokfield): Check field_decls for redeclaration as well.

From-SVN: r21942

gcc/cp/pt.c

index 79a00fad65c98dc8b9582f76f1c271285f6ca081..e76c509d04b3acdbc714e0283ba7f0f873f3e37f 100644 (file)
@@ -1451,7 +1451,27 @@ int comp_template_parms (parms1, parms2)
   return 1;
 }
 
-/* Return a new TEMPLATE_PARM_INDEX with the indicated INDEX, LEVEL,
+
+/* Returns 1 iff old_id is a template parameter. OLD_DECL is the decl
+   from IDENTIFIER_LOCAL_VALUE (new identifier). */
+
+int decl_template_parm_p (old_decl)
+     tree old_decl;
+{
+  if (TREE_CODE_CLASS (TREE_CODE (old_decl)) == 'd'
+      /* For template type parameters. */
+      && ((TREE_TYPE (old_decl)
+          && TREE_CODE (TREE_TYPE (old_decl)) == TEMPLATE_TYPE_PARM)
+         /* For non-type template parameters. */
+         || (DECL_INITIAL (old_decl) 
+             && TREE_CODE (DECL_INITIAL (old_decl)) == TEMPLATE_PARM_INDEX)))
+    return 1;
+  else
+    return 0;
+}
+
+
+ /* Return a new TEMPLATE_PARM_INDEX with the indicated INDEX, LEVEL,
    ORIG_LEVEL, DECL, and TYPE.  */
 
 static tree