]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
parse.y (condition): Convert VAR_DECL from reference to indirect reference.
authorJason Merrill <jason@gcc.gnu.org>
Sun, 25 Oct 1998 17:35:47 +0000 (12:35 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 25 Oct 1998 17:35:47 +0000 (12:35 -0500)
* parse.y (condition): Convert VAR_DECL from reference to indirect
reference.
* decl2.c (validate_nonmember_using_decl): Fix using-directives of
std if std is ignored.
* method.c (build_decl_overload_real): Clear
numeric_output_need_bar after __.
* decl.c (cp_finish_decl): Make statics in extern inlines and
templates common, if possible and the target doesn't support weak
symbols.
* decl2.c (merge_functions): Remove duplicates.
* typeck.c (build_conditional_expr): Only fold if ifexp is an
INTEGER_CST.

From-SVN: r23322

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/method.c
gcc/cp/parse.c
gcc/cp/parse.y
gcc/cp/typeck.c

index 26dda44494689bc3747efd199b6ff5e8191e8b52..8b0faa7ad8c51327cade273bcfee2ed8ad80a068 100644 (file)
@@ -1,7 +1,17 @@
+1998-10-23  Martin von Löwis  <loewis@informatik.hu-berlin.de>
+
+       * parse.y (condition): Convert VAR_DECL from reference to indirect
+       reference.
+
 1998-10-18  Jason Merrill  <jason@yorick.cygnus.com>
 
        * method.c (hack_identifier): Just return a member function.
 
+1998-10-18  Martin von Löwis  <loewis@informatik.hu-berlin.de>
+
+       * decl2.c (validate_nonmember_using_decl): Fix using-directives of
+       std if std is ignored.
+
 1998-10-14  Jason Merrill  <jason@yorick.cygnus.com>
 
        * spew.c (yylex): Clear looking_for_typename if we got
        * tinfo.cc: Add #pragma implementation.
        (operator==): Move from inc/typeinfo and tinfo2.cc.
 
+1998-10-05  Martin von Löwis  <loewis@informatik.hu-berlin.de>
+
+       * method.c (build_decl_overload_real): Clear
+       numeric_output_need_bar after __.
+
+1998-10-04  Jason Merrill  <jason@yorick.cygnus.com>
+
+       * decl.c (cp_finish_decl): Make statics in extern inlines and
+       templates common, if possible and the target doesn't support weak
+       symbols.
+
+1998-10-03  Jason Merrill  <jason@yorick.cygnus.com>
+
+       * decl2.c (merge_functions): Remove duplicates.
+
+       * typeck.c (build_conditional_expr): Only fold if ifexp is an
+       INTEGER_CST.
+
 Fri Oct  2 02:07:26 1998  Mumit Khan  <khan@xraylith.wisc.edu>
 
        * parse.y (nomods_initdcl0): Set up the parser stack correctly.
index 496158d942b43c5787f630be1d6abab458e07cb2..02330ee5132f8a3394f6f58851cd8ad13cbc6f3e 100644 (file)
@@ -7191,20 +7191,52 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags)
       if (was_temp)
        end_temporary_allocation ();
 
-      /* Extern inline function static data has external linkage.
-         Instead of trying to deal with that, we disable inlining of
-         such functions.  The ASM_WRITTEN check is to avoid hitting this
-         for __FUNCTION__.  */
+      /* Static data in a function with comdat linkage also has comdat
+         linkage.  */
       if (TREE_CODE (decl) == VAR_DECL
          && TREE_STATIC (decl)
+         /* Don't mess with __FUNCTION__.  */
          && ! TREE_ASM_WRITTEN (decl)
          && current_function_decl
          && DECL_CONTEXT (decl) == current_function_decl
-         && DECL_THIS_INLINE (current_function_decl)
+         && (DECL_THIS_INLINE (current_function_decl)
+             || DECL_TEMPLATE_INSTANTIATION (current_function_decl))
          && TREE_PUBLIC (current_function_decl))
        {
+         /* Rather than try to get this right with inlining, we suppress
+            inlining of such functions.  */
          current_function_cannot_inline
            = "function with static variable cannot be inline";
+
+         /* If flag_weak, we don't need to mess with this, as we can just
+            make the function weak, and let it refer to its unique local
+            copy.  This works because we don't allow the function to be
+            inlined.  */
+         if (! flag_weak)
+           {
+             if (DECL_INTERFACE_KNOWN (current_function_decl))
+               {
+                 TREE_PUBLIC (decl) = 1;
+                 DECL_EXTERNAL (decl) = DECL_EXTERNAL (current_function_decl);
+               }
+             else if (DECL_INITIAL (decl) == NULL_TREE
+                      || DECL_INITIAL (decl) == error_mark_node)
+               {
+                 TREE_PUBLIC (decl) = 1;
+                 DECL_COMMON (decl) = 1;
+               }
+             /* else we lose. We can only do this if we can use common,
+                 which we can't if it has been initialized.  */
+
+             if (TREE_PUBLIC (decl))
+               DECL_ASSEMBLER_NAME (decl)
+                 = build_static_name (current_function_decl, DECL_NAME (decl));
+             else if (! DECL_ARTIFICIAL (decl))
+               {
+                 cp_warning_at ("sorry: semantics of inline function static data `%#D' are wrong (you'll wind up with multiple copies)", decl);
+                 cp_warning_at ("  you can work around this by removing the initializer"), decl;
+               }
+           }
        }
 
       else if (TREE_CODE (decl) == VAR_DECL
index cc2c3332c5146513eecf501ac01c396245b7ac88..2df2ac0d5c114eb7c9727c1d55c1f1f83974aed0 100644 (file)
@@ -3910,22 +3910,22 @@ add_using_namespace (user, used, indirect)
     add_using_namespace (TREE_PURPOSE (t), used, 1);
 }
 
-/* Combines two sets of overloaded functions into an OVERLOAD chain.
-   The first list becomes the tail of the result. */
+/* Combines two sets of overloaded functions into an OVERLOAD chain, removing
+   duplicates.  The first list becomes the tail of the result.
+
+   The algorithm is O(n^2).  */
 
 static tree
 merge_functions (s1, s2)
      tree s1;
      tree s2;
 {
-  if (TREE_CODE (s2) == OVERLOAD)
-    while (s2)
-      {
-       s1 = build_overload (OVL_FUNCTION (s2), s1);
-       s2 = OVL_CHAIN (s2);
-      }
-  else
-    s1 = build_overload (s2, s1);
+  for (; s2; s2 = OVL_NEXT (s2))
+    {
+      tree fn = OVL_CURRENT (s2);
+      if (! ovl_member (fn, s1))
+       s1 = build_overload (fn, s1);
+    }
   return s1;
 }
 
@@ -4458,8 +4458,11 @@ validate_nonmember_using_decl (decl, scope, name)
 {
   if (TREE_CODE (decl) == SCOPE_REF
       && TREE_OPERAND (decl, 0) == std_node)
-    return NULL_TREE;
-  if (TREE_CODE (decl) == SCOPE_REF)
+    {
+      *scope = global_namespace;
+      *name = TREE_OPERAND (decl, 1);
+    }
+  else if (TREE_CODE (decl) == SCOPE_REF)
     {
       *scope = TREE_OPERAND (decl, 0);
       *name = TREE_OPERAND (decl, 1);
index f6af6e98ed3a24d398371ca45de320a8fe95045c..29b31c426468d5f3f8d3d5d8cf350147eb939373 100644 (file)
@@ -1533,6 +1533,7 @@ build_decl_overload_real (dname, parms, ret_type, tparms, targs,
      and figure out its name without any extra encoding.  */
 
   OB_PUTC2 ('_', '_');
+  numeric_output_need_bar = 0;
 
   if (tparms)
     {
index f0edf7c233264f716374b13e608303423a17ace1..da7e6b9f363963c28f191442be9b80c825e4d95b 100644 (file)
@@ -4751,7 +4751,7 @@ case 187:
 { 
                  cp_finish_decl (yyvsp[-1].ttype, yyvsp[0].ttype, yyvsp[-3].ttype, 1, LOOKUP_ONLYCONVERTING);
                  resume_momentary (yyvsp[-2].itype);
-                 yyval.ttype = yyvsp[-1].ttype
+                 yyval.ttype = convert_from_reference (yyvsp[-1].ttype)
                  if (TREE_CODE (TREE_TYPE (yyval.ttype)) == ARRAY_TYPE)
                    cp_error ("definition of array `%#D' in condition", yyval.ttype); 
                ;
index 61a0d8773313547d02f3aac40c0cd902d91ac492..279cec338b8510ecb2bf38902ceb26632187b947 100644 (file)
@@ -991,7 +991,7 @@ condition:
                { 
                  cp_finish_decl ($<ttype>6, $7, $4, 1, LOOKUP_ONLYCONVERTING);
                  resume_momentary ($<itype>5);
-                 $$ = $<ttype>6
+                 $$ = convert_from_reference ($<ttype>6)
                  if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
                    cp_error ("definition of array `%#D' in condition", $$); 
                }
index 197aab7d985adc1fe2b180f740c65dc495125156..4e1d4fd44bf0f51ab583ebea7d734b5ead0184f9 100644 (file)
@@ -5262,7 +5262,7 @@ build_conditional_expr (ifexp, op1, op2)
     op2 = convert_for_initialization
       (NULL_TREE, result_type, op2, LOOKUP_NORMAL, "converting", NULL_TREE, 0);
 
-  if (TREE_CONSTANT (ifexp))
+  if (TREE_CODE (ifexp) == INTEGER_CST)
     return integer_zerop (ifexp) ? op2 : op1;
 
   return convert_from_reference