diff options
author | Robert Dewar <dewar@adacore.com> | 2009-04-29 13:21:10 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2009-04-29 15:21:10 +0200 |
commit | 3b4ebfc31bb3c1a81119f71e0d7cf08952471019 (patch) | |
tree | f9a9df5616d3760e7879b0d08770f81e0de8b283 | |
parent | 0c463e161734f80cedd2b771bee49e7ee6be0f05 (diff) | |
download | gcc-3b4ebfc31bb3c1a81119f71e0d7cf08952471019.zip gcc-3b4ebfc31bb3c1a81119f71e0d7cf08952471019.tar.gz gcc-3b4ebfc31bb3c1a81119f71e0d7cf08952471019.tar.bz2 |
sem_util.adb (May_Be_Lvalue): Fix cases involving indexed/selected components
2009-04-29 Robert Dewar <dewar@adacore.com>
* sem_util.adb (May_Be_Lvalue): Fix cases involving indexed/selected
components
From-SVN: r146963
-rw-r--r-- | gcc/ada/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ada/sem_util.adb | 53 |
2 files changed, 49 insertions, 9 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 46a198f..d51fddb 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2009-04-29 Robert Dewar <dewar@adacore.com> + + * sem_util.adb (May_Be_Lvalue): Fix cases involving indexed/selected + components + 2009-04-29 Ed Schonberg <schonberg@adacore.com> * exp_ch9.ads, exp_ch9.adb (Build_Wrapper_Spec): Use source line of diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index c8ab927..e76e9d2 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -7259,23 +7259,58 @@ package body Sem_Util is return N = Prefix (P) and then Name_Implies_Lvalue_Prefix (Attribute_Name (P)); - when N_Expanded_Name | - N_Indexed_Component | - N_Selected_Component | - N_Slice => - if Is_Access_Type (Etype (N)) then - return False; -- P is an implicit dereference + -- For an expanded name, the name is an lvalue if the expanded name + -- is an lvalue, but the prefix is never an lvalue, since it is just + -- the scope where the name is found. + + when N_Expanded_Name => + if N = Prefix (P) then + return May_Be_Lvalue (P); else - return N = Prefix (P); + return False; end if; + -- For a selected component A.B, A is certainly an Lvalue if A.B is + -- an Lvalue. B is a little interesting, if we have A.B:=3, there is + -- some discussion as to whether B is an Lvalue or not, we choose to + -- say it is. Note however that A is not an Lvalue if it is of an + -- access type since this is an implicit dereference. + + when N_Selected_Component => + if N = Prefix (P) + and then Present (Etype (N)) + and then Is_Access_Type (Etype (N)) + then + return False; + else + return May_Be_Lvalue (P); + end if; + + -- For an indexed component or slice, the index or slice bounds is + -- never an Lvalue. The prefix is an lvalue if the indexed component + -- or slice is an Lvalue, except if it is an access type, where we + -- have an implicit dereference. + + when N_Indexed_Component => + if N /= Prefix (P) + or else (Present (Etype (N)) and then Is_Access_Type (Etype (N))) + then + return False; + else + return May_Be_Lvalue (P); + end if; + + -- Prefix of a reference is an Lvalue if the reference is an Lvalue + when N_Reference => - return N = Prefix (P); + return May_Be_Lvalue (P); + + -- Prefix of explicit dereference is never an Lvalue when N_Explicit_Dereference => return False; - -- Function call arguments are never lvalues + -- Function call arguments are never Lvalues when N_Function_Call => return False; |