This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gomp4, 10/23] Ensure address space gets set on array types


Most of the compiler expects TYPE_ADDR_SPACE to be valid for things like
initializing a MEM. The C frontend does not set it for arrays, which
seems like an oversight caused by not setting other type qualifiers for
array types.

	gcc/
	* tree.h (set_type_quals): Declare.
	* tree.c (set_type_quals): No longer static.

	gcc/c/
	* c-typeck.c (c_build_qualified_type): Ensure arrays get the correct
	TYPE_ADDR_SPACE.

	gcc/c-family/
	* c-common.c (complete_array_type): Likewise.

------------------------------------------------------------------------
Index: gcc/c-family/c-common.c
===================================================================
--- gcc/c-family/c-common.c	(revision 422353)
+++ gcc/c-family/c-common.c	(revision 422354)
@@ -9997,6 +9997,8 @@ complete_array_type (tree *ptype, tree i
      of using build_array_type to create a new type preserves all of the
      TYPE_LANG_FLAG_? bits that the front end may have set.  */
   main_type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
+  set_type_quals (main_type, KEEP_QUAL_ADDR_SPACE (quals));
+
   TREE_TYPE (main_type) = unqual_elt;
   TYPE_DOMAIN (main_type)
     = build_range_type (TREE_TYPE (maxindex),
Index: gcc/c/c-typeck.c
===================================================================
--- gcc/c/c-typeck.c	(revision 422353)
+++ gcc/c/c-typeck.c	(revision 422354)
@@ -11748,6 +11748,7 @@ c_build_qualified_type (tree type, int t
 
 	  t = build_variant_type_copy (type);
 	  TREE_TYPE (t) = element_type;
+	  set_type_quals (t, KEEP_QUAL_ADDR_SPACE (type_quals));
 
           if (TYPE_STRUCTURAL_EQUALITY_P (element_type)
               || (domain && TYPE_STRUCTURAL_EQUALITY_P (domain)))
Index: gcc/tree.c
===================================================================
--- gcc/tree.c	(revision 422353)
+++ gcc/tree.c	(revision 422354)
@@ -205,7 +205,6 @@ static GTY ((if_marked ("tree_priority_m
 	     param_is (struct tree_priority_map)))
   htab_t init_priority_for_decl;
 
-static void set_type_quals (tree, int);
 static int type_hash_eq (const void *, const void *);
 static hashval_t type_hash_hash (const void *);
 static hashval_t int_cst_hash_hash (const void *);
@@ -6076,7 +6075,7 @@ handle_dll_attribute (tree * pnode, tree
 /* Set the type qualifiers for TYPE to TYPE_QUALS, which is a bitmask
    of the various TYPE_QUAL values.  */
 
-static void
+void
 set_type_quals (tree type, int type_quals)
 {
   TYPE_READONLY (type) = (type_quals & TYPE_QUAL_CONST) != 0;
Index: gcc/tree.h
===================================================================
--- gcc/tree.h	(revision 422353)
+++ gcc/tree.h	(revision 422354)
@@ -3785,6 +3785,9 @@ extern tree build_qualified_type (tree,
 
 extern tree build_aligned_type (tree, unsigned int);
 
+/* Set the type qualifiers on a type.  */
+extern void set_type_quals (tree, int);
+
 /* Like build_qualified_type, but only deals with the `const' and
    `volatile' qualifiers.  This interface is retained for backwards
    compatibility with the various front-ends; new code should use

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]