cvt.c (ocp_convert): Obtain the constant values from constant decls even if...
authorMark Mitchell <mmitchell@usa.net>
Tue, 3 Feb 1998 23:55:27 +0000 (23:55 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 3 Feb 1998 23:55:27 +0000 (18:55 -0500)
* cvt.c (ocp_convert): Obtain the constant values from constant
decls even if the destination type is the same as the type of the
decl.
* decl2.c (finish_file): Make sure that static inlines with
definitions are not marked DECL_EXTERNAL before returning.

From-SVN: r17653

gcc/cp/ChangeLog
gcc/cp/cvt.c
gcc/cp/decl2.c

index c9b9263..d7086dc 100644 (file)
@@ -1,3 +1,12 @@
+Tue Feb  3 23:50:52 1998  Mark Mitchell  <mmitchell@usa.net>
+
+       * cvt.c (ocp_convert): Obtain the constant values from constant
+       decls even if the destination type is the same as the type of the
+       decl. 
+
+       * decl2.c (finish_file): Make sure that static inlines with
+       definitions are not marked DECL_EXTERNAL before returning.
+
 Tue Feb  3 22:43:42 1998  Jason Merrill  <jason@yorick.cygnus.com>
 
        * decl.c: Lose arg_looking_for_template.
index c5a5f93..0fdce85 100644 (file)
@@ -982,6 +982,9 @@ ocp_convert (type, expr, convtype, flags)
       || TREE_TYPE (e) == error_mark_node)
     return error_mark_node;
 
+  if (TREE_READONLY_DECL_P (e))
+    e = decl_constant_value (e);
+
   if (IS_AGGR_TYPE (type) && (convtype & CONV_FORCE_TEMP))
     /* We need a new temporary; don't take this shortcut.  */;
   else if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (e)))
@@ -1015,9 +1018,6 @@ ocp_convert (type, expr, convtype, flags)
   if (TREE_CODE (e) == OFFSET_REF)
     e = resolve_offset_ref (e);
 
-  if (TREE_READONLY_DECL_P (e))
-    e = decl_constant_value (e);
-
   if (INTEGRAL_CODE_P (code))
     {
       tree intype = TREE_TYPE (e);
@@ -1186,7 +1186,7 @@ ocp_convert (type, expr, convtype, flags)
     }
 
   /* If TYPE or TREE_TYPE (E) is not on the permanent_obstack,
-     then the it won't be hashed and hence compare as not equal,
+     then it won't be hashed and hence compare as not equal,
      even when it is.  */
   if (code == ARRAY_TYPE
       && TREE_TYPE (TREE_TYPE (e)) == TREE_TYPE (type)
index a7eb19b..c9e11f4 100644 (file)
@@ -3286,6 +3286,25 @@ finish_file ()
              p = &TREE_CHAIN (*p);
          }
       }
+
+    /* It's possible that some of the remaining inlines will still be
+       needed.  For example, a static inline whose address is used in
+       the initializer for a file-scope static variable will be
+       needed.  Code in compile_file will handle this, but we mustn't
+       pretend that there are no definitions for the inlines, or it
+       won't be able to.
+
+       FIXME: This won't catch member functions.  We should really
+       unify this stuff with the compile_file stuff.  */
+    for (vars = saved_inlines; vars != NULL_TREE; vars = TREE_CHAIN (vars))
+      {
+       tree decl = TREE_VALUE (vars);
+
+       if (DECL_NOT_REALLY_EXTERN (decl)
+           && !DECL_COMDAT (decl)
+           && DECL_INITIAL (decl) != NULL_TREE)
+         DECL_EXTERNAL (decl) = 0;
+      }
   }
 
   /* Now delete from the chain of variables all virtual function tables.