diff options
author | gingold <gingold@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-09 11:49:50 +0000 |
---|---|---|
committer | gingold <gingold@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-09 11:49:50 +0000 |
commit | 7714837c8d8c66a53d87e4de6818fe47e1bb51d3 (patch) | |
tree | c2157f63030eac9c3e9f2a1b5c943b69133f0c01 /gcc/c-decl.c | |
parent | 2b336fc3ea490380d96587e145c5f66795f36b65 (diff) | |
download | gcc-7714837c8d8c66a53d87e4de6818fe47e1bb51d3.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@185136 138bc75d-0d04-0410-961f-82ee72b054a4
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 de46578e0bf..160d393e7ba 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) |