diff options
author | Olivier Hainque <hainque@adacore.com> | 2009-09-28 17:00:46 +0000 |
---|---|---|
committer | Olivier Hainque <hainque@gcc.gnu.org> | 2009-09-28 17:00:46 +0000 |
commit | 2d3a1837bcf31c9a622d810d29179081613346df (patch) | |
tree | 2f8f64723bebd4ae3286b02c84a5c7a1e7eb9732 | |
parent | d366d023cbfcdefc9aebbbef54e49acc4fe4a5dd (diff) | |
download | gcc-2d3a1837bcf31c9a622d810d29179081613346df.zip gcc-2d3a1837bcf31c9a622d810d29179081613346df.tar.gz gcc-2d3a1837bcf31c9a622d810d29179081613346df.tar.bz2 |
ada/
* 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.
From-SVN: r152243
-rw-r--r-- | gcc/ada/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/targtyps.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/tagged_alloc_free.adb | 22 |
4 files changed, 43 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 8e4c061..dd06574 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -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 diff --git a/gcc/ada/gcc-interface/targtyps.c b/gcc/ada/gcc-interface/targtyps.c index 716550e..9bc8f0e 100644 --- a/gcc/ada/gcc-interface/targtyps.c +++ b/gcc/ada/gcc-interface/targtyps.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 566d5be..098dc2d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 0000000..d26916d --- /dev/null +++ b/gcc/testsuite/gnat.dg/tagged_alloc_free.adb @@ -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; |