]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cp-tree.h (constructor_name_p): Declare it.
authorMark Mitchell <mark@codesourcery.com>
Tue, 9 Jul 2002 23:31:28 +0000 (23:31 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 9 Jul 2002 23:31:28 +0000 (23:31 +0000)
* cp-tree.h (constructor_name_p): Declare it.
(check_template_template_default_arg): Likewise.
* class.c (handle_using_decl): Use constructor_name_p.
* decl.c (grokdeclarator): Likewise.
* decl2.c (constructor_name_p): Define it.
* init.c (build_member_call): Use constructor_name_p.
* parse.y (template_parm): Use check_template_template_default_arg.
* pt.c (check_explicit_specialization): Use constructor_name_p.
* semantics.c (check_template_template_default_arg): New function.

From-SVN: r55350

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/init.c
gcc/cp/parse.y
gcc/cp/pt.c
gcc/cp/semantics.c

index d4873493de7bcbff1f94b10d5ccdba4f953c20b4..465716da0692652dc2b3e1e707c2a87b0cf2e0bc 100644 (file)
@@ -1,3 +1,15 @@
+2002-07-09  Mark Mitchell  <mark@codesourcery.com>
+
+       * cp-tree.h (constructor_name_p): Declare it.
+       (check_template_template_default_arg): Likewise.
+       * class.c (handle_using_decl): Use constructor_name_p.
+       * decl.c (grokdeclarator): Likewise.
+       * decl2.c (constructor_name_p): Define it.
+       * init.c (build_member_call): Use constructor_name_p.
+       * parse.y (template_parm): Use check_template_template_default_arg.
+       * pt.c (check_explicit_specialization): Use constructor_name_p.
+       * semantics.c (check_template_template_default_arg): New function.
+       
 2002-07-08  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        * pt.c (can_complete_type_without_circularity): Add static to
index aa3caa13b24e54a6c327639a36a994d61c924890..f2544bd1f521b08448fc75d5918318359442838a 100644 (file)
@@ -1212,14 +1212,12 @@ handle_using_decl (using_decl, t)
   if (! binfo)
     return;
   
-  if (name == constructor_name (ctype)
-      || name == constructor_name_full (ctype))
+  if (constructor_name_p (name, ctype))
     {
       cp_error_at ("`%D' names constructor", using_decl);
       return;
     }
-  if (name == constructor_name (t)
-      || name == constructor_name_full (t))
+  if (constructor_name_p (name, t))
     {
       cp_error_at ("`%D' invalid in `%T'", using_decl, t);
       return;
index d92597ecbb1feca1ee93aa83dee2ef519e99dd14..6b7522fbe9d007cb4e6c211d50b0b86dbf8320e2 100644 (file)
@@ -3926,6 +3926,7 @@ extern tree grokoptypename                        PARAMS ((tree, tree));
 extern void cplus_decl_attributes              PARAMS ((tree *, tree, int));
 extern tree constructor_name_full              PARAMS ((tree));
 extern tree constructor_name                   PARAMS ((tree));
+extern bool constructor_name_p                  (tree, tree);
 extern void defer_fn                           PARAMS ((tree));
 extern void finish_anon_union                  PARAMS ((tree));
 extern tree finish_table                       PARAMS ((tree, tree, tree, int));
@@ -4318,7 +4319,7 @@ extern void setup_vtbl_ptr                        PARAMS ((tree, tree));
 extern void clear_out_block                     PARAMS ((void));
 extern tree begin_global_stmt_expr              PARAMS ((void));
 extern tree finish_global_stmt_expr             PARAMS ((tree));
-
+extern tree check_template_template_default_arg (tree);
 
 /* in spew.c */
 extern void init_spew                          PARAMS ((void));
index a7d203ccee0a6180c1cdf33c9841a33e6ff575cf..b5d18b4c67cf3ceb044a4855c07cc9f6592bc44b 100644 (file)
@@ -9848,10 +9848,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
            if (ctype
                && TREE_OPERAND (decl, 0)
                && (TREE_CODE (TREE_OPERAND (decl, 0)) == TYPE_DECL
-                   && ((DECL_NAME (TREE_OPERAND (decl, 0))
-                        == constructor_name_full (ctype))
-                       || (DECL_NAME (TREE_OPERAND (decl, 0))
-                           == constructor_name (ctype)))))
+                   && constructor_name_p (DECL_NAME (TREE_OPERAND (decl, 0)),
+                                          ctype)))
              TREE_OPERAND (decl, 0) = constructor_name (ctype);
            next = &TREE_OPERAND (decl, 0);
            decl = *next;
@@ -9958,10 +9956,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
                }
 
              if (ctype && TREE_CODE (TREE_OPERAND (decl, 1)) == TYPE_DECL
-                 && ((DECL_NAME (TREE_OPERAND (decl, 1))
-                      == constructor_name_full (ctype))
-                     || (DECL_NAME (TREE_OPERAND (decl, 1))
-                         == constructor_name (ctype))))
+                 && constructor_name_p (DECL_NAME (TREE_OPERAND (decl, 1)),
+                                        ctype))
                TREE_OPERAND (decl, 1) = constructor_name (ctype);
              next = &TREE_OPERAND (decl, 1);
              decl = *next;
@@ -9975,8 +9971,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
                    }
                  else if (TREE_CODE (decl) == BIT_NOT_EXPR
                           && TREE_CODE (TREE_OPERAND (decl, 0)) == IDENTIFIER_NODE
-                          && (constructor_name (ctype) == TREE_OPERAND (decl, 0)
-                              || constructor_name_full (ctype) == TREE_OPERAND (decl, 0)))
+                          && constructor_name_p (TREE_OPERAND (decl, 0),
+                                                 ctype))
                    {
                      sfk = sfk_destructor;
                      ctor_return_type = ctype;
index 7099fc25d9567989ba5b35b32d78953688bfbf3b..4a12914695d2cf4a19c2348c36f1d5630640d86c 100644 (file)
@@ -1810,6 +1810,16 @@ constructor_name (thing)
     return thing;
   return t;
 }
+
+/* Returns TRUE if NAME is the name for the constructor for TYPE.  */
+
+bool
+constructor_name_p (tree name, tree type)
+{
+  return (name == constructor_name (type)
+         || name == constructor_name_full (type));
+}
+
 \f
 /* Defer the compilation of the FN until the end of compilation.  */
 
index 7f23699db41301a5785adc811e69cb80163f81cd..1fa75b2521ec1957846a33c8d059e7aec218efd3 100644 (file)
@@ -1522,8 +1522,7 @@ build_member_call (type, name, parmlist)
        return error_mark_node;
     }
 
-  if (method_name == constructor_name (type)
-      || method_name == constructor_name_full (type))
+  if (constructor_name_p (method_name, type))
     return build_functional_cast (type, parmlist);
   if (lookup_fnfields (basetype_path, method_name, 0))
     return build_method_call (decl, 
index 73eec6a45c26abd72f2712f6c454e0b5d0a63904..e41ffc01001895622ec7fb48af6f702ab57e6b32 100644 (file)
@@ -710,14 +710,7 @@ template_parm:
                { $$ = build_tree_list (NULL_TREE, $1); }
        | template_template_parm '=' template_arg
                {
-                 if (TREE_CODE ($3) != TEMPLATE_DECL
-                     && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
-                     && TREE_CODE ($3) != TYPE_DECL
-                     && TREE_CODE ($3) != UNBOUND_CLASS_TEMPLATE)
-                   {
-                     error ("invalid default template argument");
-                     $3 = error_mark_node;
-                   }
+                 $3 = check_template_template_default_arg ($3);
                  $$ = build_tree_list ($3, $1);
                }
        ;
index 358c129b255640f22407b7fb5374a45c7d00a052..c6d41f4ec2604567f6c5ebbfbf08e6c10425e80c 100644 (file)
@@ -1529,8 +1529,7 @@ check_explicit_specialization (declarator, decl, template_count, flags)
          tree fns = NULL_TREE;
          int idx;
 
-         if (name == constructor_name (ctype) 
-             || name == constructor_name_full (ctype))
+         if (constructor_name_p (name, ctype))
            {
              int is_constructor = DECL_CONSTRUCTOR_P (decl);
              
index 576d931b171c8f9d799f356eee4d019793d7ad60..8766d6fa731353ee6a98e5f77eb7fe6e9c2e21cc 100644 (file)
@@ -1625,6 +1625,25 @@ finish_template_template_parm (aggr, identifier)
   return finish_template_type_parm (aggr, tmpl);
 }
 
+/* ARGUMENT is the default-argument value for a template template
+   parameter.  If ARGUMENT is invalid, issue error messages and return
+   the ERROR_MARK_NODE.  Otherwise, ARGUMENT itself is returned.  */
+
+tree
+check_template_template_default_arg (tree argument)
+{
+  if (TREE_CODE (argument) != TEMPLATE_DECL
+      && TREE_CODE (argument) != TEMPLATE_TEMPLATE_PARM
+      && TREE_CODE (argument) != TYPE_DECL
+      && TREE_CODE (argument) != UNBOUND_CLASS_TEMPLATE)
+    {
+      error ("invalid default template argument");
+      return error_mark_node;
+    }
+
+  return argument;
+}
+
 /* Finish a parameter list, indicated by PARMS.  If ELLIPSIS is
    non-zero, the parameter list was terminated by a `...'.  */