diff options
author | Tristan Gingold <gingold@adacore.com> | 2012-03-09 11:49:50 +0000 |
---|---|---|
committer | Tristan Gingold <gingold@gcc.gnu.org> | 2012-03-09 11:49:50 +0000 |
commit | 412cd71971d07bde9c9f51cf4eba32a7f0df1175 (patch) | |
tree | c2157f63030eac9c3e9f2a1b5c943b69133f0c01 /gcc/c-decl.c | |
parent | 739fd6a6b37a914454431a7ab1f0a8f4e022b64c (diff) | |
download | gcc-412cd71971d07bde9c9f51cf4eba32a7f0df1175.zip gcc-412cd71971d07bde9c9f51cf4eba32a7f0df1175.tar.gz gcc-412cd71971d07bde9c9f51cf4eba32a7f0df1175.tar.bz2 |
c-tree.h (c_default_pointer_mode): New variable.
2012-03-09 Tristan Gingold <gingold@adacore.com>
* c-tree.h (c_default_pointer_mode): New variable.
* c-decl.c (c_default_pointer_mode): New variable.
(c_build_pointer_type): New function.
(grokdeclarator): Call c_build_pointer_type instead
of build_pointer_type.
* config/vms/vms-c.c: Include c-tree.h
(saved_pointer_mode): New variable.
(handle_pragma_pointer_size): New function.
(vms_pragma_pointer_size, vms_pragma_required_pointer_size): Likewise.
(vms_c_register_pragma): Register __pointer_size and
__required_pointer_size pragmas.
From-SVN: r185136
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index de46578..160d393 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -146,6 +146,10 @@ static int warn_about_return_type; static bool undef_nested_function; +/* Mode used to build pointers (VOIDmode means ptr_mode). */ + +enum machine_mode c_default_pointer_mode = VOIDmode; + /* Each c_binding structure describes one binding of an identifier to a decl. All the decls in a scope - irrespective of namespace - are @@ -558,6 +562,23 @@ add_stmt (tree t) return t; } +/* Build a pointer type using the default pointer mode. */ + +static tree +c_build_pointer_type (tree to_type) +{ + addr_space_t as = to_type == error_mark_node? ADDR_SPACE_GENERIC + : TYPE_ADDR_SPACE (to_type); + enum machine_mode pointer_mode; + + if (as != ADDR_SPACE_GENERIC || c_default_pointer_mode == VOIDmode) + pointer_mode = targetm.addr_space.pointer_mode (as); + else + pointer_mode = c_default_pointer_mode; + return build_pointer_type_for_mode (to_type, pointer_mode, false); +} + + /* Return true if we will want to say something if a goto statement crosses DECL. */ @@ -5683,7 +5704,7 @@ grokdeclarator (const struct c_declarator *declarator, TYPE_NAME (type) = decl; } - type = build_pointer_type (type); + type = c_build_pointer_type (type); /* Process type qualifiers (such as const or volatile) that were given inside the `*'. */ @@ -5918,7 +5939,7 @@ grokdeclarator (const struct c_declarator *declarator, type = TREE_TYPE (type); if (type_quals) type = c_build_qualified_type (type, type_quals); - type = build_pointer_type (type); + type = c_build_pointer_type (type); type_quals = array_ptr_quals; if (type_quals) type = c_build_qualified_type (type, type_quals); @@ -5937,7 +5958,7 @@ grokdeclarator (const struct c_declarator *declarator, "ISO C forbids qualified function types"); if (type_quals) type = c_build_qualified_type (type, type_quals); - type = build_pointer_type (type); + type = c_build_pointer_type (type); type_quals = TYPE_UNQUALIFIED; } else if (type_quals) |