* c-ada-spec.c (ADA_HOST_WIDE_INT_PRINT_DOUBLE_HEX): Define.
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 16 Oct 2012 07:13:37 +0000 (07:13 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 16 Oct 2012 07:13:37 +0000 (07:13 +0000)
(dump_generic_ada_node) <INTEGER_CST>: Deal with sizetype specially.
Remove POINTER_TYPE handling, add large unsigned handling and use
ADA_HOST_WIDE_INT_PRINT_DOUBLE_HEX for big numbers.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@192489 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/c-family/ChangeLog
gcc/c-family/c-ada-spec.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/dump-ada-spec-2.C [new file with mode: 0644]

index bb82be4..8cc5c56 100644 (file)
@@ -1,3 +1,10 @@
+2012-10-16  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * c-ada-spec.c (ADA_HOST_WIDE_INT_PRINT_DOUBLE_HEX): Define.
+       (dump_generic_ada_node) <INTEGER_CST>: Deal with sizetype specially.
+       Remove POINTER_TYPE handling, add large unsigned handling and use
+       ADA_HOST_WIDE_INT_PRINT_DOUBLE_HEX for big numbers.
+
 2012-10-12  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/54381
index 631ee7a..792fee2 100644 (file)
@@ -30,6 +30,21 @@ along with GCC; see the file COPYING3.  If not see
 #include "c-pragma.h"
 #include "cpp-id-data.h"
 
+/* Adapted from hwint.h to use the Ada prefix.  */
+#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
+# if HOST_BITS_PER_WIDE_INT == 64
+#  define ADA_HOST_WIDE_INT_PRINT_DOUBLE_HEX \
+     "16#%" HOST_LONG_FORMAT "x%016" HOST_LONG_FORMAT "x#"
+# else
+#  define ADA_HOST_WIDE_INT_PRINT_DOUBLE_HEX \
+     "16#%" HOST_LONG_FORMAT "x%08" HOST_LONG_FORMAT "x#"
+# endif
+#else
+  /* We can assume that 'long long' is at least 64 bits.  */
+# define ADA_HOST_WIDE_INT_PRINT_DOUBLE_HEX \
+    "16#%" HOST_LONG_LONG_FORMAT "x%016" HOST_LONG_LONG_FORMAT "x#"
+#endif /* HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG */
+
 /* Local functions, macros and variables.  */
 static int dump_generic_ada_node (pretty_printer *, tree, tree,
                                  int (*)(tree, cpp_operation), int, int, bool);
@@ -2175,12 +2190,16 @@ dump_generic_ada_node (pretty_printer *buffer, tree node, tree type,
       break;
 
     case INTEGER_CST:
-      if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
-       {
-         pp_wide_integer (buffer, TREE_INT_CST_LOW (node));
-         pp_string (buffer, "B"); /* pseudo-unit */
-       }
-      else if (!host_integerp (node, 0))
+      /* We treat the upper half of the sizetype range as negative.  This
+        is consistent with the internal treatment and makes it possible
+        to generate the (0 .. -1) range for flexible array members.  */
+      if (TREE_TYPE (node) == sizetype)
+       node = fold_convert (ssizetype, node);
+      if (host_integerp (node, 0))
+       pp_wide_integer (buffer, TREE_INT_CST_LOW (node));
+      else if (host_integerp (node, 1))
+       pp_unsigned_wide_integer (buffer, TREE_INT_CST_LOW (node));
+      else
        {
          tree val = node;
          unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (val);
@@ -2193,12 +2212,10 @@ dump_generic_ada_node (pretty_printer *buffer, tree node, tree type,
              low = -low;
            }
          sprintf (pp_buffer (buffer)->digit_buffer,
-         HOST_WIDE_INT_PRINT_DOUBLE_HEX,
-           (unsigned HOST_WIDE_INT) high, low);
+                  ADA_HOST_WIDE_INT_PRINT_DOUBLE_HEX,
+                  (unsigned HOST_WIDE_INT) high, low);
          pp_string (buffer, pp_buffer (buffer)->digit_buffer);
        }
-      else
-       pp_wide_integer (buffer, TREE_INT_CST_LOW (node));
       break;
 
     case REAL_CST:
index f384ebe..adeeb3e 100644 (file)
@@ -1,4 +1,9 @@
-2012-10-15   Easwaran Raman  <eraman@google.com>
+2012-10-16  Eric Botcazou <ebotcazou@adacore.com>
+
+       * g++.dg/other/dump-ada-spec-2.C: New test.
+
+2012-10-16  Easwaran Raman  <eraman@google.com>
+
        * gcc.dg/tree-prof/switch-case-1.c: New test case.
        * gcc.dg/tree-prof/switch-case-2.c: New test case.
 
diff --git a/gcc/testsuite/g++.dg/other/dump-ada-spec-2.C b/gcc/testsuite/g++.dg/other/dump-ada-spec-2.C
new file mode 100644 (file)
index 0000000..87c183a
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-ada-spec" } */
+
+struct S
+{
+  int it;
+  __extension__ unsigned char data[];
+};
+
+/* { dg-final { scan-ada-spec "array \\(0 .. -1\\)" } } */
+/* { dg-final { cleanup-ada-spec } } */