diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-01-19 10:37:59 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-01-19 10:37:59 +0000 |
commit | 698d81ad3d737d882aab66d64cf53bf741d09546 (patch) | |
tree | 94817510a2b1922a0d21ee9356fdcf6573a68339 /gcc/ada/sem_eval.adb | |
parent | df9e12ce41ffa6240d58c4abe427381c989c81f0 (diff) | |
download | gcc-698d81ad3d737d882aab66d64cf53bf741d09546.tar.gz |
2004-01-19 Arnaud Charlet <charlet@act-europe.fr>
* utils.c: Update copyright notice, missed in previous change.
2004-01-19 Vincent Celier <celier@gnat.com>
* mlib-prj.adb (Build_Library.Add_ALI_For): Only add the ALI to the
args if Bind is True. Set First_ALI, if not already done.
(Build_Library): For Stand Alone Libraries, extract from one ALI file
an eventual --RTS switch, for gnatbind, and all backend switches +
--RTS, for linking.
2004-01-19 Robert Dewar <dewar@gnat.com>
* sem_attr.adb, memtrack.adb: Minor reformatting
2004-01-19 Ed Schonberg <schonberg@gnat.com>
* exp_ch6.adb (Expand_Call): Remove code to fold calls to functions
that rename enumeration literals. This is properly done in sem_eval.
* sem_eval.ads, sem_eval.adb (Eval_Call): New procedure to fold calls
to functions that rename enumeration literals.
* sem_res.adb (Resolve_Call): Use Eval_Call to fold static calls to
functions that rename enumeration literals.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@76146 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/sem_eval.adb')
-rw-r--r-- | gcc/ada/sem_eval.adb | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb index 222355d1dc3..f884854f906 100644 --- a/gcc/ada/sem_eval.adb +++ b/gcc/ada/sem_eval.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2003 Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2004 Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -1180,6 +1180,49 @@ package body Sem_Eval is null; end Eval_Character_Literal; + --------------- + -- Eval_Call -- + --------------- + + -- Static function calls are either calls to predefined operators + -- with static arguments, or calls to functions that rename a literal. + -- Only the latter case is handled here, predefined operators are + -- constant-folded elsewhere. + -- If the function is itself inherited (see 7423-001) the literal of + -- the parent type must be explicitly converted to the return type + -- of the function. + + procedure Eval_Call (N : Node_Id) is + Loc : constant Source_Ptr := Sloc (N); + Typ : constant Entity_Id := Etype (N); + Lit : Entity_Id; + + begin + if Nkind (N) = N_Function_Call + and then No (Parameter_Associations (N)) + and then Is_Entity_Name (Name (N)) + and then Present (Alias (Entity (Name (N)))) + and then Is_Enumeration_Type (Base_Type (Typ)) + then + Lit := Alias (Entity (Name (N))); + + while Present (Alias (Lit)) loop + Lit := Alias (Lit); + end loop; + + if Ekind (Lit) = E_Enumeration_Literal then + if Base_Type (Etype (Lit)) /= Base_Type (Typ) then + Rewrite + (N, Convert_To (Typ, New_Occurrence_Of (Lit, Loc))); + else + Rewrite (N, New_Occurrence_Of (Lit, Loc)); + end if; + + Resolve (N, Typ); + end if; + end if; + end Eval_Call; + ------------------------ -- Eval_Concatenation -- ------------------------ |