Use fix_string_type to get all string types.
When making a decl for __FUNCTION__ we use a slightly different method
than elsewhere to arrive at a string type. This changes it to use the
common idiom. On ptx these types will have an address space, and this
ensures that we don't drop it when constifying the type.
gcc/c/
* c-decl.c (c_make_fname_decl): Use fix_string_type to get a type,
then make it const.
------------------------------------------------------------------------
===================================================================
@@ -3559,9 +3559,13 @@ c_make_fname_decl (location_t loc, tree
tree decl, type, init;
size_t length = strlen (name);
- type = build_array_type (char_type_node,
- build_index_type (size_int (length)));
- type = c_build_qualified_type (type, TYPE_QUAL_CONST);
+ init = build_string (length + 1, name);
+ TREE_TYPE (init) = char_array_type_node;
+ init = fix_string_type (init);
+ type = TREE_TYPE (init);
+ type = c_build_qualified_type (type,
+ (TYPE_QUAL_CONST
+ | KEEP_QUAL_ADDR_SPACE (TYPE_QUALS (type))));
decl = build_decl (loc, VAR_DECL, id, type);
@@ -3569,9 +3573,7 @@ c_make_fname_decl (location_t loc, tree
TREE_READONLY (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
- init = build_string (length + 1, name);
free (CONST_CAST (char *, name));
- TREE_TYPE (init) = type;
DECL_INITIAL (decl) = init;
TREE_USED (decl) = 1;