ada/
authorhainque <hainque@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 28 Sep 2009 17:00:46 +0000 (17:00 +0000)
committerhainque <hainque@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 28 Sep 2009 17:00:46 +0000 (17:00 +0000)
        * gcc-interface/targtyps.c
        * (get_target_default_allocator_alignment):
        Account for observable alignments out of default allocators.

        testsuite/
        * gnat.dg (tagged_alloc_free.adb): New testcase.

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

gcc/ada/ChangeLog
gcc/ada/gcc-interface/targtyps.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/tagged_alloc_free.adb [new file with mode: 0644]

index 8e4c061..dd06574 100644 (file)
@@ -1,3 +1,8 @@
+2009-09-28  Olivier Hainque  <hainque@adacore.com>
+
+       * gcc-interface/targtyps.c (get_target_default_allocator_alignment):
+       Account for observable alignments out of default allocators.
+
 2009-09-28  Richard Henderson  <rth@redhat.com>
 
        * gcc-interface/utils.c (gnat_install_builtins): Update call to
index 716550e..9bc8f0e 100644 (file)
@@ -160,10 +160,21 @@ get_target_maximum_default_alignment (void)
    handy and what alignment it honors).  In the meantime, resort to malloc
    considerations only.  */
 
+/* Account for MALLOC_OBSERVABLE_ALIGNMENTs here.  Use this or the ABI
+   guaranteed alignment if greater.  */
+
+#ifdef MALLOC_OBSERVABLE_ALIGNMENT
+#define MALLOC_ALIGNMENT MALLOC_OBSERVABLE_ALIGNMENT
+#else
+#define MALLOC_OBSERVABLE_ALIGNMENT (2 * LONG_TYPE_SIZE)
+#define MALLOC_ALIGNMENT \
+  MAX (MALLOC_ABI_ALIGNMENT, MALLOC_OBSERVABLE_ALIGNMENT)
+#endif
+
 Pos
 get_target_default_allocator_alignment (void)
 {
-  return MALLOC_ABI_ALIGNMENT / BITS_PER_UNIT;
+  return MALLOC_ALIGNMENT / BITS_PER_UNIT;
 }
 
 /* Standard'Maximum_Allowed_Alignment.  Maximum alignment that we may
index 566d5be..098dc2d 100644 (file)
@@ -1,3 +1,7 @@
+2009-09-28  Olivier Hainque  <hainque@adacore.com>
+
+       * gnat.dg (tagged_alloc_free.adb): New testcase.
+       
 2009-09-28  Janis Johnson  <janis187@us.ibm.com>
 
        * g++.dg/dfp: New directory.
diff --git a/gcc/testsuite/gnat.dg/tagged_alloc_free.adb b/gcc/testsuite/gnat.dg/tagged_alloc_free.adb
new file mode 100644 (file)
index 0000000..d26916d
--- /dev/null
@@ -0,0 +1,22 @@
+-- { dg-do run }
+
+with Ada.Unchecked_Deallocation;
+with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
+
+procedure Tagged_Alloc_Free is
+
+  type Test_Base is tagged null record;
+  type Test_Class_Access is access all Test_Base'Class;
+  type Test_Extension is new Test_Base with record
+    Last_Name : Unbounded_String := Null_Unbounded_String;
+  end record;
+
+  procedure Free is new Ada.Unchecked_Deallocation
+    (Object => Test_Base'Class,
+     Name   => Test_Class_Access);
+
+  Handle : Test_Class_Access := new Test_Extension;
+
+begin
+  Free (Handle);
+end;