diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-01-13 11:05:22 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-01-13 11:05:22 +0100 |
commit | e4d0416682374541d42aebe9b3535dbfa7fd0058 (patch) | |
tree | a7f70047650464a25666464552b1b189dc756398 /gcc/ada/sem_eval.adb | |
parent | 66340e0e9a029aa5cbba0e63f66e5319c1286ce4 (diff) | |
download | gcc-e4d0416682374541d42aebe9b3535dbfa7fd0058.zip gcc-e4d0416682374541d42aebe9b3535dbfa7fd0058.tar.gz gcc-e4d0416682374541d42aebe9b3535dbfa7fd0058.tar.bz2 |
[multiple changes]
2017-01-13 Arnaud Charlet <charlet@adacore.com>
* bindusg.adb: Improve usage output for -f switch.
2017-01-13 Hristian Kirtchev <kirtchev@adacore.com>
* frontend.adb, freeze.adb, sem_res.adb, sem_attr.adb, sem_ch8.adb:
Minor reformatting.
2017-01-13 Ed Schonberg <schonberg@adacore.com>
* sem_ch13.adb (Is_Predicate_Static): Following the intent of the RM,
treat comparisons on strings as legal in a Static_Predicate.
(Is_Predicate_Static, Is_Type_Ref): Predicate also returns true on
a function call that is the expansion of a string comparison.The
function call is built when compiling the corresponding predicate
function, but the expression has been found legal as a static
predicate during earlier analysis.
* sem_eval.adb (Real_Or_String_Static_Predicate_Matches): Handle
properly a function call that is the expansion of a string
comparison operation, in order to recover the Static_Predicate
expression and apply it to a static argument when needed.
From-SVN: r244400
Diffstat (limited to 'gcc/ada/sem_eval.adb')
-rw-r--r-- | gcc/ada/sem_eval.adb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb index 531dd70..f98498d 100644 --- a/gcc/ada/sem_eval.adb +++ b/gcc/ada/sem_eval.adb @@ -5469,6 +5469,40 @@ package body Sem_Eval is return Skip; end; + -- The predicate function may contain string-comparison operations + -- that have been converted into calls to run-time array-comparison + -- routines. To evaluate the predicate statically, we recover the + -- original comparison operation and replace the occurrence of the + -- formal by the static string value. The actuals of the generated + -- call are of the form X'Address. + + elsif Nkind (N) in N_Op_Compare + and then Nkind (Left_Opnd (N)) = N_Function_Call + then + declare + C : constant Node_Id := Left_Opnd (N); + F : constant Node_Id := First (Parameter_Associations (C)); + L : constant Node_Id := Prefix (F); + R : constant Node_Id := Prefix (Next (F)); + + begin + -- If an operand is an entity name, it is the formal of the + -- predicate function, so replace it with the string value. + -- It may be either operand in the call. The other operand + -- is a static string from the original predicate. + + if Is_Entity_Name (L) then + Rewrite (Left_Opnd (N), New_Copy (Val)); + Rewrite (Right_Opnd (N), New_Copy (R)); + + else + Rewrite (Left_Opnd (N), New_Copy (L)); + Rewrite (Right_Opnd (N), New_Copy (Val)); + end if; + + return Skip; + end; + else return OK; end if; |