cp-tree.h (grok_enum_decls): Remove type parameter.
authorJason Merrill <jason@gcc.gnu.org>
Wed, 28 Jan 1998 11:43:39 +0000 (06:43 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 28 Jan 1998 11:43:39 +0000 (06:43 -0500)
* cp-tree.h (grok_enum_decls): Remove type parameter.
* decl.c (grok_enum_decls): Likewise.
* decl2.c (grok_x_components): Call grok_enum_decls
unconditionally, since it will do nothing if there is no
current_local_enum.  Use the new calling sequence.
* pt.c (tsubst_enum): Use the new calling sequence for
grok_enum_decls.
* decl.c (start_function): Make member functions of local classes
in extern inline functions have comdat linkage here...
(grokdeclarator): Rather than here.
* pt.c (convert_nontype_argument): Use decl_constant_value.

From-SVN: r17531

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/pt.c

index 355cb249455b59f94a41eb63d8916a8272bf2969..42bc3ea04e29f169b7cee9117f82798cefabe184 100644 (file)
@@ -1,3 +1,21 @@
+Wed Jan 28 11:04:07 1998  Mark Mitchell  <mmitchell@usa.net>
+
+       * cp-tree.h (grok_enum_decls): Remove type parameter.
+       * decl.c (grok_enum_decls): Likewise.
+       * decl2.c (grok_x_components): Call grok_enum_decls
+       unconditionally, since it will do nothing if there is no
+       current_local_enum.  Use the new calling sequence.
+       * pt.c (tsubst_enum): Use the new calling sequence for
+       grok_enum_decls.
+
+       * decl.c (start_function): Make member functions of local classes
+       in extern inline functions have comdat linkage here...
+       (grokdeclarator): Rather than here.
+       
+Wed Jan 28 10:55:47 1998  Jason Merrill  <jason@yorick.cygnus.com>
+
+       * pt.c (convert_nontype_argument): Use decl_constant_value.
+
 Tue Jan 27 16:42:21 1998  Mark Mitchell  <mmitchell@usa.net>
 
        * call.c (add_template_candidate_real): New function.
@@ -13,6 +31,7 @@ Tue Jan 27 16:42:21 1998  Mark Mitchell  <mmitchell@usa.net>
        (check_explicit_specialization): Return a tree, not an int.
        (more_specialized): Take additional argument.
        (get_bindings): Likewise.
+       (TI_PENDING_SPECIALIZATION_FLAG): New macro.
        * cvt.c (perform_qualification_conversions): Use comp_ptr_ttypes.
        (perform_array_to_pointer_conversion): Remove.
        * decl.c (saved_scope): Add processing_specialization,
index 7354ba9cecf5f72579a9b22e97270e1be217c1d6..85225da73931cd94b60af8fdc3f9598282e1d259 100644 (file)
@@ -2099,7 +2099,7 @@ extern void xref_basetypes                        PROTO((tree, tree, tree, tree));
 extern tree start_enum                         PROTO((tree));
 extern tree finish_enum                                PROTO((tree, tree));
 extern tree build_enumerator                   PROTO((tree, tree));
-extern tree grok_enum_decls                    PROTO((tree, tree));
+extern tree grok_enum_decls                    PROTO((tree));
 extern int start_function                      PROTO((tree, tree, tree, int));
 extern void expand_start_early_try_stmts       PROTO((void));
 extern void store_parm_decls                   PROTO((void));
index 700ce08b95e87cf556172114b4e57278af0214da..fdac895ef2d851cccaa14ec752e9364b565a8b07 100644 (file)
@@ -9734,16 +9734,6 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
                               funcdef_flag, template_count);
            if (decl == NULL_TREE)
              return NULL_TREE;
-           if (function_context != NULL_TREE
-               && DECL_THIS_INLINE (function_context)
-               && TREE_PUBLIC (function_context))
-             /* We just declared a member of a local class in an
-                extern inline function.  Give such an entity comdat
-                linkage.  */
-             {
-               comdat_linkage (decl);
-               DECL_INTERFACE_KNOWN (decl) = 1;
-             }
 #if 0
            /* This clobbers the attrs stored in `decl' from `attrlist'.  */
            /* The decl and setting of decl_machine_attr is also turned off.  */
@@ -11395,8 +11385,8 @@ build_enumerator (name, value)
 }
 
 tree
-grok_enum_decls (type, decl)
-     tree type, decl;
+grok_enum_decls (decl)
+     tree decl;
 {
   tree d = current_local_enum;
   
@@ -11405,7 +11395,6 @@ grok_enum_decls (type, decl)
   
   while (1)
     {
-      TREE_TYPE (d) = type;
       if (TREE_CHAIN (d) == NULL_TREE)
        {
          TREE_CHAIN (d) = decl;
@@ -11661,8 +11650,16 @@ start_function (declspecs, declarator, attrs, pre_parsed_p)
 
   if (DECL_INTERFACE_KNOWN (decl1))
     {
+      tree ctx = hack_decl_function_context (decl1);
+
       if (DECL_NOT_REALLY_EXTERN (decl1))
        DECL_EXTERNAL (decl1) = 0;
+
+      if (ctx != NULL_TREE && DECL_THIS_INLINE (ctx) 
+         && TREE_PUBLIC (ctx))
+       /* This is a function in a local class in an extern inline
+          function.  */
+       comdat_linkage (decl1);
     }
   /* If this function belongs to an interface, it is public.
      If it belongs to someone else's interface, it is also external.
index b003b6c2d121cad0d62b4c96cfb52e07a0d05af9..253e8bf598c655bb6e7aa88518026cb4ee552091 100644 (file)
@@ -916,7 +916,7 @@ grok_x_components (specs, components)
                  break;
            }
          else if (TREE_CODE (t) == ENUMERAL_TYPE)
-           x = grok_enum_decls (t, NULL_TREE);
+           x = grok_enum_decls (NULL_TREE);
          else
            x = NULL_TREE;
          return x;
@@ -929,13 +929,12 @@ grok_x_components (specs, components)
        }
     }
   else
-    {
-      t = TREE_TYPE (components);
-      if (TREE_CODE (t) == ENUMERAL_TYPE && TREE_NONLOCAL_FLAG (t))
-       return grok_enum_decls (t, components);
-      else
-       return components;
-    }
+    /* There may or may not be any enum decls to grok, but
+       grok_enum_decls will just return components, if there aren't
+       any.  We used to try to figure out whether or not there were
+       any enum decls based on the type of components, but that's too
+       hard; it might be something like `enum { a } *p;'.  */
+    return grok_enum_decls (components);
 }
 
 /* Classes overload their constituent function names automatically.
index 8782406c41c6b7b6fb48fe175a976e4b88fbfd5f..a4c51dc7c36afc0dc105b130a3b63d7888f5a300 100644 (file)
@@ -1401,7 +1401,7 @@ convert_nontype_argument (type, expr)
      
      --the name of an object or function with external linkage,
      including function templates and function template-ids but
-     excluding non- tatic class members, expressed as id-expression;
+     excluding non-static class members, expressed as id-expression;
      or
      
      --the address of an object or function with external linkage,
@@ -1412,13 +1412,16 @@ convert_nontype_argument (type, expr)
      
      --a pointer to member expressed as described in _expr.unary.op_.  */
 
+  /* An integral constant-expression can include const variables
+     or enumerators.  */
+  if (INTEGRAL_TYPE_P (expr_type) && TREE_READONLY_DECL_P (expr))
+    expr = decl_constant_value (expr);
+
   if (INTEGRAL_TYPE_P (expr_type) 
       || TYPE_PTRMEM_P (expr_type) 
       || TYPE_PTRMEMFUNC_P (expr_type))
     {
-      if (!TREE_CONSTANT (expr) 
-         /* FIXME: Should this case be handled by fold()?  Why not?  */
-         && !(TREE_CODE (expr) == VAR_DECL && TREE_READONLY (expr)))
+      if (! TREE_CONSTANT (expr))
        {
          cp_error ("non-constant `%E' cannot be used as template argument",
                    expr);
@@ -5874,7 +5877,7 @@ tsubst_enum (tag, args, nargs, field_chain)
   finish_enum (newtag, values);
 
   if (NULL != field_chain)
-    *field_chain = grok_enum_decls (newtag, NULL_TREE);
+    *field_chain = grok_enum_decls (NULL_TREE);
 
   current_local_enum = prev_local_enum;