diff options
author | uweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-10-26 21:58:06 +0000 |
---|---|---|
committer | uweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-10-26 21:58:06 +0000 |
commit | 6d5d708e56103fe5b3909c9782d2ade3a982350a (patch) | |
tree | 309434d678721acedb299f20cdc2b4778062b180 /gcc/c-parser.c | |
parent | 98155838dbd82b97bb7bb16dfcbf98fa2ab27ca9 (diff) | |
download | gcc-6d5d708e56103fe5b3909c9782d2ade3a982350a.tar.gz |
2009-10-26 Ben Elliston <bje@au.ibm.com>
Michael Meissner <meissner@linux.vnet.ibm.com>
Ulrich Weigand <uweigand@de.ibm.com>
* doc/tm.texi (TARGET_ADDR_SPACE_KEYWORDS): Document.
* c-common.c (c_common_reswords): If TARGET_ADDR_SPACE_KEYWORDS is
defined, add the named address space keywords.
(c_addr_space_name): New function.
(complete_array_type): Preserve named address space.
(handle_mode_attribute): Use targetm.addr_space.valid_pointer_mode
instead of targetm.valid_pointer_mode.
* c-common.h (enum rid): Add RID_ADDR_SPACE_0 .. RID_ADDR_SPACE_15,
RID_FIRST_ADDR_SPACE and RID_LAST_ADDR_SPACE.
(ADDR_SPACE_KEYWORD): New macro.
(c_addr_space_name): Add prototype.
* c-tree.h (struct c_declspecs): Add address_space member.
(declspecs_add_addrspace): Add prototype.
* c-pretty-print.c (pp_c_type_qualifier_list): Handle address spaces.
* c-parser.c (c_parse_init): Add assertion.
(typedef enum c_id_kind): Add C_ID_ADDRSPACE.
(c_lex_one_token): Handle address space keywords.
(c_token_starts_typename): Likewise.
(c_token_starts_declspecs): Likewise.
(c_parser_declspecs): Likewise.
(c_parser_postfix_expression_after_paren_type): Diagnose compound
literal within function qualified with named address space.
* c-decl.c (diagnose_mismatched_decls): Diagnose conflicting named
address space qualifiers.
(shadow_tag_warned): Warn about useless address space qualifiers.
(quals_from_declspecs): Handle address space qualifiers.
(grokdeclarator): Likewise.
(build_null_declspecs): Likewise.
(declspecs_add_addrspace): New function.
* c-typeck.c (addr_space_superset): New function.
(qualify_type): Handle named address spaces.
(composite_type): Likewise.
(common_pointer_type): Likewise.
(comp_target_types): Likewise.
(build_conditional_expr): Likewise.
(handle_warn_cast_qual): Likewise.
(build_c_cast): Likewise.
(convert_for_assignment): Likewise.
(build_binary_op): Likewise.
(pointer_diff): Handle named address spaces. Use intermediate
integer type of sufficient size if required.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153574 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-parser.c')
-rw-r--r-- | gcc/c-parser.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gcc/c-parser.c b/gcc/c-parser.c index 767d97fbe58..1a6012e9128 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -72,6 +72,10 @@ c_parse_init (void) tree id; int mask = 0; + /* Make sure RID_MAX hasn't grown past the 8 bits used to hold the keyword in + the c_token structure. */ + gcc_assert (RID_MAX <= 255); + mask |= D_CXXONLY; if (!flag_isoc99) mask |= D_C99; @@ -132,6 +136,8 @@ typedef enum c_id_kind { C_ID_TYPENAME, /* An identifier declared as an Objective-C class name. */ C_ID_CLASSNAME, + /* An address space identifier. */ + C_ID_ADDRSPACE, /* Not an identifier. */ C_ID_NONE } c_id_kind; @@ -226,6 +232,13 @@ c_lex_one_token (c_parser *parser, c_token *token) "identifier %qE conflicts with C++ keyword", token->value); } + else if (rid_code >= RID_FIRST_ADDR_SPACE + && rid_code <= RID_LAST_ADDR_SPACE) + { + token->id_kind = C_ID_ADDRSPACE; + token->keyword = rid_code; + break; + } else if (c_dialect_objc ()) { if (!objc_is_reserved_word (token->value) @@ -352,6 +365,8 @@ c_token_starts_typename (c_token *token) { case C_ID_ID: return false; + case C_ID_ADDRSPACE: + return true; case C_ID_TYPENAME: return true; case C_ID_CLASSNAME: @@ -422,6 +437,8 @@ c_token_starts_declspecs (c_token *token) { case C_ID_ID: return false; + case C_ID_ADDRSPACE: + return true; case C_ID_TYPENAME: return true; case C_ID_CLASSNAME: @@ -1411,6 +1428,7 @@ c_parser_asm_definition (c_parser *parser) const restrict volatile + address-space-qualifier (restrict is new in C99.) @@ -1419,6 +1437,12 @@ c_parser_asm_definition (c_parser *parser) declaration-specifiers: attributes declaration-specifiers[opt] + type-qualifier: + address-space + + address-space: + identifier recognized by the target + storage-class-specifier: __thread @@ -1459,6 +1483,17 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs, { tree value = c_parser_peek_token (parser)->value; c_id_kind kind = c_parser_peek_token (parser)->id_kind; + + if (kind == C_ID_ADDRSPACE) + { + addr_space_t as + = c_parser_peek_token (parser)->keyword - RID_FIRST_ADDR_SPACE; + declspecs_add_addrspace (specs, as); + c_parser_consume_token (parser); + attrs_ok = true; + continue; + } + /* This finishes the specifiers unless a type name is OK, it is declared as a type name and a type name hasn't yet been seen. */ @@ -5775,6 +5810,14 @@ c_parser_postfix_expression_after_paren_type (c_parser *parser, finish_init (); maybe_warn_string_init (type, init); + if (type != error_mark_node + && !ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (type)) + && current_function_decl) + { + error ("compound literal qualified by address-space qualifier"); + type = error_mark_node; + } + if (!flag_isoc99) pedwarn (start_loc, OPT_pedantic, "ISO C90 forbids compound literals"); non_const = ((init.value && TREE_CODE (init.value) == CONSTRUCTOR) |