cp-tree.h (enum_name_string): Remove prototype.
authorNathan Sidwell <nathan@codesourcery.com>
Fri, 18 Aug 2000 09:15:51 +0000 (09:15 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Fri, 18 Aug 2000 09:15:51 +0000 (09:15 +0000)
* cp-tree.h (enum_name_string): Remove prototype.
(report_case_error): Remove prototype.
* cp/typeck2.c (enum_name_string): Remove.
(report_case_error): Remove.
* error.c (dump_expr): Deal with enum values directly.
Correctly negate integer constant.

From-SVN: r35774

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/error.c
gcc/cp/typeck2.c

index e2248aa7b250b71ef4802d6862da8add14d090f4..0a2fb19c356fe49462d503d269f05d2b93b7f132 100644 (file)
@@ -1,3 +1,12 @@
+2000-08-18  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * cp-tree.h (enum_name_string): Remove prototype.
+       (report_case_error): Remove prototype.
+       * cp/typeck2.c (enum_name_string): Remove.
+       (report_case_error): Remove.
+       * error.c (dump_expr): Deal with enum values directly.
+       Correctly negate integer constant.
+
 2000-08-17  Nathan Sidwell  <nathan@codesourcery.com>
 
        * inc/cxxabi.h (__cxa_vec_new2, __cxa_vec_new3): Declare.
index 1f21995c5dfa88eee05eca281397f1ee51f73b1f..5dba2e394724a56b944b3b873355629ec06cfac9 100644 (file)
@@ -4643,8 +4643,6 @@ extern tree build_scoped_ref                      PARAMS ((tree, tree));
 extern tree build_x_arrow                      PARAMS ((tree));
 extern tree build_m_component_ref              PARAMS ((tree, tree));
 extern tree build_functional_cast              PARAMS ((tree, tree));
-extern char *enum_name_string                  PARAMS ((tree, tree));
-extern void report_case_error                  PARAMS ((int, tree, tree, tree));
 extern void check_for_new_type                 PARAMS ((const char *, flagged_type_tree));
 extern tree add_exception_specifier             PARAMS ((tree, tree, int));
 
index fb8ff389eec67be4268b28435188781a3e9b6772..b8063b34d11813d60adb763cd438bbe0b608115e 100644 (file)
@@ -1469,8 +1469,23 @@ dump_expr (t, flags)
        /* If it's an enum, output its tag, rather than its value.  */
        if (TREE_CODE (type) == ENUMERAL_TYPE)
          {
-           const char *p = enum_name_string (t, type);
-           OB_PUTCP (p);
+           tree values = TYPE_VALUES (type);
+           
+           for (; values;
+                values = TREE_CHAIN (values))
+             if (tree_int_cst_equal (TREE_VALUE (values), t))
+               break;
+           
+           if (values)
+             OB_PUTID (TREE_PURPOSE (values));
+           else
+             {
+                /* Value must have been cast.  */
+                OB_PUTC ('(');
+                dump_type (type, flags);
+                OB_PUTC (')');
+                goto do_int;
+             }
          }
        else if (type == boolean_type_node)
          {
@@ -1485,30 +1500,35 @@ dump_expr (t, flags)
            dump_char (tree_low_cst (t, 0));
            OB_PUTC ('\'');
          }
-       else if ((unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (t)
-                != (TREE_INT_CST_LOW (t) >> (HOST_BITS_PER_WIDE_INT - 1)))
+       else
          {
-           tree val = t;
-
-           if (tree_int_cst_sgn (val) < 0)
+           do_int:
+           if ((unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (t)
+               != (TREE_INT_CST_LOW (t) >> (HOST_BITS_PER_WIDE_INT - 1)))
              {
-               OB_PUTC ('-');
-               val = build_int_2 (~TREE_INT_CST_LOW (val),
-                                  -TREE_INT_CST_HIGH (val));
+               tree val = t;
+
+               if (tree_int_cst_sgn (val) < 0)
+                 {
+                   OB_PUTC ('-');
+                   val = build_int_2 (-TREE_INT_CST_LOW (val),
+                                      ~TREE_INT_CST_HIGH (val)
+                                      + !TREE_INT_CST_LOW (val));
+                 }
+               /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
+                  systems?  */
+               {
+                 static char format[10]; /* "%x%09999x\0" */
+                 if (!format[0])
+                   sprintf (format, "%%x%%0%dx", HOST_BITS_PER_INT / 4);
+                 sprintf (digit_buffer, format, TREE_INT_CST_HIGH (val),
+                          TREE_INT_CST_LOW (val));
+                 OB_PUTCP (digit_buffer);
+               }
              }
-           /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
-              systems?  */
-           {
-             static char format[10]; /* "%x%09999x\0" */
-             if (!format[0])
-               sprintf (format, "%%x%%0%dx", HOST_BITS_PER_INT / 4);
-             sprintf (digit_buffer, format, TREE_INT_CST_HIGH (val),
-                      TREE_INT_CST_LOW (val));
-             OB_PUTCP (digit_buffer);
-           }
+           else
+             OB_PUTI (TREE_INT_CST_LOW (t));
          }
-       else
-         OB_PUTI (TREE_INT_CST_LOW (t));
       }
       break;
 
index b2e6221c8341e114b5f3077efd3facaffa265bc1..fecd227f174f86d389b9550b5d5c88ad1b378e27 100644 (file)
@@ -1209,138 +1209,6 @@ build_functional_cast (exp, parms)
   return build_cplus_new (type, exp);
 }
 \f
-/* Return the character string for the name that encodes the
-   enumeral value VALUE in the domain TYPE.  */
-
-char *
-enum_name_string (value, type)
-     tree value;
-     tree type;
-{
-  register tree values = TYPE_VALUES (type);
-
-  my_friendly_assert (TREE_CODE (type) == ENUMERAL_TYPE, 324);
-
-  while (values && ! tree_int_cst_equal (TREE_VALUE (values), value))
-    values = TREE_CHAIN (values);
-
-  if (values == NULL_TREE)
-    {
-      char *buf = (char *) oballoc (16 + TYPE_NAME_LENGTH (type));
-
-      /* Value must have been cast.  */
-      sprintf (buf, "(enum %s)%ld",
-              TYPE_NAME_STRING (type), (long) TREE_INT_CST_LOW (value));
-      return buf;
-    }
-  return IDENTIFIER_POINTER (TREE_PURPOSE (values));
-}
-
-#if 0
-/* Print out a language-specific error message for
-   (Pascal) case or (C) switch statements.
-   CODE tells what sort of message to print. 
-   TYPE is the type of the switch index expression.
-   NEW is the new value that we were trying to add.
-   OLD is the old value that stopped us from adding it.  */
-
-void
-report_case_error (code, type, new_value, old_value)
-     int code;
-     tree type;
-     tree new_value, old_value;
-{
-  if (code == 1)
-    {
-      if (new_value)
-       error ("case label not within a switch statement");
-      else
-       error ("default label not within a switch statement");
-    }
-  else if (code == 2)
-    {
-      if (new_value == 0)
-       {
-         error ("multiple default labels in one switch");
-         return;
-       }
-      if (TREE_CODE (new_value) == RANGE_EXPR)
-       if (TREE_CODE (old_value) == RANGE_EXPR)
-         {
-           char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type)));
-           if (TREE_CODE (type) == ENUMERAL_TYPE)
-             sprintf (buf, "overlapping ranges [%s..%s], [%s..%s] in case expression",
-                      enum_name_string (TREE_OPERAND (new_value, 0), type),
-                      enum_name_string (TREE_OPERAND (new_value, 1), type),
-                      enum_name_string (TREE_OPERAND (old_value, 0), type),
-                      enum_name_string (TREE_OPERAND (old_value, 1), type));
-           else
-             sprintf (buf, "overlapping ranges [%d..%d], [%d..%d] in case expression",
-                      TREE_INT_CST_LOW (TREE_OPERAND (new_value, 0)),
-                      TREE_INT_CST_LOW (TREE_OPERAND (new_value, 1)),
-                      TREE_INT_CST_LOW (TREE_OPERAND (old_value, 0)),
-                      TREE_INT_CST_LOW (TREE_OPERAND (old_value, 1)));
-           error (buf);
-         }
-       else
-         {
-           char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type)));
-           if (TREE_CODE (type) == ENUMERAL_TYPE)
-             sprintf (buf, "range [%s..%s] includes element `%s' in case expression",
-                      enum_name_string (TREE_OPERAND (new_value, 0), type),
-                      enum_name_string (TREE_OPERAND (new_value, 1), type),
-                      enum_name_string (old_value, type));
-           else
-             sprintf (buf, "range [%d..%d] includes (%d) in case expression",
-                      TREE_INT_CST_LOW (TREE_OPERAND (new_value, 0)),
-                      TREE_INT_CST_LOW (TREE_OPERAND (new_value, 1)),
-                      TREE_INT_CST_LOW (old_value));
-           error (buf);
-         }
-      else if (TREE_CODE (old_value) == RANGE_EXPR)
-       {
-         char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type)));
-         if (TREE_CODE (type) == ENUMERAL_TYPE)
-           sprintf (buf, "range [%s..%s] includes element `%s' in case expression",
-                    enum_name_string (TREE_OPERAND (old_value, 0), type),
-                    enum_name_string (TREE_OPERAND (old_value, 1), type),
-                    enum_name_string (new_value, type));
-         else
-           sprintf (buf, "range [%d..%d] includes (%d) in case expression",
-                    TREE_INT_CST_LOW (TREE_OPERAND (old_value, 0)),
-                    TREE_INT_CST_LOW (TREE_OPERAND (old_value, 1)),
-                    TREE_INT_CST_LOW (new_value));
-         error (buf);
-       }
-      else
-       {
-         if (TREE_CODE (type) == ENUMERAL_TYPE)
-           error ("duplicate label `%s' in switch statement",
-                  enum_name_string (new_value, type));
-         else
-           error ("duplicate label (%d) in switch statement",
-                  TREE_INT_CST_LOW (new_value));
-       }
-    }
-  else if (code == 3)
-    {
-      if (TREE_CODE (type) == ENUMERAL_TYPE)
-       warning ("case value out of range for enum %s",
-                TYPE_NAME_STRING (type));
-      else
-       warning ("case value out of range");
-    }
-  else if (code == 4)
-    {
-      if (TREE_CODE (type) == ENUMERAL_TYPE)
-       error ("range values `%s' and `%s' reversed",
-              enum_name_string (new_value, type),
-              enum_name_string (old_value, type));
-      else
-       error ("range values reversed");
-    }
-}
-#endif
 
 /* Complain about defining new types in inappropriate places.  We give an
    exception for C-style casts, to accommodate GNU C stylings.  */