diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2010-11-10 11:56:14 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2010-11-10 11:56:14 +0000 |
commit | 054d6b836f08882538082f76547c4414cb52e0ba (patch) | |
tree | 1a825cfc7c0ddbe33d8a235f9c004fd1fb7fe2f9 | |
parent | 5c779305f6a063aed81e1e7025e1a609de83b1d9 (diff) | |
download | gcc-054d6b836f08882538082f76547c4414cb52e0ba.zip gcc-054d6b836f08882538082f76547c4414cb52e0ba.tar.gz gcc-054d6b836f08882538082f76547c4414cb52e0ba.tar.bz2 |
trans.c (lvalue_required_p) <N_Type_Conversion>): Look through it for elementary types as well.
* gcc-interface/trans.c (lvalue_required_p) <N_Type_Conversion>): Look
through it for elementary types as well.
<N_Unchecked_Type_Conversion>: Adjust to above change.
<N_Allocator>: Likewise.
(gnat_to_gnu): Do not attempt to rewrite boolean literals.
From-SVN: r166532
-rw-r--r-- | gcc/ada/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/trans.c | 33 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/boolean_conv.adb | 34 |
4 files changed, 61 insertions, 18 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 0e522fd..477aa98 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,13 @@ 2010-11-10 Eric Botcazou <ebotcazou@adacore.com> + * gcc-interface/trans.c (lvalue_required_p) <N_Type_Conversion>): Look + through it for elementary types as well. + <N_Unchecked_Type_Conversion>: Adjust to above change. + <N_Allocator>: Likewise. + (gnat_to_gnu): Do not attempt to rewrite boolean literals. + +2010-11-10 Eric Botcazou <ebotcazou@adacore.com> + * gcc-interface/decl.c (gnat_to_gnu_entity): Do not set DECL_ARTIFICIAL on the reused DECL node coming from a renamed object. Set DECL_IGNORED_P on the DECL node built for renaming entities if they diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index e0d1793..5d36595 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -829,29 +829,25 @@ lvalue_required_p (Node_Id gnat_node, tree gnu_type, bool constant, || (Is_Composite_Type (Underlying_Type (Etype (gnat_node))) && Is_Atomic (Entity (Name (gnat_parent))))); - case N_Type_Conversion: - case N_Qualified_Expression: - /* We must look through all conversions for composite types because we - may need to bypass an intermediate conversion to a narrower record - type that is generated for a formal conversion, e.g. the conversion - to the root type of a hierarchy of tagged types generated for the - formal conversion to the class-wide type. */ - if (!Is_Composite_Type (Underlying_Type (Etype (gnat_node)))) - return 0; + case N_Unchecked_Type_Conversion: + if (!constant) + return 1; /* ... fall through ... */ - case N_Unchecked_Type_Conversion: - return (!constant - || lvalue_required_p (gnat_parent, - get_unpadded_type (Etype (gnat_parent)), - constant, address_of_constant, aliased)); + case N_Type_Conversion: + case N_Qualified_Expression: + /* We must look through all conversions because we may need to bypass + an intermediate conversion that is meant to be purely formal. */ + return lvalue_required_p (gnat_parent, + get_unpadded_type (Etype (gnat_parent)), + constant, address_of_constant, aliased); case N_Allocator: - /* We should only reach here through the N_Qualified_Expression case - and, therefore, only for composite types. Force an lvalue since - a block-copy to the newly allocated area of memory is made. */ - return 1; + /* We should only reach here through the N_Qualified_Expression case. + Force an lvalue for composite types since a block-copy to the newly + allocated area of memory is made. */ + return Is_Composite_Type (Underlying_Type (Etype (gnat_node))); case N_Explicit_Dereference: /* We look through dereferences for address of constant because we need @@ -5781,6 +5777,7 @@ gnat_to_gnu (Node_Id gnat_node) so that the code just below can put the location information of the reference to B on the inequality operator for better debug info. */ if (!optimize + && TREE_CODE (gnu_result) != INTEGER_CST && (kind == N_Identifier || kind == N_Expanded_Name || kind == N_Explicit_Dereference diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 468b863..f3a0b12 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-11-10 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/boolean_conv.adb: New test. + 2010-11-10 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> * gcc.dg/stack-usage-1.c: Define SIZE for s390 and s390x. diff --git a/gcc/testsuite/gnat.dg/boolean_conv.adb b/gcc/testsuite/gnat.dg/boolean_conv.adb new file mode 100644 index 0000000..7a9b4f3 --- /dev/null +++ b/gcc/testsuite/gnat.dg/boolean_conv.adb @@ -0,0 +1,34 @@ +-- { dg-do run } + +with System; use System; + +procedure Boolean_Conv is + subtype B1 is Boolean; + subtype B2 is Boolean; + A0, A1, A2 : Address; + + B : aliased B1; + + procedure P2 (X2 : access B2) is + begin + A2 := X2.all'Address; + end P2; + + procedure P1 (X1 : access B1) is + begin + A1 := X1.all'Address; + P2 (B2 (X1.all)'Unrestricted_Access); + end P1; + +begin + A0 := B'Address; + P1 (B'Access); + + if A1 /= A0 then + raise Program_Error; + end if; + + if A2 /= A0 then + raise Program_Error; + end if; +end; |