aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorGary Dismukes <dismukes@adacore.com>2008-08-22 16:56:32 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2008-08-22 16:56:32 +0200
commit9f4e488138d23660082c4ecd744dd0ae7a5db028 (patch)
tree83f84a1594bea8e85b85300ab13c06aed2a5164d /gcc
parent9b4b0a1ac996ea8e38ff857fb171f3cd1f6a45a5 (diff)
downloadgcc-9f4e488138d23660082c4ecd744dd0ae7a5db028.zip
gcc-9f4e488138d23660082c4ecd744dd0ae7a5db028.tar.gz
gcc-9f4e488138d23660082c4ecd744dd0ae7a5db028.tar.bz2
sem_util.adb (Has_Preelaborable_Initialization): Revise checking of private types to allow for types derived from a private type...
2008-08-22 Gary Dismukes <dismukes@adacore.com> * sem_util.adb (Has_Preelaborable_Initialization): Revise checking of private types to allow for types derived from a private type with preelaborable initialization, but return False for a private extension (unless it has the pragma). From-SVN: r139480
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_util.adb22
1 files changed, 14 insertions, 8 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 7d8865c..83c3f4b 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -4616,14 +4616,6 @@ package body Sem_Util is
return Has_Preelaborable_Initialization (Base_Type (E));
end if;
- -- Other private types never have preelaborable initialization
-
- if Is_Private_Type (E) then
- return False;
- end if;
-
- -- Here for all non-private view
-
-- All elementary types have preelaborable initialization
if Is_Elementary_Type (E) then
@@ -4643,6 +4635,13 @@ package body Sem_Util is
elsif Is_Derived_Type (E) then
+ -- If the derived type is a private extension then it doesn't have
+ -- preelaborable initialization.
+
+ if Ekind (Base_Type (E)) = E_Record_Type_With_Private then
+ return False;
+ end if;
+
-- First check whether ancestor type has preelaborable initialization
Has_PE := Has_Preelaborable_Initialization (Etype (Base_Type (E)));
@@ -4663,6 +4662,13 @@ package body Sem_Util is
Has_PE := False;
end if;
+ -- Private types not derived from a type having preelaborable init and
+ -- that are not marked with pragma Preelaborable_Initialization do not
+ -- have preelaborable initialization.
+
+ elsif Is_Private_Type (E) then
+ return False;
+
-- Record type has PI if it is non private and all components have PI
elsif Is_Record_Type (E) then