aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/gcc-interface/decl.c16
-rw-r--r--gcc/ada/gcc-interface/utils2.c20
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gnat.dg/specs/constant1.ads22
-rw-r--r--gcc/testsuite/gnat.dg/specs/constant1_pkg.ads11
6 files changed, 69 insertions, 12 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 6624445..ade0440 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,10 @@
+2010-09-19 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Constant>: Look into
+ expressions for external constants that are aggregates.
+ * gcc-interface/utils2.c (build_simple_component_ref): If the field
+ is an inherited component in an extension, look through the extension.
+
2010-09-10 Vincent Celier <celier@adacore.com>
* projects.texi: Add documentation for package extensions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index 75cdb84..6d77ffb 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -421,17 +421,15 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
}
/* If we have an external constant that we are not defining, get the
- expression that is was defined to represent. We may throw that
- expression away later if it is not a constant. Do not retrieve the
- expression if it is an aggregate or allocator, because in complex
- instantiation contexts it may not be expanded */
+ expression that is was defined to represent. We may throw it away
+ later if it is not a constant. But do not retrieve the expression
+ if it is an allocator because the designated type might be dummy
+ at this point. */
if (!definition
- && Present (Expression (Declaration_Node (gnat_entity)))
&& !No_Initialization (Declaration_Node (gnat_entity))
- && (Nkind (Expression (Declaration_Node (gnat_entity)))
- != N_Aggregate)
- && (Nkind (Expression (Declaration_Node (gnat_entity)))
- != N_Allocator))
+ && Present (Expression (Declaration_Node (gnat_entity)))
+ && Nkind (Expression (Declaration_Node (gnat_entity)))
+ != N_Allocator)
gnu_expr = gnat_to_gnu (Expression (Declaration_Node (gnat_entity)));
/* Ignore deferred constant definitions without address clause since
diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c
index bd78686..c40223f 100644
--- a/gcc/ada/gcc-interface/utils2.c
+++ b/gcc/ada/gcc-interface/utils2.c
@@ -1603,10 +1603,9 @@ build_simple_component_ref (tree record_variable, tree component,
if (!field)
return NULL_TREE;
- /* If this field is not in the specified record, see if we can find
- something in the record whose original field is the same as this one. */
+ /* If this field is not in the specified record, see if we can find a field
+ in the specified record whose original field is the same as this one. */
if (DECL_CONTEXT (field) != record_type)
- /* Check if there is a field with name COMPONENT in the record. */
{
tree new_field;
@@ -1616,6 +1615,21 @@ build_simple_component_ref (tree record_variable, tree component,
if (SAME_FIELD_P (field, new_field))
break;
+ /* Next, see if we're looking for an inherited component in an extension.
+ If so, look thru the extension directly. */
+ if (!new_field
+ && TREE_CODE (record_variable) == VIEW_CONVERT_EXPR
+ && TYPE_ALIGN_OK (record_type)
+ && TREE_CODE (TREE_TYPE (TREE_OPERAND (record_variable, 0)))
+ == RECORD_TYPE
+ && TYPE_ALIGN_OK (TREE_TYPE (TREE_OPERAND (record_variable, 0))))
+ {
+ ref = build_simple_component_ref (TREE_OPERAND (record_variable, 0),
+ NULL_TREE, field, no_fold_p);
+ if (ref)
+ return ref;
+ }
+
/* Next, loop thru DECL_INTERNAL_P components if we haven't found
the component in the first search. Doing this search in 2 steps
is required to avoiding hidden homonymous fields in the
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9deaf42..dc0286a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2010-09-19 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/specs/constant1.ads: New test.
+ * gnat.dg/specs/constant1_pkg.ads: New helper.
+
2010-09-18 Jan Hubicka <jh@suse.cz>
PR tree-optimization/45453
diff --git a/gcc/testsuite/gnat.dg/specs/constant1.ads b/gcc/testsuite/gnat.dg/specs/constant1.ads
new file mode 100644
index 0000000..1c00c33
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/constant1.ads
@@ -0,0 +1,22 @@
+-- { dg-do compile }
+
+with Constant1_Pkg;
+
+package Constant1 is
+
+ type Timer_Id_T is new Constant1_Pkg.Timer_Id_T with null record;
+
+ type Timer_Op_T (Pending : Boolean := False) is
+ record
+ case Pending is
+ when True =>
+ Timer_Id : Timer_Id_T;
+ when False =>
+ null;
+ end case;
+ end record;
+
+ Timer : Timer_Op_T
+ := (True, Timer_Id_T'(Constant1_Pkg.Null_Timer_Id with null record));
+
+end Constant1;
diff --git a/gcc/testsuite/gnat.dg/specs/constant1_pkg.ads b/gcc/testsuite/gnat.dg/specs/constant1_pkg.ads
new file mode 100644
index 0000000..13300b1
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/constant1_pkg.ads
@@ -0,0 +1,11 @@
+package Constant1_Pkg is
+
+ type Id_T is mod Natural'Last + 1;
+
+ type Timer_Id_T is tagged record
+ Id : Id_T := Id_T'Last;
+ end record;
+
+ Null_Timer_Id : constant Timer_Id_T := (Id => Id_T'Last - 1);
+
+end Constant1_Pkg;