This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gomp4, 16/23] Keep address spaces on string type nodes
- From: Bernd Schmidt <bernds at codesourcery dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 9 Dec 2013 16:10:49 +0100
- Subject: [gomp4, 16/23] Keep address spaces on string type nodes
- Authentication-results: sourceware.org; auth=none
- References: <52A5D8D4 dot 2030803 at codesourcery dot com>
Another small patchlet to prepare for implicit address spaces. We'll
modify char_array_type_node etc. to have an address space for nvptx, and
we'll need to be careful to retain it in fix_string_type.
gcc/c-family/
* c-common.c (fix_string_type): Get the element type from the value's
type if possible.
------------------------------------------------------------------------
Index: gcc/c-family/c-common.c
===================================================================
--- gcc/c-family/c-common.c.orig
+++ gcc/c-family/c-common.c
@@ -960,27 +960,28 @@ fix_string_type (tree value)
int length = TREE_STRING_LENGTH (value);
int nchars;
tree e_type, i_type, a_type;
+ tree valtype = TREE_TYPE (value);
/* Compute the number of elements, for the array type. */
- if (TREE_TYPE (value) == char_array_type_node || !TREE_TYPE (value))
+ if (valtype == char_array_type_node || !valtype)
{
nchars = length;
- e_type = char_type_node;
+ e_type = valtype ? TREE_TYPE (valtype) : char_type_node;
}
- else if (TREE_TYPE (value) == char16_array_type_node)
+ else if (valtype == char16_array_type_node)
{
nchars = length / (TYPE_PRECISION (char16_type_node) / BITS_PER_UNIT);
- e_type = char16_type_node;
+ e_type = TREE_TYPE (valtype);
}
- else if (TREE_TYPE (value) == char32_array_type_node)
+ else if (valtype == char32_array_type_node)
{
nchars = length / (TYPE_PRECISION (char32_type_node) / BITS_PER_UNIT);
- e_type = char32_type_node;
+ e_type = TREE_TYPE (valtype);
}
else
{
nchars = length / (TYPE_PRECISION (wchar_type_node) / BITS_PER_UNIT);
- e_type = wchar_type_node;
+ e_type = TREE_TYPE (valtype);
}
/* C89 2.2.4.1, C99 5.2.4.1 (Translation limits). The analogous