aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorPierre-Marie de Rodat <derodat@adacore.com>2015-03-02 10:59:32 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2015-03-02 11:59:32 +0100
commitaef308d0d6a4d64fb220d88d0e7b736d70fd88da (patch)
tree52a6e66a285b54a02a7555a6e7d81b48214a6807 /gcc/ada
parent184a23e94a1b968a1b94defad02a00479a3264a2 (diff)
downloadgcc-aef308d0d6a4d64fb220d88d0e7b736d70fd88da.zip
gcc-aef308d0d6a4d64fb220d88d0e7b736d70fd88da.tar.gz
gcc-aef308d0d6a4d64fb220d88d0e7b736d70fd88da.tar.bz2
utils.c (gnat_pushdecl): For non-artificial pointer types...
2015-03-02 Pierre-Marie de Rodat <derodat@adacore.com> * gcc-interface/utils.c (gnat_pushdecl): For non-artificial pointer types, preserve the original type and create copies just like the C front-end does. For artificial ones, do not define a name for the original type. (create_type_decl): When gnat_pushdecl made the input type the original type for the new declaration, do not define a stub declaration for it. * gcc-interface/utils2.c (build_binary_op): Accept two different pointer types when they point to the same type. From-SVN: r221108
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog12
-rw-r--r--gcc/ada/gcc-interface/utils.c77
-rw-r--r--gcc/ada/gcc-interface/utils2.c7
3 files changed, 66 insertions, 30 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 6220a7e..97c86f3 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,15 @@
+2015-03-02 Pierre-Marie de Rodat <derodat@adacore.com>
+
+ * gcc-interface/utils.c (gnat_pushdecl): For non-artificial pointer
+ types, preserve the original type and create copies just like the C
+ front-end does. For artificial ones, do not define a name for
+ the original type.
+ (create_type_decl): When gnat_pushdecl made the input type the
+ original type for the new declaration, do not define a stub
+ declaration for it.
+ * gcc-interface/utils2.c (build_binary_op): Accept two different
+ pointer types when they point to the same type.
+
2015-03-02 Hristian Kirtchev <kirtchev@adacore.com>
* exp_util.adb (Possible_Bit_Aligned_Component): Do not process
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 4fa3d32..8d36cf7 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -773,32 +773,33 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
}
}
- /* For the declaration of a type, set its name if it either is not already
+ /* For the declaration of a type, set its name either if it isn't already
set or if the previous type name was not derived from a source name.
We'd rather have the type named with a real name and all the pointer
- types to the same object have the same POINTER_TYPE node. Code in the
- equivalent function of c-decl.c makes a copy of the type node here, but
- that may cause us trouble with incomplete types. We make an exception
- for fat pointer types because the compiler automatically builds them
- for unconstrained array types and the debugger uses them to represent
- both these and pointers to these. */
+ types to the same object have the same node, except when the names are
+ both derived from source names. */
if (TREE_CODE (decl) == TYPE_DECL && DECL_NAME (decl))
{
tree t = TREE_TYPE (decl);
- if (!(TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL))
+ if (!(TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL)
+ && (TREE_CODE (t) != POINTER_TYPE || DECL_ARTIFICIAL (decl)))
{
- /* Array and pointer types aren't "tagged" types so we force the
- type to be associated with its typedef in the DWARF back-end,
- in order to make sure that the latter is always preserved. */
- if (!DECL_ARTIFICIAL (decl)
- && (TREE_CODE (t) == ARRAY_TYPE
- || TREE_CODE (t) == POINTER_TYPE))
+ /* Array types aren't "tagged" types so we force the type to be
+ associated with its typedef in the DWARF back-end, in order to
+ make sure that the latter is always preserved. We used to do the
+ same for pointer types, but to have consistent DWARF output we now
+ create copies for DECL_ORIGINAL_TYPE just like the C front-end
+ does in c-common.c:set_underlying_type. */
+ if (!DECL_ARTIFICIAL (decl) && TREE_CODE (t) == ARRAY_TYPE)
{
tree tt = build_distinct_type_copy (t);
if (TREE_CODE (t) == POINTER_TYPE)
TYPE_NEXT_PTR_TO (t) = tt;
- TYPE_NAME (tt) = DECL_NAME (decl);
+ /* Array types need to have a name so that they can be related to
+ their GNAT encodings. */
+ if (TREE_CODE (t) == ARRAY_TYPE)
+ TYPE_NAME (tt) = DECL_NAME (decl);
defer_or_set_type_context (tt,
DECL_CONTEXT (decl),
deferred_decl_context);
@@ -806,32 +807,43 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
DECL_ORIGINAL_TYPE (decl) = tt;
}
}
- else if (TYPE_IS_FAT_POINTER_P (t))
+ else if (!DECL_ARTIFICIAL (decl)
+ && (TREE_CODE (t) == POINTER_TYPE || TYPE_IS_FAT_POINTER_P (t)))
{
- /* We need a variant for the placeholder machinery to work. */
- tree tt = build_variant_type_copy (t);
+ tree tt;
+ /* ??? We need a variant for the placeholder machinery to work. */
+ if (TYPE_IS_FAT_POINTER_P (t))
+ tt = build_variant_type_copy (t);
+ else
+ tt = build_distinct_type_copy (t);
+ if (TREE_CODE (t) == POINTER_TYPE)
+ TYPE_NEXT_PTR_TO (t) = tt;
TYPE_NAME (tt) = decl;
defer_or_set_type_context (tt,
DECL_CONTEXT (decl),
deferred_decl_context);
TREE_USED (tt) = TREE_USED (t);
TREE_TYPE (decl) = tt;
- if (DECL_ORIGINAL_TYPE (TYPE_NAME (t)))
+ if (TYPE_NAME (t) != NULL_TREE
+ && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
+ && DECL_ORIGINAL_TYPE (TYPE_NAME (t)))
DECL_ORIGINAL_TYPE (decl) = DECL_ORIGINAL_TYPE (TYPE_NAME (t));
else
DECL_ORIGINAL_TYPE (decl) = t;
- DECL_ARTIFICIAL (decl) = 0;
t = NULL_TREE;
}
- else if (DECL_ARTIFICIAL (TYPE_NAME (t)) && !DECL_ARTIFICIAL (decl))
+ else if (TYPE_NAME (t) != NULL_TREE
+ && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
+ && DECL_ARTIFICIAL (TYPE_NAME (t)) && !DECL_ARTIFICIAL (decl))
;
else
t = NULL_TREE;
/* Propagate the name to all the anonymous variants. This is needed
- for the type qualifiers machinery to work properly. Also propagate
- the context to them. Note that the context will be propagated to all
- parallel types too thanks to gnat_set_type_context. */
+ for the type qualifiers machinery to work properly (see
+ check_qualified_type). Also propagate the context to them. Note that
+ the context will be propagated to all parallel types too thanks to
+ gnat_set_type_context. */
if (t)
for (t = TYPE_MAIN_VARIANT (t); t; t = TYPE_NEXT_VARIANT (t))
if (!(TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL))
@@ -2277,11 +2289,16 @@ create_type_decl (tree type_name, tree type, bool artificial_p,
/* Add this decl to the current binding level. */
gnat_pushdecl (type_decl, gnat_node);
- /* If we're naming the type, equate the TYPE_STUB_DECL to the name.
- This causes the name to be also viewed as a "tag" by the debug
- back-end, with the advantage that no DW_TAG_typedef is emitted
- for artificial "tagged" types in DWARF. */
- if (!named)
+ /* If we're naming the type, equate the TYPE_STUB_DECL to the name. This
+ causes the name to be also viewed as a "tag" by the debug back-end, with
+ the advantage that no DW_TAG_typedef is emitted for artificial "tagged"
+ types in DWARF.
+
+ Note that if "type" is used as a DECL_ORIGINAL_TYPE, it may be referenced
+ from multiple contexts, and "type_decl" references a copy of it: in such a
+ case, do not mess TYPE_STUB_DECL: we do not want to re-use the TYPE_DECL
+ with the mechanism above. */
+ if (!named && type != DECL_ORIGINAL_TYPE (type_decl))
TYPE_STUB_DECL (type) = type_decl;
/* Do not generate debug info for UNCONSTRAINED_ARRAY_TYPE that the
@@ -5216,7 +5233,7 @@ gnat_write_global_declarations (void)
/* The general scheme is fairly simple:
For each builtin function/type to be declared, gnat_install_builtins calls
- internal facilities which eventually get to gnat_push_decl, which in turn
+ internal facilities which eventually get to gnat_pushdecl, which in turn
tracks the so declared builtin function decls in the 'builtin_decls' global
datastructure. When an Intrinsic subprogram declaration is processed, we
search this global datastructure to retrieve the associated BUILT_IN DECL
diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c
index a5fb3e2..e04add9 100644
--- a/gcc/ada/gcc-interface/utils2.c
+++ b/gcc/ada/gcc-interface/utils2.c
@@ -1062,6 +1062,13 @@ build_binary_op (enum tree_code op_code, tree result_type,
gcc_unreachable ();
}
+ else if (POINTER_TYPE_P (left_base_type)
+ && POINTER_TYPE_P (right_base_type))
+ {
+ gcc_assert (TREE_TYPE (left_base_type)
+ == TREE_TYPE (right_base_type));
+ best_type = left_base_type;
+ }
else
gcc_unreachable ();