diff options
author | Eric Christopher <echristo@gcc.gnu.org> | 2004-02-27 02:01:10 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gcc.gnu.org> | 2004-02-27 02:01:10 +0000 |
commit | 2152660651dd8d705e788e30dc9e6baa68706ab3 (patch) | |
tree | e038a62a69bfb1693a9ec4eefdb706a3fe353e15 | |
parent | 26d8bbbbc39d3621e926b393138125800a5dc90a (diff) | |
download | gcc-2152660651dd8d705e788e30dc9e6baa68706ab3.tar.gz |
target-supports.exp (check-iconv-available): New function.
2004-02-26 Eric Christopher <echristo@redhat.com>
* lib/target-supports.exp (check-iconv-available): New function.
* lib/gcc-dg.exp (dg-require-iconv): New function.
Use above.
* gcc.dg/charset: New directory.
* gcc.dg/charset/charset.exp: New file.
* gcc.dg/charset/asm1.c: Ditto.
* gcc.dg/charset/asm2.c: Ditto.
* gcc.dg/charset/asm3.c: Ditto.
* gcc.dg/charset/asm4.c: Ditto.
* gcc.dg/charset/asm5.c: Ditto.
* gcc.dg/charset/attribute1.c: Ditto.
* gcc.dg/charset/attribute2.c: Ditto.
* gcc.dg/charset/string1.c: Ditto.
* g++.dg/charset: New directory.
* g++.dg/dg.exp: Add here. Special options.
* g++.dg/charset/charset.exp: New file.
* g++.dg/charset/asm1.c: Ditto.
* g++.dg/charset/asm2.c: Ditto.
* g++.dg/charset/asm3.c: Ditto.
* g++.dg/charset/asm4.c: Ditto.
* g++.dg/charset/attribute1.c: Ditto.
* g++.dg/charset/attribute2.c: Ditto.
* g++.dg/charset/extern1.cc: Ditto.
* g++.dg/charset/extern2.cc: Ditto.
* g++.dg/charset/string1.c: Ditto.
2004-02-26 Eric Christopher <echristo@redhat.com>
* c-lex.c (c_lex_string_translate): New variable.
(lex_string): Use to determine string translation.
* c-pragma.h: Prototype.
* c-parse.in (start_string_translation): New. Set above.
(stop_string_translation): Ditto.
(attribute, attribute_list, asm_def, asm_stmt,
asm_operand): Use above functions.
* cp/parser.c (cp_parser_declaration): Translate strings
unless token is RID_EXTERN. Set c_lex_string_translate
for recursive use.
(cp_parser_asm_definition): Only translate argument strings
to asms.
(cp_parser_asm_operand_list): Ditto.
(cp_parser_attribute_list): Do not translate attribute strings.
From-SVN: r78548
28 files changed, 1180 insertions, 751 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 48af072a4d1..2df61916674 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,20 @@ +2004-02-26 Eric Christopher <echristo@redhat.com> + + * c-lex.c (c_lex_string_translate): New variable. + (lex_string): Use to determine string translation. + * c-pragma.h: Prototype. + * c-parse.in (start_string_translation): New. Set above. + (stop_string_translation): Ditto. + (attribute, attribute_list, asm_def, asm_stmt, + asm_operand): Use above functions. + * cp/parser.c (cp_parser_declaration): Translate strings + unless token is RID_EXTERN. Set c_lex_string_translate + for recursive use. + (cp_parser_asm_definition): Only translate argument strings + to asms. + (cp_parser_asm_operand_list): Ditto. + (cp_parser_attribute_list): Do not translate attribute strings. + 2004-02-26 Kazu Hirata <kazu@cs.umass.edu> * stmt.c (expand_start_case_dummy): Remove. @@ -104,7 +121,7 @@ * cfglayout.c (break_superblocks): Likewise; fix memory leak. * except.c (build_post_landing_pads, connect_post_landing_pads, dw2_build_landing_pads, sjlj_emit_function_enter, - sjlj_emit_function_exit, sjlj_emit_dispatch_table, + sjlj_emit_function_exit, sjlj_emit_dispatch_table, sjlj_build_landing_pads): Update CFG. (emit_to_new_bb_before): New function. (finish_eh_generation): Do not rebuild the CFG. @@ -715,7 +732,7 @@ 2004-02-23 Fariborz Jahanian <fjahanian@apple.com> * config/rs6000/rs6000.c (function_arg): call to rs6000_mixed_function_arg for DFmode moved to allow - normal DFmode incoming register assignment. + normal DFmode incoming register assignment. 2004-02-23 Dale Johannesen <dalej@apple.com> @@ -864,7 +881,7 @@ merely its number. (rs6000_attribute_table): Add "altivec" attribute. (rs6000_handle_altivec_attribute): New function. - * config/rs6000/rs6000.h (TARGET_OPTIONS): Describe + * config/rs6000/rs6000.h (TARGET_OPTIONS): Describe '-m[no-]-warn-altivec-long' (which '-W[no-]altivec-long-deprecated' maps to). (rs6000_warn_altivec_long, rs6000_warn_altivec_long_switch): Forward diff --git a/gcc/c-lex.c b/gcc/c-lex.c index cbd557346f9..3986b2771bb 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -54,6 +54,7 @@ static splay_tree file_info_tree; int pending_lang_change; /* If we need to switch languages - C++ only */ int c_header_level; /* depth in C headers - C++ only */ +bool c_lex_string_translate = true; /* If we need to translate characters received. */ static tree interpret_integer (const cpp_token *, unsigned int); static tree interpret_float (const cpp_token *, unsigned int); @@ -308,7 +309,7 @@ get_nonpadding_token (void) timevar_pop (TV_CPP); return tok; -} +} int c_lex_with_flags (tree *value, unsigned char *cpp_flags) @@ -675,7 +676,7 @@ lex_string (const cpp_token *tok, tree *valp, bool objc_string) if (tok->type == CPP_WSTRING) wide = true; obstack_grow (&str_ob, &tok->val.str, sizeof (cpp_string)); - + tok = get_nonpadding_token (); if (c_dialect_objc () && tok->type == CPP_ATSIGN) { @@ -693,7 +694,9 @@ lex_string (const cpp_token *tok, tree *valp, bool objc_string) if (count > 1 && !objc_string && warn_traditional && !in_system_header) warning ("traditional C rejects string constant concatenation"); - if (cpp_interpret_string (parse_in, strs, count, &istr, wide)) + if ((c_lex_string_translate + ? cpp_interpret_string : cpp_interpret_string_notranslate) + (parse_in, strs, count, &istr, wide)) { value = build_string (istr.len, (char *)istr.text); free ((void *)istr.text); diff --git a/gcc/c-parse.in b/gcc/c-parse.in index 59440857508..e628aa5fe90 100644 --- a/gcc/c-parse.in +++ b/gcc/c-parse.in @@ -1432,8 +1432,11 @@ attributes: ; attribute: - ATTRIBUTE '(' '(' attribute_list ')' ')' - { $$ = $4; } + ATTRIBUTE stop_string_translation + '(' '(' attribute_list ')' ')' start_string_translation + { $$ = $5; } + | ATTRIBUTE error start_string_translation + {} ; attribute_list: @@ -2480,8 +2483,9 @@ label: CASE expr_no_commas ':' /* simple_asm_expr is used in restricted contexts, where a full expression with inputs and outputs does not make sense. */ simple_asm_expr: - ASM_KEYWORD '(' STRING ')' - { $$ = $3; } + ASM_KEYWORD stop_string_translation + '(' STRING ')' start_string_translation + { $$ = $4; } ; /* maybeasm: used for assembly names for declarations */ @@ -2495,14 +2499,17 @@ maybeasm: asmdef: simple_asm_expr ';' { assemble_asm ($1); } + | ASM_KEYWORD error start_string_translation ';' + {} ; /* Full-blown asm statement with inputs, outputs, clobbers, and volatile tag allowed. */ asm_stmt: - ASM_KEYWORD maybe_volatile '(' asm_argument ')' ';' + ASM_KEYWORD maybe_volatile stop_string_translation + '(' asm_argument ')' start_string_translation ';' { stmt_count++; - $$ = build_asm_stmt ($2, $4); } + $$ = build_asm_stmt ($2, $5); } ; asm_argument: @@ -2550,12 +2557,13 @@ nonnull_asm_operands: ; asm_operand: - STRING '(' expr ')' - { $$ = build_tree_list (build_tree_list (NULL_TREE, $1), $3); } - | '[' identifier ']' STRING '(' expr ')' + STRING start_string_translation '(' expr ')' stop_string_translation + { $$ = build_tree_list (build_tree_list (NULL_TREE, $1), $4); } + | '[' identifier ']' STRING start_string_translation + '(' expr ')' stop_string_translation { $2 = build_string (IDENTIFIER_LENGTH ($2), IDENTIFIER_POINTER ($2)); - $$ = build_tree_list (build_tree_list ($2, $4), $6); } + $$ = build_tree_list (build_tree_list ($2, $4), $7); } ; asm_clobbers: @@ -2564,6 +2572,15 @@ asm_clobbers: | asm_clobbers ',' STRING { $$ = tree_cons (NULL_TREE, $3, $1); } ; + +stop_string_translation: + { c_lex_string_translate = false; } + ; + +start_string_translation: + { c_lex_string_translate = true; } + ; + /* This is what appears inside the parens in a function declarator. Its value is a list of ..._TYPE nodes. Attributes must appear here diff --git a/gcc/c-pragma.h b/gcc/c-pragma.h index a1469db1742..397b02d6840 100644 --- a/gcc/c-pragma.h +++ b/gcc/c-pragma.h @@ -57,4 +57,8 @@ extern void add_to_renaming_pragma_list (tree, tree); extern int c_lex (tree *); extern int c_lex_with_flags (tree *, unsigned char *); +/* If true, then lex strings into the execution character set. + Otherwise, lex strings into the host character set. */ +extern bool c_lex_string_translate; + #endif /* GCC_C_PRAGMA_H */ diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 3e26c2d5188..a7ec5f065b3 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -58,7 +58,7 @@ The parser routinely peeks at the next token, and then consumes it later. That also requires a buffer in which to store the tokens. - + In order to easily permit adding tokens to the end of the buffer, while removing them from the beginning of the buffer, we use a circular buffer. */ @@ -89,7 +89,7 @@ typedef struct cp_token GTY (()) large numbers of tokens. (For example, a token block is created when the body of an inline member function is first encountered; the tokens are processed later after the class definition is - complete.) + complete.) This somewhat ungainly data structure (as opposed to, say, a variable-length array), is used due to constraints imposed by the @@ -120,7 +120,7 @@ typedef struct cp_token_cache GTY (()) /* Prototypes. */ -static cp_token_cache *cp_token_cache_new +static cp_token_cache *cp_token_cache_new (void); static void cp_token_cache_push_token (cp_token_cache *, cp_token *); @@ -223,7 +223,7 @@ static cp_token *cp_lexer_next_token (cp_lexer *, cp_token *); static cp_token *cp_lexer_prev_token (cp_lexer *, cp_token *); -static ptrdiff_t cp_lexer_token_difference +static ptrdiff_t cp_lexer_token_difference (cp_lexer *, cp_token *, cp_token *); static cp_token *cp_lexer_read_token (cp_lexer *); @@ -241,7 +241,7 @@ static bool cp_lexer_next_token_is_not (cp_lexer *, enum cpp_ttype); static bool cp_lexer_next_token_is_keyword (cp_lexer *, enum rid); -static cp_token *cp_lexer_consume_token +static cp_token *cp_lexer_consume_token (cp_lexer *); static void cp_lexer_purge_token (cp_lexer *); @@ -253,11 +253,11 @@ static void cp_lexer_commit_tokens (cp_lexer *); static void cp_lexer_rollback_tokens (cp_lexer *); -static inline void cp_lexer_set_source_position_from_token +static inline void cp_lexer_set_source_position_from_token (cp_lexer *, const cp_token *); static void cp_lexer_print_token (FILE *, cp_token *); -static inline bool cp_lexer_debugging_p +static inline bool cp_lexer_debugging_p (cp_lexer *); static void cp_lexer_start_debugging (cp_lexer *) ATTRIBUTE_UNUSED; @@ -327,7 +327,7 @@ cp_lexer_new_main (void) /* Create the SAVED_TOKENS stack. */ VARRAY_INT_INIT (lexer->saved_tokens, CP_SAVED_TOKENS_SIZE, "saved_tokens"); - + /* Create the STRINGS array. */ VARRAY_TREE_INIT (lexer->string_tokens, 32, "strings"); @@ -357,7 +357,7 @@ cp_lexer_new_from_tokens (cp_token_cache *tokens) num_tokens += block->num_tokens; lexer->buffer = ggc_alloc (num_tokens * sizeof (cp_token)); lexer->buffer_end = lexer->buffer + num_tokens; - + /* Install the tokens. */ token = lexer->buffer; for (block = tokens->first; block != NULL; block = block->next) @@ -378,7 +378,7 @@ cp_lexer_new_from_tokens (cp_token_cache *tokens) /* Create the SAVED_TOKENS stack. */ VARRAY_INT_INIT (lexer->saved_tokens, CP_SAVED_TOKENS_SIZE, "saved_tokens"); - + /* Create the STRINGS array. */ VARRAY_TREE_INIT (lexer->string_tokens, 32, "strings"); @@ -536,9 +536,9 @@ cp_lexer_maybe_grow_buffer (cp_lexer* lexer) /* Compute the current buffer size. */ buffer_length = lexer->buffer_end - lexer->buffer; /* Allocate a buffer twice as big. */ - new_buffer = ggc_realloc (lexer->buffer, + new_buffer = ggc_realloc (lexer->buffer, 2 * buffer_length * sizeof (cp_token)); - + /* Because the buffer is circular, logically consecutive tokens are not necessarily placed consecutively in memory. Therefore, we must keep move the tokens that were before @@ -550,11 +550,11 @@ cp_lexer_maybe_grow_buffer (cp_lexer* lexer) num_tokens_to_copy * sizeof (cp_token)); /* Clear the rest of the buffer. We never look at this storage, but the garbage collector may. */ - memset (new_buffer + buffer_length + num_tokens_to_copy, 0, + memset (new_buffer + buffer_length + num_tokens_to_copy, 0, (buffer_length - num_tokens_to_copy) * sizeof (cp_token)); /* Now recompute all of the buffer pointers. */ - new_first_token + new_first_token = new_buffer + (lexer->first_token - old_buffer); if (lexer->next_token != NULL) { @@ -563,7 +563,7 @@ cp_lexer_maybe_grow_buffer (cp_lexer* lexer) if (lexer->next_token > lexer->first_token) next_token_delta = lexer->next_token - lexer->first_token; else - next_token_delta = + next_token_delta = buffer_length - (lexer->first_token - lexer->next_token); lexer->next_token = new_first_token + next_token_delta; } @@ -576,7 +576,7 @@ cp_lexer_maybe_grow_buffer (cp_lexer* lexer) /* Store the next token from the preprocessor in *TOKEN. */ -static void +static void cp_lexer_get_preprocessor_token (cp_lexer *lexer ATTRIBUTE_UNUSED , cp_token *token) { @@ -619,7 +619,7 @@ cp_lexer_get_preprocessor_token (cp_lexer *lexer ATTRIBUTE_UNUSED , token->location = input_location; /* Check to see if this token is a keyword. */ - if (token->type == CPP_NAME + if (token->type == CPP_NAME && C_IS_RESERVED_WORD (token->value)) { /* Mark this token as a keyword. */ @@ -746,7 +746,7 @@ cp_lexer_consume_token (cp_lexer* lexer) token = lexer->next_token; /* Increment NEXT_TOKEN. */ - lexer->next_token = cp_lexer_next_token (lexer, + lexer->next_token = cp_lexer_next_token (lexer, lexer->next_token); /* Check to see if we're all out of tokens. */ if (lexer->next_token == lexer->last_token) @@ -784,7 +784,7 @@ cp_lexer_purge_token (cp_lexer *lexer) cp_token *next_token; token = lexer->next_token; - while (true) + while (true) { next_token = cp_lexer_next_token (lexer, token); if (next_token == lexer->last_token) @@ -887,7 +887,7 @@ cp_lexer_rollback_tokens (cp_lexer* lexer) delta = VARRAY_TOP_INT(lexer->saved_tokens); /* Make it the next token again now. */ lexer->next_token = cp_lexer_advance_token (lexer, - lexer->first_token, + lexer->first_token, delta); /* It might be the case that there were no tokens when we started saving tokens, but that there are some tokens now. */ @@ -960,10 +960,10 @@ cp_lexer_print_token (FILE * stream, cp_token* token) else fprintf (stream, "%d", token->type); /* And, for an identifier, print the identifier name. */ - if (token->type == CPP_NAME + if (token->type == CPP_NAME /* Some keywords have a value that is not an IDENTIFIER_NODE. For example, `struct' is mapped to an INTEGER_CST. */ - || (token->type == CPP_KEYWORD + || (token->type == CPP_KEYWORD && TREE_CODE (token->value) == IDENTIFIER_NODE)) fprintf (stream, " %s", IDENTIFIER_POINTER (token->value)); } @@ -975,7 +975,7 @@ cp_lexer_start_debugging (cp_lexer* lexer) { ++lexer->debugging_p; } - + /* Stop emitting debugging information. */ static void @@ -1000,7 +1000,7 @@ cp_lexer_stop_debugging (cp_lexer* lexer) The parser invokes routines elsewhere in the compiler to perform semantic analysis and to build up the abstract syntax tree for the - code processed. + code processed. The parser (and the template instantiation code, which is, in a way, a close relative of parsing) are the only parts of the @@ -1013,7 +1013,7 @@ cp_lexer_stop_debugging (cp_lexer* lexer) Methodology ----------- - + The parser is of the standard recursive-descent variety. Upcoming tokens in the token stream are examined in order to determine which production to use when parsing a non-terminal. Some C++ constructs @@ -1033,7 +1033,7 @@ cp_lexer_stop_debugging (cp_lexer* lexer) Future Improvements ------------------- - + The performance of the parser could probably be improved substantially. Some possible improvements include: @@ -1174,7 +1174,7 @@ typedef struct cp_parser GTY(()) /* The scope in which names should be looked up. If NULL_TREE, then we look up names in the scope that is currently open in the source program. If non-NULL, this is either a TYPE or - NAMESPACE_DECL for the scope in which we should look. + NAMESPACE_DECL for the scope in which we should look. This value is not cleared automatically after a name is looked up, so we must be careful to clear it before starting a new look @@ -1188,7 +1188,7 @@ typedef struct cp_parser GTY(()) /* OBJECT_SCOPE and QUALIFYING_SCOPE give the scopes in which the last lookup took place. OBJECT_SCOPE is used if an expression like "x->y" or "x.y" was used; it gives the type of "*x" or "x", - respectively. QUALIFYING_SCOPE is used for an expression of the + respectively. QUALIFYING_SCOPE is used for an expression of the form "X::Y"; it refers to X. */ tree object_scope; tree qualifying_scope; @@ -1217,7 +1217,7 @@ typedef struct cp_parser GTY(()) that starts at this point. FALSE if only a gnu extension makes them permissible. */ bool default_arg_ok_p; - + /* TRUE if we are parsing an integral constant-expression. See [expr.const] for a precise definition. */ bool integral_constant_expression_p; @@ -1304,7 +1304,7 @@ typedef tree (*cp_parser_expression_fn) (cp_parser *); static cp_parser *cp_parser_new (void); -/* Routines to parse various constructs. +/* Routines to parse various constructs. Those that return `tree' will return the error_mark_node (rather than NULL_TREE) if a parse error occurs, unless otherwise noted. @@ -1364,7 +1364,7 @@ static tree cp_parser_new_initializer (cp_parser *); static tree cp_parser_delete_expression (cp_parser *); -static tree cp_parser_cast_expression +static tree cp_parser_cast_expression (cp_parser *, bool); static tree cp_parser_pm_expression (cp_parser *); @@ -1386,7 +1386,7 @@ static tree cp_parser_inclusive_or_expression (cp_parser *); static tree cp_parser_logical_and_expression (cp_parser *); -static tree cp_parser_logical_or_expression +static tree cp_parser_logical_or_expression (cp_parser *); static tree cp_parser_question_colon_clause (cp_parser *, tree); @@ -1439,7 +1439,7 @@ static void cp_parser_block_declaration (cp_parser *, bool); static void cp_parser_simple_declaration (cp_parser *, bool); -static tree cp_parser_decl_specifier_seq +static tree cp_parser_decl_specifier_seq (cp_parser *, cp_parser_flags, tree *, int *); static tree cp_parser_storage_class_specifier_opt (cp_parser *); @@ -1457,7 +1457,7 @@ static tree cp_parser_enum_specifier (cp_parser *); static void cp_parser_enumerator_list (cp_parser *, tree); -static void cp_parser_enumerator_definition +static void cp_parser_enumerator_definition (cp_parser *, tree); static tree cp_parser_namespace_name (cp_parser *); @@ -1591,7 +1591,7 @@ static void cp_parser_explicit_specialization /* Exception handling [gram.exception] */ -static tree cp_parser_try_block +static tree cp_parser_try_block (cp_parser *); static bool cp_parser_function_try_block (cp_parser *); @@ -1675,7 +1675,7 @@ static cp_token *cp_parser_require (cp_parser *, enum cpp_ttype, const char *); static cp_token *cp_parser_require_keyword (cp_parser *, enum rid, const char *); -static bool cp_parser_token_starts_function_definition_p +static bool cp_parser_token_starts_function_definition_p (cp_token *); static bool cp_parser_next_token_starts_class_definition_p (cp_parser *); @@ -1691,11 +1691,11 @@ static void cp_parser_check_access_in_redeclaration (tree type); static bool cp_parser_optional_template_keyword (cp_parser *); -static void cp_parser_pre_parsed_nested_name_specifier +static void cp_parser_pre_parsed_nested_name_specifier (cp_parser *); static void cp_parser_cache_group (cp_parser *, cp_token_cache *, enum cpp_ttype, unsigned); -static void cp_parser_parse_tentatively +static void cp_parser_parse_tentatively (cp_parser *); static void cp_parser_commit_to_tentative_parse (cp_parser *); @@ -1743,7 +1743,7 @@ static bool cp_parser_allow_gnu_extensions_p (cp_parser *); static bool cp_parser_is_string_literal (cp_token *); -static bool cp_parser_is_keyword +static bool cp_parser_is_keyword (cp_token *, enum rid); static tree cp_parser_make_typename_type (cp_parser *, tree, tree); @@ -1782,11 +1782,11 @@ cp_parser_error (cp_parser* parser, const char* message) { cp_token *token; token = cp_lexer_peek_token (parser->lexer); - c_parse_error (message, + c_parse_error (message, /* Because c_parser_error does not understand CPP_KEYWORD, keywords are treated like identifiers. */ - (token->type == CPP_KEYWORD ? CPP_NAME : token->type), + (token->type == CPP_KEYWORD ? CPP_NAME : token->type), token->value); } } @@ -1807,7 +1807,7 @@ cp_parser_name_lookup_error (cp_parser* parser, if (decl == error_mark_node) { if (parser->scope && parser->scope != global_namespace) - error ("`%D::%D' has not been declared", + error ("`%D::%D' has not been declared", parser->scope, name); else if (parser->scope == global_namespace) error ("`::%D' has not been declared", name); @@ -1858,7 +1858,7 @@ cp_parser_check_type_definition (cp_parser* parser) then an error is issued. */ static void -cp_parser_check_for_definition_in_return_type (tree declarator, +cp_parser_check_for_definition_in_return_type (tree declarator, int declares_class_or_enum) { /* [dcl.fct] forbids type definitions in return types. @@ -1869,7 +1869,7 @@ cp_parser_check_for_definition_in_return_type (tree declarator, || TREE_CODE (declarator) == ADDR_EXPR)) declarator = TREE_OPERAND (declarator, 0); if (declarator - && TREE_CODE (declarator) == CALL_EXPR + && TREE_CODE (declarator) == CALL_EXPR && declares_class_or_enum & 2) error ("new types may not be defined in a return type"); } @@ -1880,7 +1880,7 @@ cp_parser_check_for_definition_in_return_type (tree declarator, invalid attempt to form a template-id. */ static void -cp_parser_check_for_invalid_template_id (cp_parser* parser, +cp_parser_check_for_invalid_template_id (cp_parser* parser, tree type) { ptrdiff_t start; @@ -1933,7 +1933,7 @@ cp_parser_non_integral_constant_expression (const char *thing) } /* Emit a diagnostic for an invalid type name. Consider also if it is - qualified or not and the result of a lookup, to provide a better + qualified or not and the result of a lookup, to provide a better message. */ static void @@ -1970,7 +1970,7 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, tree scope, tree id) b = TREE_CHAIN (b)) { tree base_type = BINFO_TYPE (b); - if (CLASS_TYPE_P (base_type) + if (CLASS_TYPE_P (base_type) && dependent_type_p (base_type)) { tree field; @@ -1996,13 +1996,13 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, tree scope, tree id) } /* Here we diagnose qualified-ids where the scope is actually correct, but the identifier does not resolve to a valid type name. */ - else + else { if (TREE_CODE (parser->scope) == NAMESPACE_DECL) - error ("`%E' in namespace `%E' does not name a type", + error ("`%E' in namespace `%E' does not name a type", id, parser->scope); else if (TYPE_P (parser->scope)) - error ("`%E' in class `%T' does not name a type", + error ("`%E' in class `%T' does not name a type", id, parser->scope); else abort(); @@ -2012,10 +2012,10 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, tree scope, tree id) /* Check for a common situation where a type-name should be present, but is not, and issue a sensible error message. Returns true if an invalid type-name was detected. - + The situation handled by this function are variable declarations of the - form `ID a', where `ID' is an id-expression and `a' is a plain identifier. - Usually, `ID' should name a type, but if we got here it means that it + form `ID a', where `ID' is an id-expression and `a' is a plain identifier. + Usually, `ID' should name a type, but if we got here it means that it does not. We try to emit the best possible error message depending on how exactly the id-expression looks like. */ @@ -2026,7 +2026,7 @@ cp_parser_parse_and_diagnose_invalid_type_name (cp_parser *parser) tree id; cp_parser_parse_tentatively (parser); - id = cp_parser_id_expression (parser, + id = cp_parser_id_expression (parser, /*template_keyword_p=*/false, /*check_dependency_p=*/true, /*template_p=*/NULL, @@ -2035,7 +2035,7 @@ cp_parser_parse_and_diagnose_invalid_type_name (cp_parser *parser) otherwise this is not a simple variable declaration. Also, if the scope is dependent, we cannot do much. */ if (!cp_lexer_next_token_is (parser->lexer, CPP_NAME) - || (parser->scope && TYPE_P (parser->scope) + || (parser->scope && TYPE_P (parser->scope) && dependent_type_p (parser->scope))) { cp_parser_abort_tentative_parse (parser); @@ -2056,14 +2056,14 @@ cp_parser_parse_and_diagnose_invalid_type_name (cp_parser *parser) return true; } -/* Consume tokens up to, and including, the next non-nested closing `)'. +/* Consume tokens up to, and including, the next non-nested closing `)'. Returns 1 iff we found a closing `)'. RECOVERING is true, if we are doing error recovery. Returns -1 if OR_COMMA is true and we found an unnested comma. */ static int cp_parser_skip_to_closing_parenthesis (cp_parser *parser, - bool recovering, + bool recovering, bool or_comma, bool consume_paren) { @@ -2073,17 +2073,17 @@ cp_parser_skip_to_closing_parenthesis (cp_parser *parser, if (recovering && !or_comma && cp_parser_parsing_tentatively (parser) && !cp_parser_committed_to_tentative_parse (parser)) return 0; - + while (true) { cp_token *token; - + /* If we've run out of tokens, then there is no closing `)'. */ if (cp_lexer_next_token_is (parser->lexer, CPP_EOF)) return 0; token = cp_lexer_peek_token (parser->lexer); - + /* This matches the processing in skip_to_end_of_statement. */ if (token->type == CPP_SEMICOLON && !brace_depth) return 0; @@ -2097,7 +2097,7 @@ cp_parser_skip_to_closing_parenthesis (cp_parser *parser, if (recovering && or_comma && token->type == CPP_COMMA && !brace_depth && !paren_depth) return -1; - + if (!brace_depth) { /* If it is an `(', we have entered another level of nesting. */ @@ -2111,7 +2111,7 @@ cp_parser_skip_to_closing_parenthesis (cp_parser *parser, return 1; } } - + /* Consume the token. */ cp_lexer_consume_token (parser->lexer); } @@ -2146,7 +2146,7 @@ cp_parser_skip_to_end_of_statement (cp_parser* parser) /* If this is a non-nested `}', stop before consuming it. That way, when confronted with something like: - { 3 + } + { 3 + } we stop before consuming the closing `}', even though we have not yet reached a `;'. */ @@ -2225,7 +2225,7 @@ cp_parser_skip_to_end_of_block_or_statement (cp_parser* parser) token = cp_lexer_consume_token (parser->lexer); /* If the next token is a non-nested `}', then we have reached the end of the current block. */ - if (token->type == CPP_CLOSE_BRACE + if (token->type == CPP_CLOSE_BRACE && (nesting_depth == 0 || --nesting_depth == 0)) break; /* If it the next token is a `{', then we are entering a new @@ -2308,7 +2308,7 @@ cp_parser_new (void) parser->greater_than_is_operator_p = true; parser->default_arg_ok_p = true; - + /* We are not parsing a constant-expression. */ parser->integral_constant_expression_p = false; parser->allow_non_integral_constant_expression_p = false; @@ -2355,7 +2355,7 @@ cp_parser_new (void) /* Parse an identifier. Returns an IDENTIFIER_NODE representing the identifier. */ -static tree +static tree cp_parser_identifier (cp_parser* parser) { cp_token *token; @@ -2371,7 +2371,7 @@ cp_parser_identifier (cp_parser* parser) /* Parse a translation-unit. translation-unit: - declaration-seq [opt] + declaration-seq [opt] Returns TRUE if all went well. */ @@ -2385,7 +2385,7 @@ cp_parser_translation_unit (cp_parser* parser) /* If there are no tokens left then all went well. */ if (cp_lexer_next_token_is (parser->lexer, CPP_EOF)) break; - + /* Otherwise, issue an error message. */ cp_parser_error (parser, "expected declaration"); return false; @@ -2393,7 +2393,7 @@ cp_parser_translation_unit (cp_parser* parser) /* Consume the EOF token. */ cp_parser_require (parser, CPP_EOF, "end-of-file"); - + /* Finish up. */ finish_translation_unit (); @@ -2420,9 +2420,9 @@ cp_parser_translation_unit (cp_parser* parser) literal: __null - Returns a representation of the expression. + Returns a representation of the expression. - *IDK indicates what kind of id-expression (if any) was present. + *IDK indicates what kind of id-expression (if any) was present. *QUALIFYING_CLASS is set to a non-NULL value if the id-expression can be used as the operand of a pointer-to-member. In that case, @@ -2430,7 +2430,7 @@ cp_parser_translation_unit (cp_parser* parser) class in the pointer-to-member. */ static tree -cp_parser_primary_expression (cp_parser *parser, +cp_parser_primary_expression (cp_parser *parser, cp_id_kind *idk, tree *qualifying_class) { @@ -2468,7 +2468,7 @@ cp_parser_primary_expression (cp_parser *parser, cp_lexer_consume_token (parser->lexer); /* Within a parenthesized expression, a `>' token is always the greater-than operator. */ - saved_greater_than_is_operator_p + saved_greater_than_is_operator_p = parser->greater_than_is_operator_p; parser->greater_than_is_operator_p = true; /* If we see `( { ' then we are looking at the beginning of @@ -2478,13 +2478,13 @@ cp_parser_primary_expression (cp_parser *parser, { /* Statement-expressions are not allowed by the standard. */ if (pedantic) - pedwarn ("ISO C++ forbids braced-groups within expressions"); - + pedwarn ("ISO C++ forbids braced-groups within expressions"); + /* And they're not allowed outside of a function-body; you cannot, for example, write: - + int i = ({ int j = 3; j + 1; }); - + at class or namespace scope. */ if (!at_function_scope_p ()) error ("statement-expressions are allowed only inside functions"); @@ -2508,7 +2508,7 @@ cp_parser_primary_expression (cp_parser *parser, } /* The `>' token might be the end of a template-id or template-parameter-list now. */ - parser->greater_than_is_operator_p + parser->greater_than_is_operator_p = saved_greater_than_is_operator_p; /* Consume the `)'. */ if (!cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'")) @@ -2527,7 +2527,7 @@ cp_parser_primary_expression (cp_parser *parser, case RID_FALSE: cp_lexer_consume_token (parser->lexer); return boolean_false_node; - + /* The `__null' literal. */ case RID_NULL: cp_lexer_consume_token (parser->lexer); @@ -2562,7 +2562,7 @@ cp_parser_primary_expression (cp_parser *parser, __func__ are the names of variables -- but they are treated specially. Therefore, they are handled here, rather than relying on the generic id-expression logic - below. Grammatically, these names are id-expressions. + below. Grammatically, these names are id-expressions. Consume the token. */ token = cp_lexer_consume_token (parser->lexer); @@ -2610,7 +2610,7 @@ cp_parser_primary_expression (cp_parser *parser, /* Parse the parenthesized (almost) constant-expression. */ saved_in_offsetof_p = parser->in_offsetof_p; parser->in_offsetof_p = true; - expression + expression = cp_parser_constant_expression (parser, /*allow_non_constant_p=*/false, /*non_constant_p=*/NULL); @@ -2640,8 +2640,8 @@ cp_parser_primary_expression (cp_parser *parser, id_expression: /* Parse the id-expression. */ - id_expression - = cp_parser_id_expression (parser, + id_expression + = cp_parser_id_expression (parser, /*template_keyword_p=*/false, /*check_dependency_p=*/true, /*template_p=*/NULL, @@ -2655,7 +2655,7 @@ cp_parser_primary_expression (cp_parser *parser, || TREE_CODE (id_expression) == TYPE_DECL) decl = id_expression; /* Look up the name. */ - else + else { decl = cp_parser_lookup_name_simple (parser, id_expression); /* If name lookup gives us a SCOPE_REF, then the @@ -2682,7 +2682,7 @@ cp_parser_primary_expression (cp_parser *parser, extern void f(int j = i); } - Here, name look up will originally find the out + Here, name look up will originally find the out of scope `i'. We need to issue a warning message, but then use the global `i'. */ decl = check_for_out_of_scope_variable (decl); @@ -2694,8 +2694,8 @@ cp_parser_primary_expression (cp_parser *parser, } } } - - decl = finish_id_expression (id_expression, decl, parser->scope, + + decl = finish_id_expression (id_expression, decl, parser->scope, idk, qualifying_class, parser->integral_constant_expression_p, parser->allow_non_integral_constant_expression_p, @@ -2738,11 +2738,11 @@ cp_parser_primary_expression (cp_parser *parser, `template' keyword. If CHECK_DEPENDENCY_P is false, then names are looked up inside - uninstantiated templates. + uninstantiated templates. If *TEMPLATE_P is non-NULL, it is set to true iff the `template' keyword is used to explicitly indicate that the entity - named is a template. + named is a template. If DECLARATOR_P is true, the id-expression is appearing as part of a declarator, rather than as part of an expression. */ @@ -2762,11 +2762,11 @@ cp_parser_id_expression (cp_parser *parser, *template_p = false; /* Look for the optional `::' operator. */ - global_scope_p - = (cp_parser_global_scope_opt (parser, /*current_scope_valid_p=*/false) + global_scope_p + = (cp_parser_global_scope_opt (parser, /*current_scope_valid_p=*/false) != NULL_TREE); /* Look for the optional nested-name-specifier. */ - nested_name_specifier_p + nested_name_specifier_p = (cp_parser_nested_name_specifier_opt (parser, /*typename_keyword_p=*/false, check_dependency_p, @@ -2816,14 +2816,14 @@ cp_parser_id_expression (cp_parser *parser, /* If it's an identifier, and the next token is not a "<", then we can avoid the template-id case. This is an optimization for this common case. */ - if (token->type == CPP_NAME - && !cp_parser_nth_token_starts_template_argument_list_p + if (token->type == CPP_NAME + && !cp_parser_nth_token_starts_template_argument_list_p (parser, 2)) return cp_parser_identifier (parser); cp_parser_parse_tentatively (parser); /* Try a template-id. */ - id = cp_parser_template_id (parser, + id = cp_parser_template_id (parser, /*template_keyword_p=*/false, /*check_dependency_p=*/true, declarator_p); @@ -2844,7 +2844,7 @@ cp_parser_id_expression (cp_parser *parser, if (token->keyword == RID_OPERATOR) return cp_parser_operator_function_id (parser); /* Fall through. */ - + default: cp_parser_error (parser, "expected id-expression"); return error_mark_node; @@ -2879,7 +2879,7 @@ cp_parser_id_expression (cp_parser *parser, rather than as part of an expression. */ static tree -cp_parser_unqualified_id (cp_parser* parser, +cp_parser_unqualified_id (cp_parser* parser, bool template_keyword_p, bool check_dependency_p, bool declarator_p) @@ -2888,7 +2888,7 @@ cp_parser_unqualified_id (cp_parser* parser, /* Peek at the next token. */ token = cp_lexer_peek_token (parser->lexer); - + switch (token->type) { case CPP_NAME: @@ -2936,11 +2936,11 @@ cp_parser_unqualified_id (cp_parser* parser, template <typename T> void f(T t) { t.T::~T(); - } + } Here, it is not possible to look up `T' in the scope of `T' itself. We must look in both the current scope, and the - scope of the containing complete expression. + scope of the containing complete expression. Yet another issue is: @@ -2965,9 +2965,9 @@ cp_parser_unqualified_id (cp_parser* parser, /* If the name is of the form "X::~X" it's OK. */ if (scope && TYPE_P (scope) && cp_lexer_next_token_is (parser->lexer, CPP_NAME) - && (cp_lexer_peek_nth_token (parser->lexer, 2)->type + && (cp_lexer_peek_nth_token (parser->lexer, 2)->type == CPP_OPEN_PAREN) - && (cp_lexer_peek_token (parser->lexer)->value + && (cp_lexer_peek_token (parser->lexer)->value == TYPE_IDENTIFIER (scope))) { cp_lexer_consume_token (parser->lexer); @@ -2979,7 +2979,7 @@ cp_parser_unqualified_id (cp_parser* parser, if (scope) { cp_parser_parse_tentatively (parser); - type_decl = cp_parser_class_name (parser, + type_decl = cp_parser_class_name (parser, /*typename_keyword_p=*/false, /*template_keyword_p=*/false, /*type_p=*/false, @@ -2996,8 +2996,8 @@ cp_parser_unqualified_id (cp_parser* parser, parser->scope = qualifying_scope; parser->object_scope = NULL_TREE; parser->qualifying_scope = NULL_TREE; - type_decl - = cp_parser_class_name (parser, + type_decl + = cp_parser_class_name (parser, /*typename_keyword_p=*/false, /*template_keyword_p=*/false, /*type_p=*/false, @@ -3014,8 +3014,8 @@ cp_parser_unqualified_id (cp_parser* parser, parser->scope = object_scope; parser->object_scope = NULL_TREE; parser->qualifying_scope = NULL_TREE; - type_decl - = cp_parser_class_name (parser, + type_decl + = cp_parser_class_name (parser, /*typename_keyword_p=*/false, /*template_keyword_p=*/false, /*type_p=*/false, @@ -3029,8 +3029,8 @@ cp_parser_unqualified_id (cp_parser* parser, parser->scope = NULL_TREE; parser->object_scope = NULL_TREE; parser->qualifying_scope = NULL_TREE; - type_decl - = cp_parser_class_name (parser, + type_decl + = cp_parser_class_name (parser, /*typename_keyword_p=*/false, /*template_keyword_p=*/false, /*type_p=*/false, @@ -3050,7 +3050,7 @@ cp_parser_unqualified_id (cp_parser* parser, A typedef-name that names a class shall not be used as the identifier in the declarator for a destructor declaration. */ - if (declarator_p + if (declarator_p && !DECL_IMPLICIT_TYPEDEF_P (type_decl) && !DECL_SELF_REFERENCE_P (type_decl)) error ("typedef-name `%D' used as destructor declarator", @@ -3106,14 +3106,14 @@ cp_parser_unqualified_id (cp_parser* parser, Sets PARSER->SCOPE to the class (TYPE) or namespace (NAMESPACE_DECL) specified by the nested-name-specifier, or leaves it unchanged if there is no nested-name-specifier. Returns the new - scope iff there is a nested-name-specifier, or NULL_TREE otherwise. + scope iff there is a nested-name-specifier, or NULL_TREE otherwise. If IS_DECLARATION is TRUE, the nested-name-specifier is known to be part of a declaration and/or decl-specifier. */ static tree -cp_parser_nested_name_specifier_opt (cp_parser *parser, - bool typename_keyword_p, +cp_parser_nested_name_specifier_opt (cp_parser *parser, + bool typename_keyword_p, bool check_dependency_p, bool type_p, bool is_declaration) @@ -3125,7 +3125,7 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, /* If the next token corresponds to a nested name specifier, there is no need to reparse it. However, if CHECK_DEPENDENCY_P is - false, it may have been true before, in which case something + false, it may have been true before, in which case something like `A<X>::B<Y>::C' may have resulted in a nested-name-specifier of `A<X>::', where it should now be `A<X>::B<Y>::'. So, when CHECK_DEPENDENCY_P is false, we have to fall through into the @@ -3212,7 +3212,7 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, old_scope = parser->scope; saved_qualifying_scope = parser->qualifying_scope; /* Parse the qualifying entity. */ - new_scope + new_scope = cp_parser_class_or_namespace_name (parser, typename_keyword_p, template_keyword_p, @@ -3237,13 +3237,13 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, that is a `::', then any valid interpretation would have found a class-or-namespace-name. */ while (cp_lexer_next_token_is (parser->lexer, CPP_NAME) - && (cp_lexer_peek_nth_token (parser->lexer, 2)->type + && (cp_lexer_peek_nth_token (parser->lexer, 2)->type == CPP_SCOPE) - && (cp_lexer_peek_nth_token (parser->lexer, 3)->type + && (cp_lexer_peek_nth_token (parser->lexer, 3)->type != CPP_COMPL)) { token = cp_lexer_consume_token (parser->lexer); - if (!error_p) + if (!error_p) { tree decl; @@ -3252,8 +3252,8 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, error ("`%D' used without template parameters", decl); else - cp_parser_name_lookup_error - (parser, token->value, decl, + cp_parser_name_lookup_error + (parser, token->value, decl, "is not a class or namespace"); parser->scope = NULL_TREE; error_p = true; @@ -3276,7 +3276,7 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, success = true; /* Make sure we look in the right scope the next time through the loop. */ - parser->scope = (TREE_CODE (new_scope) == TYPE_DECL + parser->scope = (TREE_CODE (new_scope) == TYPE_DECL ? TREE_TYPE (new_scope) : new_scope); /* If it is a class scope, try to complete it; we are about to @@ -3303,7 +3303,7 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, { /* Find the token that corresponds to the start of the template-id. */ - token = cp_lexer_advance_token (parser->lexer, + token = cp_lexer_advance_token (parser->lexer, parser->lexer->first_token, start); @@ -3328,8 +3328,8 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, is present. */ static tree -cp_parser_nested_name_specifier (cp_parser *parser, - bool typename_keyword_p, +cp_parser_nested_name_specifier (cp_parser *parser, + bool typename_keyword_p, bool check_dependency_p, bool type_p, bool is_declaration) @@ -3371,7 +3371,7 @@ cp_parser_nested_name_specifier (cp_parser *parser, ERROR_MARK_NODE is returned. */ static tree -cp_parser_class_or_namespace_name (cp_parser *parser, +cp_parser_class_or_namespace_name (cp_parser *parser, bool typename_keyword_p, bool template_keyword_p, bool check_dependency_p, @@ -3395,7 +3395,7 @@ cp_parser_class_or_namespace_name (cp_parser *parser, only_class_p = template_keyword_p || (saved_scope && TYPE_P (saved_scope)); if (!only_class_p) cp_parser_parse_tentatively (parser); - scope = cp_parser_class_name (parser, + scope = cp_parser_class_name (parser, typename_keyword_p, template_keyword_p, type_p, @@ -3429,7 +3429,7 @@ cp_parser_class_or_namespace_name (cp_parser *parser, postfix-expression [ expression ] postfix-expression ( expression-list [opt] ) simple-type-specifier ( expression-list [opt] ) - typename :: [opt] nested-name-specifier identifier + typename :: [opt] nested-name-specifier identifier ( expression-list [opt] ) typename :: [opt] nested-name-specifier template [opt] template-id ( expression-list [opt] ) @@ -3447,7 +3447,7 @@ cp_parser_class_or_namespace_name (cp_parser *parser, typeid ( type-id ) GNU Extension: - + postfix-expression: ( type-id ) { initializer-list , [opt] } @@ -3491,7 +3491,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) of view of parsing. Begin by consuming the token identifying the cast. */ cp_lexer_consume_token (parser->lexer); - + /* New types cannot be defined in the cast. */ saved_message = parser->type_definition_forbidden_message; parser->type_definition_forbidden_message @@ -3521,7 +3521,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) && !(parser->in_offsetof_p && POINTER_TYPE_P (type))) { if (!parser->allow_non_integral_constant_expression_p) - return (cp_parser_non_integral_constant_expression + return (cp_parser_non_integral_constant_expression ("a cast to a type other than an integral or " "enumeration type")); parser->non_integral_constant_expression_p = true; @@ -3597,7 +3597,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) parser->type_definition_forbidden_message = saved_message; } break; - + case RID_TYPENAME: { bool template_p = false; @@ -3607,7 +3607,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) /* Consume the `typename' token. */ cp_lexer_consume_token (parser->lexer); /* Look for the optional `::' operator. */ - cp_parser_global_scope_opt (parser, + cp_parser_global_scope_opt (parser, /*current_scope_valid_p=*/false); /* Look for the nested-name-specifier. */ cp_parser_nested_name_specifier (parser, @@ -3629,7 +3629,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) id = cp_parser_identifier (parser); /* Create a TYPENAME_TYPE to represent the type to which the functional cast is being performed. */ - type = make_typename_type (parser->scope, id, + type = make_typename_type (parser->scope, id, /*complain=*/1); postfix_expression = cp_parser_functional_cast (parser, type); @@ -3646,12 +3646,12 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) that doesn't work we fall back to the primary-expression. */ cp_parser_parse_tentatively (parser); /* Look for the simple-type-specifier. */ - type = cp_parser_simple_type_specifier (parser, + type = cp_parser_simple_type_specifier (parser, CP_PARSER_FLAGS_NONE, /*identifier_p=*/false); /* Parse the cast itself. */ if (!cp_parser_error_occurred (parser)) - postfix_expression + postfix_expression = cp_parser_functional_cast (parser, type); /* If that worked, we're done. */ if (cp_parser_parse_definitely (parser)) @@ -3683,7 +3683,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) { bool non_constant_p; /* Parse the initializer-list. */ - initializer_list + initializer_list = cp_parser_initializer_list (parser, &non_constant_p); /* Allow a trailing `,'. */ if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA)) @@ -3700,14 +3700,14 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) if (pedantic) pedwarn ("ISO C++ forbids compound-literals"); /* Form the representation of the compound-literal. */ - postfix_expression + postfix_expression = finish_compound_literal (type, initializer_list); break; } } /* It must be a primary-expression. */ - postfix_expression = cp_parser_primary_expression (parser, + postfix_expression = cp_parser_primary_expression (parser, &idk, &qualifying_class); } @@ -3745,9 +3745,9 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) && TREE_CODE (postfix_expression) == IDENTIFIER_NODE && cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_PAREN)) /* It is not a Koenig lookup function call. */ - postfix_expression + postfix_expression = unqualified_name_lookup_error (postfix_expression); - + /* Peek at the next token. */ token = cp_lexer_peek_token (parser->lexer); @@ -3766,7 +3766,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) cp_parser_require (parser, CPP_CLOSE_SQUARE, "`]'"); /* Build the ARRAY_REF. */ - postfix_expression + postfix_expression = grok_array_decl (postfix_expression, index); idk = CP_ID_KIND_NONE; /* Array references are not permitted in @@ -3774,7 +3774,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) if (parser->integral_constant_expression_p) { if (!parser->allow_non_integral_constant_expression_p) - postfix_expression + postfix_expression = cp_parser_non_integral_constant_expression ("an array reference"); parser->non_integral_constant_expression_p = true; } @@ -3785,7 +3785,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) /* postfix-expression ( expression-list [opt] ) */ { bool koenig_p; - tree args = (cp_parser_parenthesized_expression_list + tree args = (cp_parser_parenthesized_expression_list (parser, false, /*non_constant_p=*/NULL)); if (args == error_mark_node) @@ -3793,14 +3793,14 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) postfix_expression = error_mark_node; break; } - + /* Function calls are not permitted in constant-expressions. */ if (parser->integral_constant_expression_p) { if (!parser->allow_non_integral_constant_expression_p) { - postfix_expression + postfix_expression = cp_parser_non_integral_constant_expression ("a function call"); break; } @@ -3816,14 +3816,14 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) || TREE_CODE (postfix_expression) == IDENTIFIER_NODE)) { koenig_p = true; - postfix_expression + postfix_expression = perform_koenig_lookup (postfix_expression, args); } else if (TREE_CODE (postfix_expression) == IDENTIFIER_NODE) postfix_expression = unqualified_fn_lookup_error (postfix_expression); } - + if (TREE_CODE (postfix_expression) == COMPONENT_REF) { tree instance = TREE_OPERAND (postfix_expression, 0); @@ -3843,9 +3843,9 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) if (BASELINK_P (fn)) postfix_expression - = (build_new_method_call - (instance, fn, args, NULL_TREE, - (idk == CP_ID_KIND_QUALIFIED + = (build_new_method_call + (instance, fn, args, NULL_TREE, + (idk == CP_ID_KIND_QUALIFIED ? LOOKUP_NONVIRTUAL : LOOKUP_NORMAL))); else postfix_expression @@ -3867,8 +3867,8 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) koenig_p); else /* All other function calls. */ - postfix_expression - = finish_call_expr (postfix_expression, args, + postfix_expression + = finish_call_expr (postfix_expression, args, /*disallow_virtual=*/false, koenig_p); @@ -3876,11 +3876,11 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) idk = CP_ID_KIND_NONE; } break; - + case CPP_DOT: case CPP_DEREF: - /* postfix-expression . template [opt] id-expression - postfix-expression . pseudo-destructor-name + /* postfix-expression . template [opt] id-expression + postfix-expression . pseudo-destructor-name postfix-expression -> template [opt] id-expression postfix-expression -> pseudo-destructor-name */ { @@ -3904,7 +3904,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) idk = CP_ID_KIND_NONE; /* Enter the scope corresponding to the type of the object given by the POSTFIX_EXPRESSION. */ - if (!dependent_p + if (!dependent_p && TREE_TYPE (postfix_expression) != NULL_TREE) { scope = TREE_TYPE (postfix_expression); @@ -3956,7 +3956,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) struct X { void f(); }; template <typename T> void f(T* t) { t->X::f(); } - + Even though "t" is dependent, "X::f" is not and has been resolved to a BASELINK; there is no need to include scope information. */ @@ -3966,7 +3966,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) if (parser->scope) idk = CP_ID_KIND_QUALIFIED; - if (name != error_mark_node + if (name != error_mark_node && !BASELINK_P (name) && parser->scope) { @@ -3975,7 +3975,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) parser->qualifying_scope = NULL_TREE; parser->object_scope = NULL_TREE; } - postfix_expression + postfix_expression = finish_class_member_access_expr (postfix_expression, name); } /* Otherwise, try the pseudo-destructor-name production. */ @@ -3987,7 +3987,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) /* Parse the pseudo-destructor-name. */ cp_parser_pseudo_destructor_name (parser, &s, &type); /* Form the call. */ - postfix_expression + postfix_expression = finish_pseudo_destructor_expr (postfix_expression, s, TREE_TYPE (type)); } @@ -4004,8 +4004,8 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) && !parser->in_offsetof_p) { if (!parser->allow_non_integral_constant_expression_p) - postfix_expression - = (cp_parser_non_integral_constant_expression + postfix_expression + = (cp_parser_non_integral_constant_expression (token_type == CPP_DEREF ? "'->'" : "`.'")); parser->non_integral_constant_expression_p = true; } @@ -4017,14 +4017,14 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) /* Consume the `++' token. */ cp_lexer_consume_token (parser->lexer); /* Generate a representation for the complete expression. */ - postfix_expression - = finish_increment_expr (postfix_expression, + postfix_expression + = finish_increment_expr (postfix_expression, POSTINCREMENT_EXPR); /* Increments may not appear in constant-expressions. */ if (parser->integral_constant_expression_p) { if (!parser->allow_non_integral_constant_expression_p) - postfix_expression + postfix_expression = cp_parser_non_integral_constant_expression ("an increment"); parser->non_integral_constant_expression_p = true; } @@ -4036,14 +4036,14 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) /* Consume the `--' token. */ cp_lexer_consume_token (parser->lexer); /* Generate a representation for the complete expression. */ - postfix_expression - = finish_increment_expr (postfix_expression, + postfix_expression + = finish_increment_expr (postfix_expression, POSTDECREMENT_EXPR); /* Decrements may not appear in constant-expressions. */ if (parser->integral_constant_expression_p) { if (!parser->allow_non_integral_constant_expression_p) - postfix_expression + postfix_expression = cp_parser_non_integral_constant_expression ("a decrement"); parser->non_integral_constant_expression_p = true; } @@ -4082,7 +4082,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) constant. */ static tree -cp_parser_parenthesized_expression_list (cp_parser* parser, +cp_parser_parenthesized_expression_list (cp_parser* parser, bool is_attribute_list, bool *non_constant_p) { @@ -4095,20 +4095,20 @@ cp_parser_parenthesized_expression_list (cp_parser* parser, if (!cp_parser_require (parser, CPP_OPEN_PAREN, "`('")) return error_mark_node; - + /* Consume expressions until there are no more. */ if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN)) while (true) { tree expr; - + /* At the beginning of attribute lists, check to see if the next token is an identifier. */ if (is_attribute_list && cp_lexer_peek_token (parser->lexer)->type == CPP_NAME) { cp_token *token; - + /* Consume the identifier. */ token = cp_lexer_consume_token (parser->lexer); /* Save the identifier. */ @@ -4120,7 +4120,7 @@ cp_parser_parenthesized_expression_list (cp_parser* parser, if (non_constant_p) { bool expr_non_constant_p; - expr = (cp_parser_constant_expression + expr = (cp_parser_constant_expression (parser, /*allow_non_constant_p=*/true, &expr_non_constant_p)); if (expr_non_constant_p) @@ -4142,7 +4142,7 @@ cp_parser_parenthesized_expression_list (cp_parser* parser, /* After the first item, attribute lists look the same as expression lists. */ is_attribute_list = false; - + get_comma:; /* If the next token isn't a `,', then we are done. */ if (cp_lexer_next_token_is_not (parser->lexer, CPP_COMMA)) @@ -4151,16 +4151,16 @@ cp_parser_parenthesized_expression_list (cp_parser* parser, /* Otherwise, consume the `,' and keep going. */ cp_lexer_consume_token (parser->lexer); } - + if (!cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'")) { int ending; - + skip_comma:; /* We try and resync to an unnested comma, as that will give the user better diagnostics. */ - ending = cp_parser_skip_to_closing_parenthesis (parser, - /*recovering=*/true, + ending = cp_parser_skip_to_closing_parenthesis (parser, + /*recovering=*/true, /*or_comma=*/true, /*consume_paren=*/true); if (ending < 0) @@ -4173,7 +4173,7 @@ cp_parser_parenthesized_expression_list (cp_parser* parser, expression_list = nreverse (expression_list); if (identifier) expression_list = tree_cons (NULL_TREE, identifier, expression_list); - + return expression_list; } @@ -4190,8 +4190,8 @@ cp_parser_parenthesized_expression_list (cp_parser* parser, or ERROR_MARK_NODE if the parse fails. */ static void -cp_parser_pseudo_destructor_name (cp_parser* parser, - tree* scope, +cp_parser_pseudo_destructor_name (cp_parser* parser, + tree* scope, tree* type) { bool nested_name_specifier_p; @@ -4199,22 +4199,22 @@ cp_parser_pseudo_destructor_name (cp_parser* parser, /* Look for the optional `::' operator. */ cp_parser_global_scope_opt (parser, /*current_scope_valid_p=*/true); /* Look for the optional nested-name-specifier. */ - nested_name_specifier_p + nested_name_specifier_p = (cp_parser_nested_name_specifier_opt (parser, /*typename_keyword_p=*/false, /*check_dependency_p=*/true, /*type_p=*/false, - /*is_declaration=*/true) + /*is_declaration=*/true) != NULL_TREE); /* Now, if we saw a nested-name-specifier, we might be doing the second production. */ - if (nested_name_specifier_p + if (nested_name_specifier_p && cp_lexer_next_token_is_keyword (parser->lexer, RID_TEMPLATE)) { /* Consume the `template' keyword. */ cp_lexer_consume_token (parser->lexer); /* Parse the template-id. */ - cp_parser_template_id (parser, + cp_parser_template_id (parser, /*template_keyword_p=*/true, /*check_dependency_p=*/false, /*is_declaration=*/true); @@ -4302,7 +4302,7 @@ cp_parser_unary_expression (cp_parser *parser, bool address_p) { tree operand; enum tree_code op; - + op = keyword == RID_ALIGNOF ? ALIGNOF_EXPR : SIZEOF_EXPR; /* Consume the token. */ cp_lexer_consume_token (parser->lexer); @@ -4320,7 +4320,7 @@ cp_parser_unary_expression (cp_parser *parser, bool address_p) case RID_DELETE: return cp_parser_delete_expression (parser); - + case RID_EXTENSION: { /* The saved value of the PEDANTIC flag. */ @@ -4410,7 +4410,7 @@ cp_parser_unary_expression (cp_parser *parser, bool address_p) /* Consume the operator token. */ token = cp_lexer_consume_token (parser->lexer); /* Parse the cast-expression. */ - cast_expression + cast_expression = cp_parser_cast_expression (parser, unary_operator == ADDR_EXPR); /* Now, build an appropriate representation. */ switch (unary_operator) @@ -4480,7 +4480,7 @@ cp_parser_unary_operator (cp_token* token) case CPP_NOT: return TRUTH_NOT_EXPR; - + case CPP_COMPL: return BIT_NOT_EXPR; @@ -4506,7 +4506,7 @@ cp_parser_new_expression (cp_parser* parser) tree initializer; /* Look for the optional `::' operator. */ - global_scope_p + global_scope_p = (cp_parser_global_scope_opt (parser, /*current_scope_valid_p=*/false) != NULL_TREE); @@ -4568,7 +4568,7 @@ cp_parser_new_placement (cp_parser* parser) tree expression_list; /* Parse the expression-list. */ - expression_list = (cp_parser_parenthesized_expression_list + expression_list = (cp_parser_parenthesized_expression_list (parser, false, /*non_constant_p=*/NULL)); return expression_list; @@ -4660,7 +4660,7 @@ cp_parser_new_declarator_opt (cp_parser* parser) direct-new-declarator: [ expression ] - direct-new-declarator [constant-expression] + direct-new-declarator [constant-expression] Returns an ARRAY_REF, following the same conventions as are documented for cp_parser_direct_declarator. */ @@ -4688,7 +4688,7 @@ cp_parser_direct_new_declarator (cp_parser* parser) enumeration type. */ if (!processing_template_decl) { - expression + expression = build_expr_type_conversion (WANT_INT | WANT_ENUM, expression, /*complain=*/true); @@ -4701,8 +4701,8 @@ cp_parser_direct_new_declarator (cp_parser* parser) } /* But all the other expressions must be. */ else - expression - = cp_parser_constant_expression (parser, + expression + = cp_parser_constant_expression (parser, /*allow_non_constant=*/false, NULL); /* Look for the closing `]'. */ @@ -4733,7 +4733,7 @@ cp_parser_new_initializer (cp_parser* parser) { tree expression_list; - expression_list = (cp_parser_parenthesized_expression_list + expression_list = (cp_parser_parenthesized_expression_list (parser, false, /*non_constant_p=*/NULL)); if (!expression_list) expression_list = void_zero_node; @@ -4820,18 +4820,18 @@ cp_parser_cast_expression (cp_parser *parser, bool address_p) the type-id, and it happens to be a class-specifier, then we will commit to the parse at that point, because we cannot undo the action that is done when creating a new class. So, - then we cannot back up and do a postfix-expression. + then we cannot back up and do a postfix-expression. Therefore, we scan ahead to the closing `)', and check to see if the token after the `)' is a `{'. If so, we are not - looking at a cast-expression. + looking at a cast-expression. Save tokens so that we can put them back. */ cp_lexer_save_tokens (parser->lexer); /* Skip tokens until the next token is a closing parenthesis. If we find the closing `)', and the next token is a `{', then we are looking at a compound-literal. */ - compound_literal_p + compound_literal_p = (cp_parser_skip_to_closing_parenthesis (parser, false, false, /*consume_paren=*/true) && cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)); @@ -4866,9 +4866,9 @@ cp_parser_cast_expression (cp_parser *parser, bool address_p) if (cp_parser_parse_definitely (parser)) { /* Warn about old-style casts, if so requested. */ - if (warn_old_style_cast - && !in_system_header - && !VOID_TYPE_P (type) + if (warn_old_style_cast + && !in_system_header + && !VOID_TYPE_P (type) && current_lang_name != lang_name_c) warning ("use of old-style cast"); @@ -4879,7 +4879,7 @@ cp_parser_cast_expression (cp_parser *parser, bool address_p) && !INTEGRAL_OR_ENUMERATION_TYPE_P (type)) { if (!parser->allow_non_integral_constant_expression_p) - return (cp_parser_non_integral_constant_expression + return (cp_parser_non_integral_constant_expression ("a casts to a type other than an integral or " "enumeration type")); parser->non_integral_constant_expression_p = true; @@ -4913,7 +4913,7 @@ cp_parser_pm_expression (cp_parser* parser) { CPP_EOF, ERROR_MARK } }; - return cp_parser_binary_expression (parser, map, + return cp_parser_binary_expression (parser, map, cp_parser_simple_cast_expression); } @@ -5160,9 +5160,9 @@ cp_parser_logical_or_expression (cp_parser* parser) This routine is used by cp_parser_assignment_expression. ? expression : assignment-expression - + GNU Extensions: - + ? : assignment-expression */ static tree @@ -5180,7 +5180,7 @@ cp_parser_question_colon_clause (cp_parser* parser, tree logical_or_expr) else /* Parse the expression. */ expr = cp_parser_expression (parser); - + /* The next token should be a `:'. */ cp_parser_require (parser, CPP_COLON, "`:'"); /* Parse the assignment-expression. */ @@ -5220,13 +5220,13 @@ cp_parser_assignment_expression (cp_parser* parser) conditional-expression. */ if (cp_lexer_next_token_is (parser->lexer, CPP_QUERY)) return cp_parser_question_colon_clause (parser, expr); - else + else { enum tree_code assignment_operator; /* If it's an assignment-operator, we're using the second production. */ - assignment_operator + assignment_operator = cp_parser_assignment_operator_opt (parser); if (assignment_operator != ERROR_MARK) { @@ -5243,8 +5243,8 @@ cp_parser_assignment_expression (cp_parser* parser) parser->non_integral_constant_expression_p = true; } /* Build the assignment expression. */ - expr = build_x_modify_expr (expr, - assignment_operator, + expr = build_x_modify_expr (expr, + assignment_operator, rhs); } } @@ -5255,11 +5255,11 @@ cp_parser_assignment_expression (cp_parser* parser) /* Parse an (optional) assignment-operator. - assignment-operator: one of - = *= /= %= += -= >>= <<= &= ^= |= + assignment-operator: one of + = *= /= %= += -= >>= <<= &= ^= |= GNU Extension: - + assignment-operator: one of <?= >?= @@ -5333,7 +5333,7 @@ cp_parser_assignment_operator_opt (cp_parser* parser) op = MAX_EXPR; break; - default: + default: /* Nothing else is an assignment operator. */ op = ERROR_MARK; } @@ -5363,7 +5363,7 @@ cp_parser_expression (cp_parser* parser) tree assignment_expression; /* Parse the next assignment-expression. */ - assignment_expression + assignment_expression = cp_parser_assignment_expression (parser); /* If this is the first assignment-expression, we can just save it away. */ @@ -5382,7 +5382,7 @@ cp_parser_expression (cp_parser* parser) if (parser->integral_constant_expression_p) { if (!parser->allow_non_integral_constant_expression_p) - expression + expression = cp_parser_non_integral_constant_expression ("a comma operator"); parser->non_integral_constant_expression_p = true; } @@ -5391,10 +5391,10 @@ cp_parser_expression (cp_parser* parser) return expression; } -/* Parse a constant-expression. +/* Parse a constant-expression. constant-expression: - conditional-expression + conditional-expression If ALLOW_NON_CONSTANT_P a non-constant expression is silently accepted. If ALLOW_NON_CONSTANT_P is true and the expression is not @@ -5402,7 +5402,7 @@ cp_parser_expression (cp_parser* parser) is false, NON_CONSTANT_P should be NULL. */ static tree -cp_parser_constant_expression (cp_parser* parser, +cp_parser_constant_expression (cp_parser* parser, bool allow_non_constant_p, bool *non_constant_p) { @@ -5430,7 +5430,7 @@ cp_parser_constant_expression (cp_parser* parser, /* Save the old settings. */ saved_integral_constant_expression_p = parser->integral_constant_expression_p; - saved_allow_non_integral_constant_expression_p + saved_allow_non_integral_constant_expression_p = parser->allow_non_integral_constant_expression_p; saved_non_integral_constant_expression_p = parser->non_integral_constant_expression_p; /* We are now parsing a constant-expression. */ @@ -5449,7 +5449,7 @@ cp_parser_constant_expression (cp_parser* parser, expression = cp_parser_assignment_expression (parser); /* Restore the old settings. */ parser->integral_constant_expression_p = saved_integral_constant_expression_p; - parser->allow_non_integral_constant_expression_p + parser->allow_non_integral_constant_expression_p = saved_allow_non_integral_constant_expression_p; if (allow_non_constant_p) *non_constant_p = parser->non_integral_constant_expression_p; @@ -5460,7 +5460,7 @@ cp_parser_constant_expression (cp_parser* parser, /* Statements [gram.stmt.stmt] */ -/* Parse a statement. +/* Parse a statement. statement: labeled-statement @@ -5540,7 +5540,7 @@ cp_parser_statement (cp_parser* parser, bool in_statement_expr_p) statement = cp_parser_compound_statement (parser, false); /* Everything else must be a declaration-statement or an - expression-statement. Try for the declaration-statement + expression-statement. Try for the declaration-statement first, unless we are looking at a `;', in which case we know that we have an expression-statement. */ if (!statement) @@ -5571,7 +5571,7 @@ cp_parser_statement (cp_parser* parser, bool in_statement_expr_p) default : statement GNU Extension: - + labeled-statement: case constant-expression ... constant-expression : statement @@ -5603,7 +5603,7 @@ cp_parser_labeled_statement (cp_parser* parser, bool in_statement_expr_p) /* Consume the `case' token. */ cp_lexer_consume_token (parser->lexer); /* Parse the constant-expression. */ - expr = cp_parser_constant_expression (parser, + expr = cp_parser_constant_expression (parser, /*allow_non_constant_p=*/false, NULL); @@ -5672,7 +5672,7 @@ cp_parser_expression_statement (cp_parser* parser, bool in_statement_expr_p) statement. */ if (cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON)) statement = cp_parser_expression (parser); - + /* Consume the final `;'. */ cp_parser_consume_semicolon_at_end_of_statement (parser); @@ -5687,7 +5687,7 @@ cp_parser_expression_statement (cp_parser* parser, bool in_statement_expr_p) statement = finish_expr_stmt (statement); else finish_stmt (); - + return statement; } @@ -5695,7 +5695,7 @@ cp_parser_expression_statement (cp_parser* parser, bool in_statement_expr_p) compound-statement: { statement-seq [opt] } - + Returns a COMPOUND_STMT representing the statement. */ static tree @@ -5745,7 +5745,7 @@ cp_parser_statement_seq_opt (cp_parser* parser, bool in_statement_expr_p) selection-statement: if ( condition ) statement if ( condition ) statement else statement - switch ( condition ) statement + switch ( condition ) statement Returns the new IF_STMT or SWITCH_STMT. */ @@ -5808,7 +5808,7 @@ cp_parser_selection_statement (cp_parser* parser) /* Consume the `else' keyword. */ cp_lexer_consume_token (parser->lexer); /* Parse the else-clause. */ - else_stmt + else_stmt = cp_parser_implicitly_scoped_statement (parser); finish_else_clause (statement); } @@ -5844,18 +5844,18 @@ cp_parser_selection_statement (cp_parser* parser) } } -/* Parse a condition. +/* Parse a condition. condition: expression - type-specifier-seq declarator = assignment-expression + type-specifier-seq declarator = assignment-expression GNU Extension: - + condition: - type-specifier-seq declarator asm-specification [opt] + type-specifier-seq declarator asm-specification [opt] attributes [opt] = assignment-expression - + Returns the expression that should be tested. */ static tree @@ -5883,7 +5883,7 @@ cp_parser_condition (cp_parser* parser) tree attributes; tree declarator; tree initializer = NULL_TREE; - + /* Parse the declarator. */ declarator = cp_parser_declarator (parser, CP_PARSER_DECLARATOR_NAMED, /*ctor_dtor_or_conv_p=*/NULL, @@ -5894,9 +5894,9 @@ cp_parser_condition (cp_parser* parser) asm_specification = cp_parser_asm_specification_opt (parser); /* If the next token is not an `=', then we might still be looking at an expression. For example: - + if (A(a).x) - + looks like a decl-specifier-seq and a declarator -- but then there is no `=', so this is an expression. */ cp_parser_require (parser, CPP_EQ, "`='"); @@ -5905,18 +5905,18 @@ cp_parser_condition (cp_parser* parser) if (cp_parser_parse_definitely (parser)) { /* Create the declaration. */ - decl = start_decl (declarator, type_specifiers, + decl = start_decl (declarator, type_specifiers, /*initialized_p=*/true, attributes, /*prefix_attributes=*/NULL_TREE); /* Parse the assignment-expression. */ initializer = cp_parser_assignment_expression (parser); - + /* Process the initializer. */ - cp_finish_decl (decl, - initializer, - asm_specification, + cp_finish_decl (decl, + initializer, + asm_specification, LOOKUP_ONLYCONVERTING); - + return convert_from_reference (decl); } } @@ -5954,7 +5954,7 @@ cp_parser_iteration_statement (cp_parser* parser) return error_mark_node; /* Remember whether or not we are already within an iteration - statement. */ + statement. */ in_iteration_statement_p = parser->in_iteration_statement_p; /* See what kind of keyword it is. */ @@ -6093,7 +6093,7 @@ cp_parser_for_init_statement (cp_parser* parser) break ; continue ; return expression [opt] ; - goto identifier ; + goto identifier ; GNU extension: @@ -6146,7 +6146,7 @@ cp_parser_jump_statement (cp_parser* parser) { tree expr; - /* If the next token is a `;', then there is no + /* If the next token is a `;', then there is no expression. */ if (cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON)) expr = cp_parser_expression (parser); @@ -6207,7 +6207,7 @@ cp_parser_declaration_statement (cp_parser* parser) declarations appearing in the dependent statement are out of scope after control passes that point. This function parses a statement, but ensures that is in its own scope, even if it is not a - compound-statement. + compound-statement. Returns the new statement. */ @@ -6280,7 +6280,7 @@ cp_parser_declaration_seq_opt (cp_parser* parser) || token->type == CPP_EOF) break; - if (token->type == CPP_SEMICOLON) + if (token->type == CPP_SEMICOLON) { /* A declaration consisting of a single semicolon is invalid. Allow it unless we're being pedantic. */ @@ -6317,7 +6317,7 @@ cp_parser_declaration_seq_opt (cp_parser* parser) explicit-instantiation explicit-specialization linkage-specification - namespace-definition + namespace-definition GNU extension: @@ -6331,6 +6331,10 @@ cp_parser_declaration (cp_parser* parser) cp_token token2; int saved_pedantic; + /* Set this here since we can be called after + pushing the linkage specification. */ + c_lex_string_translate = true; + /* Check for the `__extension__' keyword. */ if (cp_parser_extension_opt (parser, &saved_pedantic)) { @@ -6344,6 +6348,11 @@ cp_parser_declaration (cp_parser* parser) /* Try to figure out what kind of declaration is present. */ token1 = *cp_lexer_peek_token (parser->lexer); + + /* Don't translate the CPP_STRING in extern "C". */ + if (token1.keyword == RID_EXTERN) + c_lex_string_translate = false; + if (token1.type != CPP_EOF) token2 = *cp_lexer_peek_nth_token (parser->lexer, 2); @@ -6386,7 +6395,7 @@ cp_parser_declaration (cp_parser* parser) else if (token1.keyword == RID_NAMESPACE && (/* A named namespace definition. */ (token2.type == CPP_NAME - && (cp_lexer_peek_nth_token (parser->lexer, 3)->type + && (cp_lexer_peek_nth_token (parser->lexer, 3)->type == CPP_OPEN_BRACE)) /* An unnamed namespace definition. */ || token2.type == CPP_OPEN_BRACE)) @@ -6396,28 +6405,30 @@ cp_parser_declaration (cp_parser* parser) else /* Try to parse a block-declaration, or a function-definition. */ cp_parser_block_declaration (parser, /*statement_p=*/false); + + c_lex_string_translate = true; } -/* Parse a block-declaration. +/* Parse a block-declaration. block-declaration: simple-declaration asm-definition namespace-alias-definition using-declaration - using-directive + using-directive GNU Extension: block-declaration: - __extension__ block-declaration + __extension__ block-declaration label-declaration If STATEMENT_P is TRUE, then this block-declaration is occurring as part of a declaration-statement. */ static void -cp_parser_block_declaration (cp_parser *parser, +cp_parser_block_declaration (cp_parser *parser, bool statement_p) { cp_token *token1; @@ -6481,17 +6492,17 @@ cp_parser_block_declaration (cp_parser *parser, /* Parse a simple-declaration. simple-declaration: - decl-specifier-seq [opt] init-declarator-list [opt] ; + decl-specifier-seq [opt] init-declarator-list [opt] ; init-declarator-list: init-declarator - init-declarator-list , init-declarator + init-declarator-list , init-declarator If FUNCTION_DEFINITION_ALLOWED_P is TRUE, then we also recognize a function-definition as a simple-declaration. */ static void -cp_parser_simple_declaration (cp_parser* parser, +cp_parser_simple_declaration (cp_parser* parser, bool function_definition_allowed_p) { tree decl_specifiers; @@ -6507,7 +6518,7 @@ cp_parser_simple_declaration (cp_parser* parser, /* Parse the decl-specifier-seq. We have to keep track of whether or not the decl-specifier-seq declares a named class or enumeration type, since that is the only case in which the - init-declarator-list is allowed to be empty. + init-declarator-list is allowed to be empty. [dcl.dcl] @@ -6516,7 +6527,7 @@ cp_parser_simple_declaration (cp_parser* parser, the decl-specifier-seq contains either a class-specifier, an elaborated-type-specifier, or an enum-specifier. */ decl_specifiers - = cp_parser_decl_specifier_seq (parser, + = cp_parser_decl_specifier_seq (parser, CP_PARSER_FLAGS_OPTIONAL, &attributes, &declares_class_or_enum); @@ -6550,7 +6561,7 @@ cp_parser_simple_declaration (cp_parser* parser, /* Keep going until we hit the `;' at the end of the simple declaration. */ saw_declarator = false; - while (cp_lexer_next_token_is_not (parser->lexer, + while (cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON)) { cp_token *token; @@ -6644,7 +6655,7 @@ cp_parser_simple_declaration (cp_parser* parser, type-specifier function-specifier friend - typedef + typedef GNU Extension: @@ -6655,16 +6666,16 @@ cp_parser_simple_declaration (cp_parser* parser, appear in the source code. The TREE_VALUE of each node is the decl-specifier. For a keyword (such as `auto' or `friend'), the TREE_VALUE is simply the corresponding TREE_IDENTIFIER. For the - representation of a type-specifier, see cp_parser_type_specifier. + representation of a type-specifier, see cp_parser_type_specifier. If there are attributes, they will be stored in *ATTRIBUTES, - represented as described above cp_parser_attributes. + represented as described above cp_parser_attributes. If FRIEND_IS_NOT_CLASS_P is non-NULL, and the `friend' specifier appears, and the entity that will be a friend is not going to be a class, then *FRIEND_IS_NOT_CLASS_P will be set to TRUE. Note that even if *FRIEND_IS_NOT_CLASS_P is FALSE, the entity to which - friendship is granted might not be a class. + friendship is granted might not be a class. *DECLARES_CLASS_OR_ENUM is set to the bitwise or of the following flags: @@ -6677,15 +6688,15 @@ cp_parser_simple_declaration (cp_parser* parser, */ static tree -cp_parser_decl_specifier_seq (cp_parser* parser, - cp_parser_flags flags, +cp_parser_decl_specifier_seq (cp_parser* parser, + cp_parser_flags flags, tree* attributes, int* declares_class_or_enum) { tree decl_specs = NULL_TREE; bool friend_p = false; bool constructor_possible_p = !parser->in_declarator_p; - + /* Assume no class or enumeration type is declared. */ *declares_class_or_enum = 0; @@ -6737,7 +6748,7 @@ cp_parser_decl_specifier_seq (cp_parser* parser, case RID_EXPLICIT: decl_spec = cp_parser_function_specifier_opt (parser); break; - + /* decl-specifier: typedef */ case RID_TYPEDEF: @@ -6758,7 +6769,7 @@ cp_parser_decl_specifier_seq (cp_parser* parser, register static extern - mutable + mutable GNU Extension: thread */ @@ -6770,14 +6781,14 @@ cp_parser_decl_specifier_seq (cp_parser* parser, case RID_THREAD: decl_spec = cp_parser_storage_class_specifier_opt (parser); break; - + default: break; } /* Constructors are a special case. The `S' in `S()' is not a decl-specifier; it is the beginning of the declarator. */ - constructor_p = (!decl_spec + constructor_p = (!decl_spec && constructor_possible_p && cp_parser_constructor_declarator_p (parser, friend_p)); @@ -6816,7 +6827,7 @@ cp_parser_decl_specifier_seq (cp_parser* parser, only exceptions are the following: -- const or volatile can be combined with any other - type-specifier. + type-specifier. -- signed or unsigned can be combined with char, long, short, or int. @@ -6874,14 +6885,14 @@ cp_parser_decl_specifier_seq (cp_parser* parser, return nreverse (decl_specs); } -/* Parse an (optional) storage-class-specifier. +/* Parse an (optional) storage-class-specifier. storage-class-specifier: auto register static extern - mutable + mutable GNU Extension: @@ -6889,7 +6900,7 @@ cp_parser_decl_specifier_seq (cp_parser* parser, thread Returns an IDENTIFIER_NODE corresponding to the keyword used. */ - + static tree cp_parser_storage_class_specifier_opt (cp_parser* parser) { @@ -6909,7 +6920,7 @@ cp_parser_storage_class_specifier_opt (cp_parser* parser) } } -/* Parse an (optional) function-specifier. +/* Parse an (optional) function-specifier. function-specifier: inline @@ -6917,7 +6928,7 @@ cp_parser_storage_class_specifier_opt (cp_parser* parser) explicit Returns an IDENTIFIER_NODE corresponding to the keyword used. */ - + static tree cp_parser_function_specifier_opt (cp_parser* parser) { @@ -6994,13 +7005,13 @@ cp_parser_linkage_specification (cp_parser* parser) { bool saved_in_unbraced_linkage_specification_p; - saved_in_unbraced_linkage_specification_p + saved_in_unbraced_linkage_specification_p = parser->in_unbraced_linkage_specification_p; parser->in_unbraced_linkage_specification_p = true; have_extern_spec = true; cp_parser_declaration (parser); have_extern_spec = false; - parser->in_unbraced_linkage_specification_p + parser->in_unbraced_linkage_specification_p = saved_in_unbraced_linkage_specification_p; } @@ -7013,11 +7024,11 @@ cp_parser_linkage_specification (cp_parser* parser) /* Parse a conversion-function-id. conversion-function-id: - operator conversion-type-id + operator conversion-type-id Returns an IDENTIFIER_NODE representing the operator. */ -static tree +static tree cp_parser_conversion_function_id (cp_parser* parser) { tree type; @@ -7038,7 +7049,7 @@ cp_parser_conversion_function_id (cp_parser* parser) entities declared within the class are available in the conversion-type-id. For example, consider: - struct S { + struct S { typedef int I; operator I(); }; @@ -7095,7 +7106,7 @@ cp_parser_conversion_type_id (cp_parser* parser) /* Parse an (optional) conversion-declarator. conversion-declarator: - ptr-operator conversion-declarator [opt] + ptr-operator conversion-declarator [opt] Returns a representation of the declarator. See cp_parser_declarator for details. */ @@ -7110,7 +7121,7 @@ cp_parser_conversion_declarator_opt (cp_parser* parser) /* We don't know if there's a ptr-operator next, or not. */ cp_parser_parse_tentatively (parser); /* Try the ptr-operator. */ - code = cp_parser_ptr_operator (parser, &class_type, + code = cp_parser_ptr_operator (parser, &class_type, &cv_qualifier_seq); /* If it worked, look for more conversion-declarators. */ if (cp_parser_parse_definitely (parser)) @@ -7141,7 +7152,7 @@ cp_parser_conversion_declarator_opt (cp_parser* parser) /* Parse an (optional) ctor-initializer. ctor-initializer: - : mem-initializer-list + : mem-initializer-list Returns TRUE iff the ctor-initializer was actually present. */ @@ -7211,10 +7222,10 @@ cp_parser_mem_initializer_list (cp_parser* parser) /* Parse a mem-initializer. mem-initializer: - mem-initializer-id ( expression-list [opt] ) + mem-initializer-id ( expression-list [opt] ) GNU extension: - + mem-initializer: ( expression-list [opt] ) @@ -7228,7 +7239,7 @@ cp_parser_mem_initializer (cp_parser* parser) tree mem_initializer_id; tree expression_list; tree member; - + /* Find out what is being initialized. */ if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN)) { @@ -7241,14 +7252,14 @@ cp_parser_mem_initializer (cp_parser* parser) if (member && !DECL_P (member)) in_base_initializer = 1; - expression_list + expression_list = cp_parser_parenthesized_expression_list (parser, false, /*non_constant_p=*/NULL); if (!expression_list) expression_list = void_type_node; in_base_initializer = 0; - + return member ? build_tree_list (member, expression_list) : NULL_TREE; } @@ -7256,7 +7267,7 @@ cp_parser_mem_initializer (cp_parser* parser) mem-initializer-id: :: [opt] nested-name-specifier [opt] class-name - identifier + identifier Returns a TYPE indicating the class to be initializer for the first production. Returns an IDENTIFIER_NODE indicating the data member @@ -7270,9 +7281,9 @@ cp_parser_mem_initializer_id (cp_parser* parser) tree id; /* Look for the optional `::' operator. */ - global_scope_p - = (cp_parser_global_scope_opt (parser, - /*current_scope_valid_p=*/false) + global_scope_p + = (cp_parser_global_scope_opt (parser, + /*current_scope_valid_p=*/false) != NULL_TREE); /* Look for the optional nested-name-specifier. The simplest way to implement: @@ -7286,7 +7297,7 @@ cp_parser_mem_initializer_id (cp_parser* parser) is to assume that we have seen the `typename' keyword at this point. */ - nested_name_specifier_p + nested_name_specifier_p = (cp_parser_nested_name_specifier_opt (parser, /*typename_keyword_p=*/true, /*check_dependency_p=*/true, @@ -7306,7 +7317,7 @@ cp_parser_mem_initializer_id (cp_parser* parser) /* Otherwise, we could also be looking for an ordinary identifier. */ cp_parser_parse_tentatively (parser); /* Try a class-name. */ - id = cp_parser_class_name (parser, + id = cp_parser_class_name (parser, /*typename_keyword_p=*/true, /*template_keyword_p=*/false, /*type_p=*/false, @@ -7325,12 +7336,12 @@ cp_parser_mem_initializer_id (cp_parser* parser) /* Parse an operator-function-id. operator-function-id: - operator operator + operator operator Returns an IDENTIFIER_NODE for the operator which is a human-readable spelling of the identifier, e.g., `operator +'. */ -static tree +static tree cp_parser_operator_function_id (cp_parser* parser) { /* Look for the `operator' keyword. */ @@ -7348,13 +7359,13 @@ cp_parser_operator_function_id (cp_parser* parser) || ++ -- , ->* -> () [] GNU Extensions: - + operator: <? >? <?= >?= Returns an IDENTIFIER_NODE for the operator which is a human-readable spelling of the identifier, e.g., `operator +'. */ - + static tree cp_parser_operator (cp_parser* parser) { @@ -7391,7 +7402,7 @@ cp_parser_operator (cp_parser* parser) cp_lexer_consume_token (parser->lexer); /* Look for the `]' token. */ cp_parser_require (parser, CPP_CLOSE_SQUARE, "`]'"); - id = ansi_opname (op == NEW_EXPR + id = ansi_opname (op == NEW_EXPR ? VEC_NEW_EXPR : VEC_DELETE_EXPR); } /* Otherwise, we have the non-array variant. */ @@ -7436,7 +7447,7 @@ cp_parser_operator (cp_parser* parser) case CPP_COMPL: id = ansi_opname (BIT_NOT_EXPR); break; - + case CPP_NOT: id = ansi_opname (TRUTH_NOT_EXPR); break; @@ -7524,7 +7535,7 @@ cp_parser_operator (cp_parser* parser) case CPP_OR_OR: id = ansi_opname (TRUTH_ORIF_EXPR); break; - + case CPP_PLUS_PLUS: id = ansi_opname (POSTINCREMENT_EXPR); break; @@ -7598,18 +7609,18 @@ cp_parser_operator (cp_parser* parser) /* Parse a template-declaration. template-declaration: - export [opt] template < template-parameter-list > declaration + export [opt] template < template-parameter-list > declaration If MEMBER_P is TRUE, this template-declaration occurs within a - class-specifier. + class-specifier. The grammar rule given by the standard isn't correct. What is really meant is: template-declaration: - export [opt] template-parameter-list-seq + export [opt] template-parameter-list-seq decl-specifier-seq [opt] init-declarator [opt] ; - export [opt] template-parameter-list-seq + export [opt] template-parameter-list-seq function-definition template-parameter-list-seq: @@ -7693,7 +7704,7 @@ cp_parser_template_parameter (cp_parser* parser) template <typename T, typename T::X X> ... or: - + template <class C, class D*> ... Here, the first parameter is a type parameter, and the second is @@ -7709,13 +7720,13 @@ cp_parser_template_parameter (cp_parser* parser) token = cp_lexer_peek_nth_token (parser->lexer, 3); /* Now, see if the token looks like the end of a template parameter. */ - if (token->type == CPP_COMMA + if (token->type == CPP_COMMA || token->type == CPP_EQ || token->type == CPP_GREATER) return cp_parser_type_parameter (parser); } - /* Otherwise, it is a non-type parameter. + /* Otherwise, it is a non-type parameter. [temp.param] @@ -7723,7 +7734,7 @@ cp_parser_template_parameter (cp_parser* parser) template-parameter, the first non-nested `>' is taken as the end of the template parameter-list rather than a greater-than operator. */ - return + return cp_parser_parameter_declaration (parser, /*template_parm_p=*/true, /*parenthesized_p=*/NULL); } @@ -7736,8 +7747,8 @@ cp_parser_template_parameter (cp_parser* parser) typename identifier [opt] typename identifier [opt] = type-id template < template-parameter-list > class identifier [opt] - template < template-parameter-list > class identifier [opt] - = id-expression + template < template-parameter-list > class identifier [opt] + = id-expression Returns a TREE_LIST. The TREE_VALUE is itself a TREE_LIST. The TREE_PURPOSE is the default-argument, if any. The TREE_VALUE is @@ -7750,7 +7761,7 @@ cp_parser_type_parameter (cp_parser* parser) tree parameter; /* Look for a keyword to tell us what kind of parameter this is. */ - token = cp_parser_require (parser, CPP_KEYWORD, + token = cp_parser_require (parser, CPP_KEYWORD, "`class', `typename', or `template'"); if (!token) return error_mark_node; @@ -7800,7 +7811,7 @@ cp_parser_type_parameter (cp_parser* parser) cp_parser_require (parser, CPP_LESS, "`<'"); /* Parse the template-parameter-list. */ begin_template_parm_list (); - parameter_list + parameter_list = cp_parser_template_parameter_list (parser); parameter_list = end_template_parm_list (parameter_list); /* Look for the `>'. */ @@ -7820,7 +7831,7 @@ cp_parser_type_parameter (cp_parser* parser) /* Create the template parameter. */ parameter = finish_template_template_parm (class_type_node, identifier); - + /* If the next token is an `=', then there is a default-argument. */ if (cp_lexer_next_token_is (parser->lexer, CPP_EQ)) @@ -7830,7 +7841,7 @@ cp_parser_type_parameter (cp_parser* parser) /* Consume the `='. */ cp_lexer_consume_token (parser->lexer); /* Parse the id-expression. */ - default_argument + default_argument = cp_parser_id_expression (parser, /*template_keyword_p=*/false, /*check_dependency_p=*/true, @@ -7843,7 +7854,7 @@ cp_parser_type_parameter (cp_parser* parser) ; else /* Look up the name. */ - default_argument + default_argument = cp_parser_lookup_name (parser, default_argument, /*is_type=*/false, /*is_template=*/is_template, @@ -7868,7 +7879,7 @@ cp_parser_type_parameter (cp_parser* parser) "expected `class', `typename', or `template'"); parameter = error_mark_node; } - + return parameter; } @@ -7881,14 +7892,14 @@ cp_parser_type_parameter (cp_parser* parser) `template' keyword. In this case, a TEMPLATE_ID_EXPR will be returned. Otherwise, if the template-name names a function, or set of functions, returns a TEMPLATE_ID_EXPR. If the template-name - names a class, returns a TYPE_DECL for the specialization. + names a class, returns a TYPE_DECL for the specialization. If CHECK_DEPENDENCY_P is FALSE, names are looked up in uninstantiated templates. */ static tree -cp_parser_template_id (cp_parser *parser, - bool template_keyword_p, +cp_parser_template_id (cp_parser *parser, + bool template_keyword_p, bool check_dependency_p, bool is_declaration) { @@ -7922,7 +7933,7 @@ cp_parser_template_id (cp_parser *parser, finding a template-id. */ if ((next_token->type != CPP_NAME && next_token->keyword != RID_OPERATOR) || (next_token->type == CPP_NAME - && !cp_parser_nth_token_starts_template_argument_list_p + && !cp_parser_nth_token_starts_template_argument_list_p (parser, 2))) { cp_parser_error (parser, "expected template-id"); @@ -7955,14 +7966,14 @@ cp_parser_template_id (cp_parser *parser, return template; } - /* If we find the sequence `[:' after a template-name, it's probably + /* If we find the sequence `[:' after a template-name, it's probably a digraph-typo for `< ::'. Substitute the tokens and check if we can parse correctly the argument list. */ next_token = cp_lexer_peek_nth_token (parser->lexer, 1); next_token_2 = cp_lexer_peek_nth_token (parser->lexer, 2); - if (next_token->type == CPP_OPEN_SQUARE + if (next_token->type == CPP_OPEN_SQUARE && next_token->flags & DIGRAPH - && next_token_2->type == CPP_COLON + && next_token_2->type == CPP_COLON && !(next_token_2->flags & PREV_WHITE)) { cp_parser_parse_tentatively (parser); @@ -8015,9 +8026,9 @@ cp_parser_template_id (cp_parser *parser, template_id = build_min_nt (TEMPLATE_ID_EXPR, template, arguments); else if (DECL_CLASS_TEMPLATE_P (template) || DECL_TEMPLATE_TEMPLATE_PARM_P (template)) - template_id - = finish_template_type (template, arguments, - cp_lexer_next_token_is (parser->lexer, + template_id + = finish_template_type (template, arguments, + cp_lexer_next_token_is (parser->lexer, CPP_SCOPE)); else { @@ -8027,10 +8038,10 @@ cp_parser_template_id (cp_parser *parser, || TREE_CODE (template) == OVERLOAD || BASELINK_P (template)), 20010716); - + template_id = lookup_template_function (template, arguments); } - + /* Retrieve any deferred checks. Do not pop this access checks yet so the memory will not be reclaimed during token replacing below. */ access_check = get_deferred_access_checks (); @@ -8047,7 +8058,7 @@ cp_parser_template_id (cp_parser *parser, /* Find the token that corresponds to the start of the template-id. */ - token = cp_lexer_advance_token (parser->lexer, + token = cp_lexer_advance_token (parser->lexer, parser->lexer->first_token, start_of_id); @@ -8067,7 +8078,7 @@ cp_parser_template_id (cp_parser *parser, template-name: identifier - + The standard should actually say: template-name: @@ -8082,7 +8093,7 @@ cp_parser_template_id (cp_parser *parser, a.operator K<int>() the conversion-function-id is "operator K<int>", and K<int> is a type-id. - It is impossible to call a templated conversion-function-id with an + It is impossible to call a templated conversion-function-id with an explicit argument list, since the only allowed template parameter is the type to which it is converting. @@ -8101,8 +8112,8 @@ cp_parser_template_id (cp_parser *parser, names are looked up inside uninstantiated templates. */ static tree -cp_parser_template_name (cp_parser* parser, - bool template_keyword_p, +cp_parser_template_name (cp_parser* parser, + bool template_keyword_p, bool check_dependency_p, bool is_declaration, bool *is_identifier) @@ -8130,7 +8141,7 @@ cp_parser_template_name (cp_parser* parser, /* Look for the identifier. */ else identifier = cp_parser_identifier (parser); - + /* If we didn't find an identifier, we don't have a template-id. */ if (identifier == error_mark_node) return error_mark_node; @@ -8153,12 +8164,12 @@ cp_parser_template_name (cp_parser* parser, /* In a declaration, in a dependent context, we pretend that the "template" keyword was present in order to improve error recovery. For example, given: - + template <typename T> void f(T::X<int>); - + we want to treat "X<int>" as a template-id. */ - if (is_declaration - && !template_keyword_p + if (is_declaration + && !template_keyword_p && parser->scope && TYPE_P (parser->scope) && dependent_type_p (parser->scope)) { @@ -8222,7 +8233,7 @@ cp_parser_template_name (cp_parser* parser, /* If DECL is a template, then the name was a template-name. */ if (TREE_CODE (decl) == TEMPLATE_DECL) ; - else + else { /* The standard does not explicitly indicate whether a name that names a set of overloaded declarations, some of which are @@ -8233,7 +8244,7 @@ cp_parser_template_name (cp_parser* parser, if (TREE_CODE (fns) == OVERLOAD) { tree fn; - + for (fn = fns; fn; fn = OVL_NEXT (fn)) if (TREE_CODE (OVL_CURRENT (fn)) == TEMPLATE_DECL) break; @@ -8285,13 +8296,13 @@ cp_parser_template_argument_list (cp_parser* parser) if (n_args) /* Consume the comma. */ cp_lexer_consume_token (parser->lexer); - + /* Parse the template-argument. */ argument = cp_parser_template_argument (parser); if (n_args == alloced) { alloced *= 2; - + if (arg_ary == fixed_args) { arg_ary = xmalloc (sizeof (tree) * alloced); @@ -8308,7 +8319,7 @@ cp_parser_template_argument_list (cp_parser* parser) while (n_args--) TREE_VEC_ELT (vec, n_args) = arg_ary[n_args]; - + if (arg_ary != fixed_args) free (arg_ary); parser->in_template_argument_list_p = saved_in_template_argument_list_p; @@ -8325,7 +8336,7 @@ cp_parser_template_argument_list (cp_parser* parser) The representation is that of an assignment-expression, type-id, or id-expression -- except that the qualified id-expression is evaluated, so that the value returned is either a DECL or an - OVERLOAD. + OVERLOAD. Although the standard says "assignment-expression", it forbids throw-expressions or assignments in the template argument. @@ -8343,19 +8354,19 @@ cp_parser_template_argument (cp_parser* parser) tree qualifying_class; /* There's really no way to know what we're looking at, so we just - try each alternative in order. + try each alternative in order. [temp.arg] In a template-argument, an ambiguity between a type-id and an expression is resolved to a type-id, regardless of the form of - the corresponding template-parameter. + the corresponding template-parameter. Therefore, we try a type-id first. */ cp_parser_parse_tentatively (parser); argument = cp_parser_type_id (parser); /* If there was no error parsing the type-id but the next token is a '>>', - we probably found a typo for '> >'. But there are type-id which are + we probably found a typo for '> >'. But there are type-id which are also valid expressions. For instance: struct X { int operator >> (int); }; @@ -8386,7 +8397,7 @@ cp_parser_template_argument (cp_parser* parser) /* We're still not sure what the argument will be. */ cp_parser_parse_tentatively (parser); /* Try a template. */ - argument = cp_parser_id_expression (parser, + argument = cp_parser_id_expression (parser, /*template_keyword_p=*/false, /*check_dependency_p=*/true, &template_p, @@ -8476,7 +8487,7 @@ cp_parser_template_argument (cp_parser* parser) later. */ ; else if (address_p - && (TREE_CODE (argument) == OFFSET_REF + && (TREE_CODE (argument) == OFFSET_REF || TREE_CODE (argument) == SCOPE_REF)) /* A pointer-to-member. */ ; @@ -8499,12 +8510,12 @@ cp_parser_template_argument (cp_parser* parser) return error_mark_node; } /* If the argument wasn't successfully parsed as a type-id followed - by '>>', the argument can only be a constant expression now. + by '>>', the argument can only be a constant expression now. Otherwise, we try parsing the constant-expression tentatively, because the argument could really be a type-id. */ if (maybe_type_id) cp_parser_parse_tentatively (parser); - argument = cp_parser_constant_expression (parser, + argument = cp_parser_constant_expression (parser, /*allow_non_constant_p=*/false, /*non_constant_p=*/NULL); argument = fold_non_dependent_expr (argument); @@ -8516,7 +8527,7 @@ cp_parser_template_argument (cp_parser* parser) return argument; /* We did our best to parse the argument as a non type-id, but that was the only alternative that matched (albeit with a '>' after - it). We can assume it's just a typo from the user, and a + it). We can assume it's just a typo from the user, and a diagnostic will then be issued. */ return cp_parser_type_id (parser); } @@ -8524,23 +8535,23 @@ cp_parser_template_argument (cp_parser* parser) /* Parse an explicit-instantiation. explicit-instantiation: - template declaration + template declaration Although the standard says `declaration', what it really means is: explicit-instantiation: - template decl-specifier-seq [opt] declarator [opt] ; + template decl-specifier-seq [opt] declarator [opt] ; Things like `template int S<int>::i = 5, int S<double>::j;' are not supposed to be allowed. A defect report has been filed about this - issue. + issue. GNU Extension: - + explicit-instantiation: - storage-class-specifier template + storage-class-specifier template decl-specifier-seq [opt] declarator [opt] ; - function-specifier template + function-specifier template decl-specifier-seq [opt] declarator [opt] ; */ static void @@ -8555,7 +8566,7 @@ cp_parser_explicit_instantiation (cp_parser* parser) function-specifier. */ if (cp_parser_allow_gnu_extensions_p (parser)) { - extension_specifier + extension_specifier = cp_parser_storage_class_specifier_opt (parser); if (!extension_specifier) extension_specifier = cp_parser_function_specifier_opt (parser); @@ -8570,7 +8581,7 @@ cp_parser_explicit_instantiation (cp_parser* parser) control while processing explicit instantiation directives. */ push_deferring_access_checks (dk_no_check); /* Parse a decl-specifier-seq. */ - decl_specifiers + decl_specifiers = cp_parser_decl_specifier_seq (parser, CP_PARSER_FLAGS_OPTIONAL, &attributes, @@ -8595,15 +8606,15 @@ cp_parser_explicit_instantiation (cp_parser* parser) tree decl; /* Parse the declarator. */ - declarator + declarator = cp_parser_declarator (parser, CP_PARSER_DECLARATOR_NAMED, /*ctor_dtor_or_conv_p=*/NULL, /*parenthesized_p=*/NULL); - cp_parser_check_for_definition_in_return_type (declarator, + cp_parser_check_for_definition_in_return_type (declarator, declares_class_or_enum); if (declarator != error_mark_node) { - decl = grokdeclarator (declarator, decl_specifiers, + decl = grokdeclarator (declarator, decl_specifiers, NORMAL, 0, NULL); /* Turn access control back on for names used during template instantiation. */ @@ -8627,13 +8638,13 @@ cp_parser_explicit_instantiation (cp_parser* parser) /* Parse an explicit-specialization. explicit-specialization: - template < > declaration + template < > declaration Although the standard says `declaration', what it really means is: explicit-specialization: template <> decl-specifier [opt] init-declarator [opt] ; - template <> function-definition + template <> function-definition template <> explicit-specialization template <> template-declaration */ @@ -8664,7 +8675,7 @@ cp_parser_explicit_specialization (cp_parser* parser) } else /* Parse the dependent declaration. */ - cp_parser_single_declaration (parser, + cp_parser_single_declaration (parser, /*member_p=*/false, /*friend_p=*/NULL); @@ -8709,8 +8720,8 @@ cp_parser_explicit_specialization (cp_parser* parser) is set to FALSE. */ static tree -cp_parser_type_specifier (cp_parser* parser, - cp_parser_flags flags, +cp_parser_type_specifier (cp_parser* parser, + cp_parser_flags flags, bool is_friend, bool is_declaration, int* declares_class_or_enum, @@ -8793,7 +8804,7 @@ cp_parser_type_specifier (cp_parser* parser, /* If we do not already have a type-specifier, assume we are looking at a simple-type-specifier. */ - type_spec = cp_parser_simple_type_specifier (parser, flags, + type_spec = cp_parser_simple_type_specifier (parser, flags, /*identifier_p=*/true); /* If we didn't find a type-specifier, and a type-specifier was not @@ -8822,7 +8833,7 @@ cp_parser_type_specifier (cp_parser* parser, unsigned float double - void + void GNU Extension: @@ -8918,7 +8929,7 @@ cp_parser_simple_type_specifier (cp_parser* parser, cp_parser_flags flags, } /* The type-specifier must be a user-defined type. */ - if (!(flags & CP_PARSER_FLAGS_NO_USER_DEFINED_TYPES)) + if (!(flags & CP_PARSER_FLAGS_NO_USER_DEFINED_TYPES)) { /* Don't gobble tokens or issue error messages if this is an optional type-specifier. */ @@ -8936,11 +8947,11 @@ cp_parser_simple_type_specifier (cp_parser* parser, cp_parser_flags flags, /*is_declaration=*/false); /* If we have seen a nested-name-specifier, and the next token is `template', then we are using the template-id production. */ - if (parser->scope + if (parser->scope && cp_parser_optional_template_keyword (parser)) { /* Look for the template-id. */ - type = cp_parser_template_id (parser, + type = cp_parser_template_id (parser, /*template_keyword_p=*/true, /*check_dependency_p=*/true, /*is_declaration=*/false); @@ -8956,7 +8967,7 @@ cp_parser_simple_type_specifier (cp_parser* parser, cp_parser_flags flags, else type = cp_parser_type_name (parser); /* If it didn't work out, we don't have a TYPE. */ - if ((flags & CP_PARSER_FLAGS_OPTIONAL) + if ((flags & CP_PARSER_FLAGS_OPTIONAL) && !cp_parser_parse_definitely (parser)) type = NULL_TREE; } @@ -8982,13 +8993,13 @@ cp_parser_simple_type_specifier (cp_parser* parser, cp_parser_flags flags, type-name: class-name enum-name - typedef-name + typedef-name enum-name: identifier typedef-name: - identifier + identifier Returns a TYPE_DECL for the the type. */ @@ -9001,7 +9012,7 @@ cp_parser_type_name (cp_parser* parser) /* We can't know yet whether it is a class-name or not. */ cp_parser_parse_tentatively (parser); /* Try a class-name. */ - type_decl = cp_parser_class_name (parser, + type_decl = cp_parser_class_name (parser, /*typename_keyword_p=*/false, /*template_keyword_p=*/false, /*type_p=*/false, @@ -9015,14 +9026,14 @@ cp_parser_type_name (cp_parser* parser) identifier = cp_parser_identifier (parser); if (identifier == error_mark_node) return error_mark_node; - + /* Look up the type-name. */ type_decl = cp_parser_lookup_name_simple (parser, identifier); /* Issue an error if we did not find a type-name. */ if (TREE_CODE (type_decl) != TYPE_DECL) { if (!cp_parser_simulate_error (parser)) - cp_parser_name_lookup_error (parser, identifier, type_decl, + cp_parser_name_lookup_error (parser, identifier, type_decl, "is not a type"); type_decl = error_mark_node; } @@ -9034,7 +9045,7 @@ cp_parser_type_name (cp_parser* parser) && !parser->scope) maybe_note_name_used_in_class (identifier, type_decl); } - + return type_decl; } @@ -9047,14 +9058,14 @@ cp_parser_type_name (cp_parser* parser) class-key :: [opt] nested-name-specifier [opt] template [opt] template-id enum :: [opt] nested-name-specifier [opt] identifier typename :: [opt] nested-name-specifier identifier - typename :: [opt] nested-name-specifier template [opt] - template-id + typename :: [opt] nested-name-specifier template [opt] + template-id GNU extension: elaborated-type-specifier: class-key attributes :: [opt] nested-name-specifier [opt] identifier - class-key attributes :: [opt] nested-name-specifier [opt] + class-key attributes :: [opt] nested-name-specifier [opt] template [opt] template-id enum attributes :: [opt] nested-name-specifier [opt] identifier @@ -9066,8 +9077,8 @@ cp_parser_type_name (cp_parser* parser) Returns the TYPE specified. */ static tree -cp_parser_elaborated_type_specifier (cp_parser* parser, - bool is_friend, +cp_parser_elaborated_type_specifier (cp_parser* parser, + bool is_friend, bool is_declaration) { enum tag_types tag_type; @@ -9108,7 +9119,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, } /* Look for the `::' operator. */ - cp_parser_global_scope_opt (parser, + cp_parser_global_scope_opt (parser, /*current_scope_valid_p=*/false); /* Look for the nested-name-specifier. */ if (tag_type == typename_type) @@ -9117,7 +9128,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, /*typename_keyword_p=*/true, /*check_dependency_p=*/true, /*type_p=*/true, - is_declaration) + is_declaration) == error_mark_node) return error_mark_node; } @@ -9157,7 +9168,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, && tag_type == typename_type) type = make_typename_type (parser->scope, decl, /*complain=*/1); - else + else type = TREE_TYPE (decl); } @@ -9174,7 +9185,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, /* For a `typename', we needn't call xref_tag. */ if (tag_type == typename_type) - return cp_parser_make_typename_type (parser, parser->scope, + return cp_parser_make_typename_type (parser, parser->scope, identifier); /* Look up a qualified name in the usual way. */ if (parser->scope) @@ -9184,7 +9195,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, /* In an elaborated-type-specifier, names are assumed to name types, so we set IS_TYPE to TRUE when calling cp_parser_lookup_name. */ - decl = cp_parser_lookup_name (parser, identifier, + decl = cp_parser_lookup_name (parser, identifier, /*is_type=*/true, /*is_template=*/false, /*is_namespace=*/false, @@ -9211,7 +9222,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, processing_template_decl does not work here since it is always 1 for the above two cases. */ - decl = (cp_parser_maybe_treat_template_as_class + decl = (cp_parser_maybe_treat_template_as_class (decl, /*tag_name_p=*/is_friend && parser->num_template_parameter_lists)); @@ -9222,14 +9233,14 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, } if (TREE_CODE (TREE_TYPE (decl)) != TYPENAME_TYPE) - check_elaborated_type_specifier + check_elaborated_type_specifier (tag_type, decl, (parser->num_template_parameter_lists || DECL_SELF_REFERENCE_P (decl))); type = TREE_TYPE (decl); } - else + else { /* An elaborated-type-specifier sometimes introduces a new type and sometimes names an existing type. Normally, the rule is that it @@ -9241,7 +9252,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, the `struct S' in the body of `f' is the same `struct S' as in the global scope; the existing definition is used. However, if - there were no global declaration, this would introduce a new + there were no global declaration, this would introduce a new local class named `S'. An exception to this rule applies to the following code: @@ -9254,7 +9265,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, This exception only applies if the elaborated-type-specifier forms the complete declaration: - [class.name] + [class.name] A declaration consisting solely of `class-key identifier ;' is either a redeclaration of the name in the current scope or a @@ -9268,7 +9279,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, struct S { friend struct T; }; - `T' is not a new type in the scope of `S'. + `T' is not a new type in the scope of `S'. Also, `new struct S' or `sizeof (struct S)' never results in the definition of a new type; a new type can only be declared in a @@ -9278,11 +9289,11 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, if (attributes) warning ("type attributes are honored only at type definition"); - type = xref_tag (tag_type, identifier, + type = xref_tag (tag_type, identifier, /*attributes=*/NULL_TREE, - (is_friend + (is_friend || !is_declaration - || cp_lexer_next_token_is_not (parser->lexer, + || cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON)), parser->num_template_parameter_lists); } @@ -9350,7 +9361,7 @@ cp_parser_enum_specifier (cp_parser* parser) } /* Parse an enumerator-list. The enumerators all have the indicated - TYPE. + TYPE. enumerator-list: enumerator-definition @@ -9367,7 +9378,7 @@ cp_parser_enumerator_list (cp_parser* parser, tree type) cp_parser_enumerator_definition (parser, type); /* Peek at the next token. */ token = cp_lexer_peek_token (parser->lexer); - /* If it's not a `,', then we've reached the end of the + /* If it's not a `,', then we've reached the end of the list. */ if (token->type != CPP_COMMA) break; @@ -9389,7 +9400,7 @@ cp_parser_enumerator_list (cp_parser* parser, tree type) enumerator-definition: enumerator enumerator = constant-expression - + enumerator: identifier */ @@ -9404,7 +9415,7 @@ cp_parser_enumerator_definition (cp_parser* parser, tree type) identifier = cp_parser_identifier (parser); if (identifier == error_mark_node) return; - + /* Peek at the next token. */ token = cp_lexer_peek_token (parser->lexer); /* If it's an `=', then there's an explicit value. */ @@ -9413,7 +9424,7 @@ cp_parser_enumerator_definition (cp_parser* parser, tree type) /* Consume the `=' token. */ cp_lexer_consume_token (parser->lexer); /* Parse the value. */ - value = cp_parser_constant_expression (parser, + value = cp_parser_constant_expression (parser, /*allow_non_constant_p=*/false, NULL); } @@ -9449,14 +9460,14 @@ cp_parser_namespace_name (cp_parser* parser) [basic.lookup.udir] When looking up a namespace-name in a using-directive or alias - definition, only namespace names are considered. + definition, only namespace names are considered. And: [basic.lookup.qual] During the lookup of a name preceding the :: scope resolution - operator, object, function, and enumerator names are ignored. + operator, object, function, and enumerator names are ignored. (Note that cp_parser_class_or_namespace_name only calls this function if the token after the name is the scope resolution @@ -9473,7 +9484,7 @@ cp_parser_namespace_name (cp_parser* parser) cp_parser_error (parser, "expected namespace-name"); namespace_decl = error_mark_node; } - + return namespace_decl; } @@ -9481,7 +9492,7 @@ cp_parser_namespace_name (cp_parser* parser) namespace-definition: named-namespace-definition - unnamed-namespace-definition + unnamed-namespace-definition named-namespace-definition: original-namespace-definition @@ -9489,10 +9500,10 @@ cp_parser_namespace_name (cp_parser* parser) original-namespace-definition: namespace identifier { namespace-body } - + extension-namespace-definition: namespace original-namespace-name { namespace-body } - + unnamed-namespace-definition: namespace { namespace-body } */ @@ -9556,7 +9567,7 @@ cp_parser_namespace_alias_definition (cp_parser* parser) /* Look for the `=' token. */ cp_parser_require (parser, CPP_EQ, "`='"); /* Look for the qualified-namespace-specifier. */ - namespace_specifier + namespace_specifier = cp_parser_qualified_namespace_specifier (parser); /* Look for the `;' token. */ cp_parser_require (parser, CPP_SEMICOLON, "`;'"); @@ -9577,7 +9588,7 @@ static tree cp_parser_qualified_namespace_specifier (cp_parser* parser) { /* Look for the optional `::'. */ - cp_parser_global_scope_opt (parser, + cp_parser_global_scope_opt (parser, /*current_scope_valid_p=*/false); /* Look for the optional nested-name-specifier. */ @@ -9609,7 +9620,7 @@ cp_parser_using_declaration (cp_parser* parser) /* Look for the `using' keyword. */ cp_parser_require_keyword (parser, RID_USING, "`using'"); - + /* Peek at the next token. */ token = cp_lexer_peek_token (parser->lexer); /* See if it's `typename'. */ @@ -9622,15 +9633,15 @@ cp_parser_using_declaration (cp_parser* parser) } /* Look for the optional global scope qualification. */ - global_scope_p + global_scope_p = (cp_parser_global_scope_opt (parser, - /*current_scope_valid_p=*/false) + /*current_scope_valid_p=*/false) != NULL_TREE); /* If we saw `typename', or didn't see `::', then there must be a nested-name-specifier present. */ if (typename_p || !global_scope_p) - qscope = cp_parser_nested_name_specifier (parser, typename_p, + qscope = cp_parser_nested_name_specifier (parser, typename_p, /*check_dependency_p=*/true, /*type_p=*/false, /*is_declaration=*/true); @@ -9646,7 +9657,7 @@ cp_parser_using_declaration (cp_parser* parser) qscope = global_namespace; /* Parse the unqualified-id. */ - identifier = cp_parser_unqualified_id (parser, + identifier = cp_parser_unqualified_id (parser, /*template_keyword_p=*/false, /*check_dependency_p=*/true, /*declarator_p=*/true); @@ -9689,8 +9700,8 @@ cp_parser_using_declaration (cp_parser* parser) cp_parser_require (parser, CPP_SEMICOLON, "`;'"); } -/* Parse a using-directive. - +/* Parse a using-directive. + using-directive: using namespace :: [opt] nested-name-specifier [opt] namespace-name ; */ @@ -9726,7 +9737,7 @@ cp_parser_using_directive (cp_parser* parser) /* Parse an asm-definition. asm-definition: - asm ( string-literal ) ; + asm ( string-literal ) ; GNU Extension: @@ -9735,8 +9746,8 @@ cp_parser_using_directive (cp_parser* parser) asm volatile [opt] ( string-literal : asm-operand-list [opt] ) ; asm volatile [opt] ( string-literal : asm-operand-list [opt] : asm-operand-list [opt] ) ; - asm volatile [opt] ( string-literal : asm-operand-list [opt] - : asm-operand-list [opt] + asm volatile [opt] ( string-literal : asm-operand-list [opt] + : asm-operand-list [opt] : asm-operand-list [opt] ) ; */ static void @@ -9765,12 +9776,13 @@ cp_parser_asm_definition (cp_parser* parser) /* Look for the opening `('. */ cp_parser_require (parser, CPP_OPEN_PAREN, "`('"); /* Look for the string. */ + c_lex_string_translate = false; token = cp_parser_require (parser, CPP_STRING, "asm body"); if (!token) - return; + goto finish; string = token->value; /* If we're allowing GNU extensions, check for the extended assembly - syntax. Unfortunately, the `:' tokens need not be separated by + syntax. Unfortunately, the `:' tokens need not be separated by a space in C, and so, for compatibility, we tolerate that here too. Doing that means that we have to treat the `::' operator as two `:' tokens. */ @@ -9791,7 +9803,7 @@ cp_parser_asm_definition (cp_parser* parser) /* Consume the `:'. */ cp_lexer_consume_token (parser->lexer); /* Parse the output-operands. */ - if (cp_lexer_next_token_is_not (parser->lexer, + if (cp_lexer_next_token_is_not (parser->lexer, CPP_COLON) && cp_lexer_next_token_is_not (parser->lexer, CPP_SCOPE) @@ -9817,7 +9829,7 @@ cp_parser_asm_definition (cp_parser* parser) /* Consume the `:'. */ cp_lexer_consume_token (parser->lexer); /* Parse the output-operands. */ - if (cp_lexer_next_token_is_not (parser->lexer, + if (cp_lexer_next_token_is_not (parser->lexer, CPP_COLON) && cp_lexer_next_token_is_not (parser->lexer, CPP_SCOPE) @@ -9830,7 +9842,7 @@ cp_parser_asm_definition (cp_parser* parser) clobbers_p = true; /* Look for clobbers. */ - if (clobbers_p + if (clobbers_p || cp_lexer_next_token_is (parser->lexer, CPP_COLON)) { if (!clobbers_p) @@ -9851,8 +9863,8 @@ cp_parser_asm_definition (cp_parser* parser) /* Create the ASM_STMT. */ if (at_function_scope_p ()) { - asm_stmt = - finish_asm_stmt (volatile_p + asm_stmt = + finish_asm_stmt (volatile_p ? ridpointers[(int) RID_VOLATILE] : NULL_TREE, string, outputs, inputs, clobbers); /* If the extended syntax was not used, mark the ASM_STMT. */ @@ -9861,6 +9873,9 @@ cp_parser_asm_definition (cp_parser* parser) } else assemble_asm (string); + + finish: + c_lex_string_translate = true; } /* Declarators [gram.dcl.decl] */ @@ -9877,13 +9892,13 @@ cp_parser_asm_definition (cp_parser* parser) function-definition: decl-specifier-seq [opt] declarator ctor-initializer [opt] - function-body - decl-specifier-seq [opt] declarator function-try-block + function-body + decl-specifier-seq [opt] declarator function-try-block GNU Extension: function-definition: - __extension__ function-definition + __extension__ function-definition The DECL_SPECIFIERS and PREFIX_ATTRIBUTES apply to this declarator. Returns a representation of the entity declared. If MEMBER_P is TRUE, @@ -9900,8 +9915,8 @@ cp_parser_asm_definition (cp_parser* parser) is FALSE. */ static tree -cp_parser_init_declarator (cp_parser* parser, - tree decl_specifiers, +cp_parser_init_declarator (cp_parser* parser, + tree decl_specifiers, tree prefix_attributes, bool function_definition_allowed_p, bool member_p, @@ -9927,12 +9942,12 @@ cp_parser_init_declarator (cp_parser* parser, *function_definition_p = false; /* Defer access checks while parsing the declarator; we cannot know - what names are accessible until we know what is being + what names are accessible until we know what is being declared. */ resume_deferring_access_checks (); /* Parse the declarator. */ - declarator + declarator = cp_parser_declarator (parser, CP_PARSER_DECLARATOR_NAMED, &ctor_dtor_or_conv_p, /*parenthesized_p=*/NULL); @@ -9999,7 +10014,7 @@ cp_parser_init_declarator (cp_parser* parser, declarator, prefix_attributes); else - decl + decl = (cp_parser_function_definition_from_specifiers_and_declarator (parser, decl_specifiers, prefix_attributes, declarator)); @@ -10010,24 +10025,24 @@ cp_parser_init_declarator (cp_parser* parser, /* [dcl.dcl] Only in function declarations for constructors, destructors, and - type conversions can the decl-specifier-seq be omitted. + type conversions can the decl-specifier-seq be omitted. We explicitly postpone this check past the point where we handle function-definitions because we tolerate function-definitions that are missing their return types in some modes. */ if (!decl_specifiers && ctor_dtor_or_conv_p <= 0) { - cp_parser_error (parser, + cp_parser_error (parser, "expected constructor, destructor, or type conversion"); return error_mark_node; } /* An `=' or an `(' indicates an initializer. */ - is_initialized = (token->type == CPP_EQ + is_initialized = (token->type == CPP_EQ || token->type == CPP_OPEN_PAREN); /* If the init-declarator isn't initialized and isn't followed by a `,' or `;', it's not a valid init-declarator. */ - if (!is_initialized + if (!is_initialized && token->type != CPP_COMMA && token->type != CPP_SEMICOLON) { @@ -10081,7 +10096,7 @@ cp_parser_init_declarator (cp_parser* parser, /* Perform deferred access control checks, now that we know in which SCOPE the declared entity resides. */ - if (!member_p && decl) + if (!member_p && decl) { tree saved_current_function_decl = NULL_TREE; @@ -10093,7 +10108,7 @@ cp_parser_init_declarator (cp_parser* parser, saved_current_function_decl = current_function_decl; current_function_decl = decl; } - + /* Perform the access control checks for the declarator and the the decl-specifiers. */ perform_deferred_access_checks (); @@ -10105,7 +10120,7 @@ cp_parser_init_declarator (cp_parser* parser, /* Parse the initializer. */ if (is_initialized) - initializer = cp_parser_initializer (parser, + initializer = cp_parser_initializer (parser, &is_parenthesized_init, &is_non_constant_init); else @@ -10140,12 +10155,12 @@ cp_parser_init_declarator (cp_parser* parser, if (decl && TREE_CODE (decl) == FUNCTION_DECL) cp_parser_save_default_args (parser, decl); } - + /* Finish processing the declaration. But, skip friend declarations. */ if (!friend_p && decl) - cp_finish_decl (decl, - initializer, + cp_finish_decl (decl, + initializer, asm_specification, /* If the initializer is in parentheses, then this is a direct-initialization, which means that an @@ -10156,7 +10171,7 @@ cp_parser_init_declarator (cp_parser* parser, /* Remember whether or not variables were initialized by constant-expressions. */ - if (decl && TREE_CODE (decl) == VAR_DECL + if (decl && TREE_CODE (decl) == VAR_DECL && is_initialized && !is_non_constant_init) DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl) = true; @@ -10164,10 +10179,10 @@ cp_parser_init_declarator (cp_parser* parser, } /* Parse a declarator. - + declarator: direct-declarator - ptr-operator declarator + ptr-operator declarator abstract-declarator: ptr-operator abstract-declarator [opt] @@ -10177,12 +10192,12 @@ cp_parser_init_declarator (cp_parser* parser, declarator: attributes [opt] direct-declarator - attributes [opt] ptr-operator declarator + attributes [opt] ptr-operator declarator abstract-declarator: attributes [opt] ptr-operator abstract-declarator [opt] attributes [opt] direct-abstract-declarator - + Returns a representation of the declarator. If the declarator has the form `* declarator', then an INDIRECT_REF is returned, whose only operand is the sub-declarator. Analogously, `& declarator' is @@ -10208,21 +10223,21 @@ cp_parser_init_declarator (cp_parser* parser, to -1 if the declarator is a name, and +1 if it is a function. Otherwise it is set to zero. Usually you just want to test for >0, but internally the negative value is used. - + (The reason for CTOR_DTOR_OR_CONV_P is that a declaration must have a decl-specifier-seq unless it declares a constructor, destructor, or conversion. It might seem that we could check this condition in semantic analysis, rather than parsing, but that makes it difficult to handle something like `f()'. We want to notice that there are no decl-specifiers, and therefore realize that this is an - expression, not a declaration.) - + expression, not a declaration.) + If PARENTHESIZED_P is non-NULL, *PARENTHESIZED_P is set to true iff the declarator is a direct-declarator of the form "(...)". */ static tree -cp_parser_declarator (cp_parser* parser, - cp_parser_declarator_kind dcl_kind, +cp_parser_declarator (cp_parser* parser, + cp_parser_declarator_kind dcl_kind, int* ctor_dtor_or_conv_p, bool* parenthesized_p) { @@ -10240,15 +10255,15 @@ cp_parser_declarator (cp_parser* parser, if (cp_parser_allow_gnu_extensions_p (parser)) attributes = cp_parser_attributes_opt (parser); - + /* Peek at the next token. */ token = cp_lexer_peek_token (parser->lexer); - + /* Check for the ptr-operator production. */ cp_parser_parse_tentatively (parser); /* Parse the ptr-operator. */ - code = cp_parser_ptr_operator (parser, - &class_type, + code = cp_parser_ptr_operator (parser, + &class_type, &cv_qualifier_seq); /* If that worked, then we have a ptr-operator. */ if (cp_parser_parse_definitely (parser)) @@ -10272,10 +10287,10 @@ cp_parser_declarator (cp_parser* parser, if (dcl_kind != CP_PARSER_DECLARATOR_NAMED && !cp_parser_parse_definitely (parser)) declarator = NULL_TREE; - + /* Build the representation of the ptr-operator. */ if (code == INDIRECT_REF) - declarator = make_pointer_declarator (cv_qualifier_seq, + declarator = make_pointer_declarator (cv_qualifier_seq, declarator); else declarator = make_reference_declarator (cv_qualifier_seq, @@ -10296,7 +10311,7 @@ cp_parser_declarator (cp_parser* parser, if (attributes && declarator != error_mark_node) declarator = tree_cons (attributes, declarator, NULL_TREE); - + return declarator; } @@ -10305,14 +10320,14 @@ cp_parser_declarator (cp_parser* parser, direct-declarator: declarator-id direct-declarator ( parameter-declaration-clause ) - cv-qualifier-seq [opt] + cv-qualifier-seq [opt] exception-specification [opt] direct-declarator [ constant-expression [opt] ] - ( declarator ) + ( declarator ) direct-abstract-declarator: direct-abstract-declarator [opt] - ( parameter-declaration-clause ) + ( parameter-declaration-clause ) cv-qualifier-seq [opt] exception-specification [opt] direct-abstract-declarator [opt] [ constant-expression [opt] ] @@ -10347,7 +10362,7 @@ cp_parser_direct_declarator (cp_parser* parser, bool saved_default_arg_ok_p = parser->default_arg_ok_p; bool saved_in_declarator_p = parser->in_declarator_p; bool first = true; - + while (true) { /* Peek at the next token. */ @@ -10364,7 +10379,7 @@ cp_parser_direct_declarator (cp_parser* parser, template parameter `(T)' is a parameter-declaration-clause, and not a parenthesized named declarator. - + We first try and parse a parameter-declaration-clause, and then try a nested declarator (if FIRST is true). @@ -10387,7 +10402,7 @@ cp_parser_direct_declarator (cp_parser* parser, int i (int (3)); The former is a function-declaration; the latter is a - variable initialization. + variable initialization. Thus again, we try a parameter-declaration-clause, and if that fails, we back out and return. */ @@ -10396,7 +10411,7 @@ cp_parser_direct_declarator (cp_parser* parser, { tree params; unsigned saved_num_template_parameter_lists; - + cp_parser_parse_tentatively (parser); /* Consume the `('. */ @@ -10408,7 +10423,7 @@ cp_parser_direct_declarator (cp_parser* parser, parser->default_arg_ok_p = false; parser->in_declarator_p = true; } - + /* Inside the function parameter list, surrounding template-parameter-lists do not apply. */ saved_num_template_parameter_lists @@ -10437,7 +10452,7 @@ cp_parser_direct_declarator (cp_parser* parser, /* Parse the cv-qualifier-seq. */ cv_qualifiers = cp_parser_cv_qualifier_seq_opt (parser); /* And the exception-specification. */ - exception_specification + exception_specification = cp_parser_exception_specification_opt (parser); /* Create the function-declarator. */ @@ -10449,12 +10464,12 @@ cp_parser_direct_declarator (cp_parser* parser, return type, so are not those of the declared function. */ parser->default_arg_ok_p = false; - + /* Repeat the main loop. */ continue; } } - + /* If this is the first, we can try a parenthesized declarator. */ if (first) @@ -10463,13 +10478,13 @@ cp_parser_direct_declarator (cp_parser* parser, parser->default_arg_ok_p = saved_default_arg_ok_p; parser->in_declarator_p = saved_in_declarator_p; - + /* Consume the `('. */ cp_lexer_consume_token (parser->lexer); /* Parse the nested declarator. */ saved_in_type_id_in_expr_p = parser->in_type_id_in_expr_p; parser->in_type_id_in_expr_p = true; - declarator + declarator = cp_parser_declarator (parser, dcl_kind, ctor_dtor_or_conv_p, /*parenthesized_p=*/NULL); parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p; @@ -10479,7 +10494,7 @@ cp_parser_direct_declarator (cp_parser* parser, declarator = error_mark_node; if (declarator == error_mark_node) break; - + goto handle_declarator; } /* Otherwise, we must be done. */ @@ -10494,7 +10509,7 @@ cp_parser_direct_declarator (cp_parser* parser, if (ctor_dtor_or_conv_p) *ctor_dtor_or_conv_p = 0; - + first = false; parser->default_arg_ok_p = false; parser->in_declarator_p = true; @@ -10508,7 +10523,7 @@ cp_parser_direct_declarator (cp_parser* parser, { bool non_constant_p; - bounds + bounds = cp_parser_constant_expression (parser, /*allow_non_constant=*/true, &non_constant_p); @@ -10542,10 +10557,10 @@ cp_parser_direct_declarator (cp_parser* parser, declarator = error_mark_node; } } - + if (declarator == error_mark_node) break; - + if (TREE_CODE (declarator) == SCOPE_REF && !current_scope ()) { @@ -10554,14 +10569,14 @@ cp_parser_direct_declarator (cp_parser* parser, /* In the declaration of a member of a template class outside of the class itself, the SCOPE will sometimes be a TYPENAME_TYPE. For example, given: - + template <typename T> int S<T>::R::i = 3; - + the SCOPE will be a TYPENAME_TYPE for `S<T>::R'. In this context, we must resolve S<T>::R to an ordinary type, rather than a typename type. - + The reason we normally avoid resolving TYPENAME_TYPEs is that a specialization of `S' might render `S<T>::R' not a type. However, if `S' is @@ -10578,16 +10593,16 @@ cp_parser_direct_declarator (cp_parser* parser, if (type != error_mark_node) scope = type; /* Build a new DECLARATOR. */ - declarator = build_nt (SCOPE_REF, + declarator = build_nt (SCOPE_REF, scope, TREE_OPERAND (declarator, 1)); } } - - /* Check to see whether the declarator-id names a constructor, + + /* Check to see whether the declarator-id names a constructor, destructor, or conversion. */ - if (declarator && ctor_dtor_or_conv_p - && ((TREE_CODE (declarator) == SCOPE_REF + if (declarator && ctor_dtor_or_conv_p + && ((TREE_CODE (declarator) == SCOPE_REF && CLASS_TYPE_P (TREE_OPERAND (declarator, 0))) || (TREE_CODE (declarator) != SCOPE_REF && at_class_scope_p ()))) @@ -10649,11 +10664,11 @@ cp_parser_direct_declarator (cp_parser* parser, parser->default_arg_ok_p = saved_default_arg_ok_p; parser->in_declarator_p = saved_in_declarator_p; - + return declarator; } -/* Parse a ptr-operator. +/* Parse a ptr-operator. ptr-operator: * cv-qualifier-seq [opt] @@ -10667,14 +10682,14 @@ cp_parser_direct_declarator (cp_parser* parser, Returns INDIRECT_REF if a pointer, or pointer-to-member, was used. Returns ADDR_EXPR if a reference was used. In the - case of a pointer-to-member, *TYPE is filled in with the + case of a pointer-to-member, *TYPE is filled in with the TYPE containing the member. *CV_QUALIFIER_SEQ is filled in with the cv-qualifier-seq, or NULL_TREE, if there are no cv-qualifiers. Returns ERROR_MARK if an error occurred. */ - + static enum tree_code -cp_parser_ptr_operator (cp_parser* parser, - tree* type, +cp_parser_ptr_operator (cp_parser* parser, + tree* type, tree* cv_qualifier_seq) { enum tree_code code = ERROR_MARK; @@ -10700,7 +10715,7 @@ cp_parser_ptr_operator (cp_parser* parser, `&', if we are allowing GNU extensions. (The only qualifier that can legally appear after `&' is `restrict', but that is enforced during semantic analysis. */ - if (code == INDIRECT_REF + if (code == INDIRECT_REF || cp_parser_allow_gnu_extensions_p (parser)) *cv_qualifier_seq = cp_parser_cv_qualifier_seq_opt (parser); } @@ -10745,7 +10760,7 @@ cp_parser_ptr_operator (cp_parser* parser, /* Parse an (optional) cv-qualifier-seq. cv-qualifier-seq: - cv-qualifier cv-qualifier-seq [opt] + cv-qualifier cv-qualifier-seq [opt] Returns a TREE_LIST. The TREE_VALUE of each node is the representation of a cv-qualifier. */ @@ -10754,7 +10769,7 @@ static tree cp_parser_cv_qualifier_seq_opt (cp_parser* parser) { tree cv_qualifiers = NULL_TREE; - + while (true) { tree cv_qualifier; @@ -10766,7 +10781,7 @@ cp_parser_cv_qualifier_seq_opt (cp_parser* parser) break; /* Add this cv-qualifier to the list. */ - cv_qualifiers + cv_qualifiers = tree_cons (NULL_TREE, cv_qualifier, cv_qualifiers); } @@ -10778,7 +10793,7 @@ cp_parser_cv_qualifier_seq_opt (cp_parser* parser) cv-qualifier: const - volatile + volatile GNU Extension: @@ -10816,7 +10831,7 @@ cp_parser_cv_qualifier_opt (cp_parser* parser) declarator-id: id-expression - :: [opt] nested-name-specifier [opt] type-name + :: [opt] nested-name-specifier [opt] type-name In the `id-expression' case, the value returned is as for cp_parser_id_expression if the id-expression was an unqualified-id. @@ -10849,7 +10864,7 @@ cp_parser_declarator_id (cp_parser* parser) /*check_dependency_p=*/false, /*template_p=*/NULL, /*declarator_p=*/true); - /* If the name was qualified, create a SCOPE_REF to represent + /* If the name was qualified, create a SCOPE_REF to represent that. */ if (parser->scope) { @@ -10874,7 +10889,7 @@ cp_parser_type_id (cp_parser* parser) tree abstract_declarator; /* Parse the type-specifier-seq. */ - type_specifier_seq + type_specifier_seq = cp_parser_type_specifier_seq (parser); if (type_specifier_seq == error_mark_node) return error_mark_node; @@ -10882,7 +10897,7 @@ cp_parser_type_id (cp_parser* parser) /* There might or might not be an abstract declarator. */ cp_parser_parse_tentatively (parser); /* Look for the declarator. */ - abstract_declarator + abstract_declarator = cp_parser_declarator (parser, CP_PARSER_DECLARATOR_ABSTRACT, NULL, /*parenthesized_p=*/NULL); /* Check to see if there really was a declarator. */ @@ -10930,7 +10945,7 @@ cp_parser_type_specifier_seq (cp_parser* parser) if (seen_type_specifier) cp_parser_parse_tentatively (parser); /* Look for the type-specifier. */ - type_specifier = cp_parser_type_specifier (parser, + type_specifier = cp_parser_type_specifier (parser, CP_PARSER_FLAGS_NONE, /*is_friend=*/false, /*is_declaration=*/false, @@ -10946,7 +10961,7 @@ cp_parser_type_specifier_seq (cp_parser* parser) break; /* Add the new type-specifier to the list. */ - type_specifier_seq + type_specifier_seq = tree_cons (NULL_TREE, type_specifier, type_specifier_seq); seen_type_specifier = true; } @@ -10997,7 +11012,7 @@ cp_parser_parameter_declaration_clause (cp_parser* parser) } /* Check for `(void)', too, which is a special case. */ else if (token->keyword == RID_VOID - && (cp_lexer_peek_nth_token (parser->lexer, 2)->type + && (cp_lexer_peek_nth_token (parser->lexer, 2)->type == CPP_CLOSE_PAREN)) { /* Consume the `void' token. */ @@ -11005,7 +11020,7 @@ cp_parser_parameter_declaration_clause (cp_parser* parser) /* There are no parameters. */ return void_list_node; } - + /* Parse the parameter-declaration-list. */ parameters = cp_parser_parameter_declaration_list (parser); /* If a parse error occurred while parsing the @@ -11022,10 +11037,10 @@ cp_parser_parameter_declaration_clause (cp_parser* parser) /* Consume the `,'. */ cp_lexer_consume_token (parser->lexer); /* Expect an ellipsis. */ - ellipsis_p + ellipsis_p = (cp_parser_require (parser, CPP_ELLIPSIS, "`...'") != NULL); } - /* It might also be `...' if the optional trailing `,' was + /* It might also be `...' if the optional trailing `,' was omitted. */ else if (token->type == CPP_ELLIPSIS) { @@ -11062,8 +11077,8 @@ cp_parser_parameter_declaration_list (cp_parser* parser) tree parameter; bool parenthesized_p; /* Parse the parameter. */ - parameter - = cp_parser_parameter_declaration (parser, + parameter + = cp_parser_parameter_declaration (parser, /*template_parm_p=*/false, &parenthesized_p); @@ -11098,10 +11113,10 @@ cp_parser_parameter_declaration_list (cp_parser* parser) /* When parsing something like: int i(float f, double d) - + we can tell after seeing the declaration for "f" that we are not looking at an initialization of a variable "i", - but rather at the declaration of a function "i". + but rather at the declaration of a function "i". Due to the fact that the parsing of template arguments (as specified to a template-id) requires backtracking we @@ -11123,7 +11138,7 @@ cp_parser_parameter_declaration_list (cp_parser* parser) cp_parser_error (parser, "expected `,' or `...'"); if (!cp_parser_parsing_tentatively (parser) || cp_parser_committed_to_tentative_parse (parser)) - cp_parser_skip_to_closing_parenthesis (parser, + cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true, /*or_comma=*/false, /*consume_paren=*/false); @@ -11158,7 +11173,7 @@ cp_parser_parameter_declaration_list (cp_parser* parser) the declarator is of the form "(p)". */ static tree -cp_parser_parameter_declaration (cp_parser *parser, +cp_parser_parameter_declaration (cp_parser *parser, bool template_parm_p, bool *parenthesized_p) { @@ -11184,11 +11199,11 @@ cp_parser_parameter_declaration (cp_parser *parser, /* Type definitions may not appear in parameter types. */ saved_message = parser->type_definition_forbidden_message; - parser->type_definition_forbidden_message + parser->type_definition_forbidden_message = "types may not be defined in parameter types"; /* Parse the declaration-specifiers. */ - decl_specifiers + decl_specifiers = cp_parser_decl_specifier_seq (parser, CP_PARSER_FLAGS_NONE, &attributes, @@ -11205,7 +11220,7 @@ cp_parser_parameter_declaration (cp_parser *parser, token = cp_lexer_peek_token (parser->lexer); /* If the next token is a `)', `,', `=', `>', or `...', then there is no declarator. */ - if (token->type == CPP_CLOSE_PAREN + if (token->type == CPP_CLOSE_PAREN || token->type == CPP_COMMA || token->type == CPP_EQ || token->type == CPP_ELLIPSIS @@ -11220,7 +11235,7 @@ cp_parser_parameter_declaration (cp_parser *parser, { bool saved_default_arg_ok_p = parser->default_arg_ok_p; parser->default_arg_ok_p = false; - + /* After seeing a decl-specifier-seq, if the next token is not a "(", there is no possibility that the code is a valid expression. Therefore, if parsing tentatively, we commit at @@ -11261,7 +11276,7 @@ cp_parser_parameter_declaration (cp_parser *parser, /* If we are defining a class, then the tokens that make up the default argument must be saved and processed later. */ - if (!template_parm_p && at_class_scope_p () + if (!template_parm_p && at_class_scope_p () && TYPE_BEING_DEFINED (current_class_type)) { unsigned depth = 0; @@ -11326,7 +11341,7 @@ cp_parser_parameter_declaration (cp_parser *parser, case CPP_NAME: case CPP_SCOPE: /* In these cases, we should look for template-ids. - For example, if the default argument is + For example, if the default argument is `X<int, double>()', we need to do name lookup to figure out whether or not `X' is a template; if so, the `,' does not end the default argument. @@ -11341,7 +11356,7 @@ cp_parser_parameter_declaration (cp_parser *parser, /* If we've reached the end, stop. */ if (done) break; - + /* Add the token to the token block. */ token = cp_lexer_consume_token (parser->lexer); cp_token_cache_push_token (DEFARG_TOKENS (default_argument), @@ -11356,21 +11371,21 @@ cp_parser_parameter_declaration (cp_parser *parser, /* Make sure that PARSER->GREATER_THAN_IS_OPERATOR_P is set correctly. */ - saved_greater_than_is_operator_p + saved_greater_than_is_operator_p = parser->greater_than_is_operator_p; parser->greater_than_is_operator_p = greater_than_is_operator_p; /* Local variable names (and the `this' keyword) may not appear in a default argument. */ - saved_local_variables_forbidden_p + saved_local_variables_forbidden_p = parser->local_variables_forbidden_p; parser->local_variables_forbidden_p = true; /* Parse the assignment-expression. */ default_argument = cp_parser_assignment_expression (parser); /* Restore saved state. */ - parser->greater_than_is_operator_p + parser->greater_than_is_operator_p = saved_greater_than_is_operator_p; - parser->local_variables_forbidden_p - = saved_local_variables_forbidden_p; + parser->local_variables_forbidden_p + = saved_local_variables_forbidden_p; } if (!parser->default_arg_ok_p) { @@ -11385,11 +11400,11 @@ cp_parser_parameter_declaration (cp_parser *parser, } else default_argument = NULL_TREE; - + /* Create the representation of the parameter. */ if (attributes) decl_specifiers = tree_cons (attributes, NULL_TREE, decl_specifiers); - parameter = build_tree_list (default_argument, + parameter = build_tree_list (default_argument, build_tree_list (decl_specifiers, declarator)); @@ -11432,10 +11447,10 @@ cp_parser_ctor_initializer_opt_and_function_body (cp_parser *parser) initializer: = initializer-clause - ( expression-list ) + ( expression-list ) Returns a expression representing the initializer. If no - initializer is present, NULL_TREE is returned. + initializer is present, NULL_TREE is returned. *IS_PARENTHESIZED_INIT is set to TRUE if the `( expression-list )' production is used, and zero otherwise. *IS_PARENTHESIZED_INIT is @@ -11479,17 +11494,17 @@ cp_parser_initializer (cp_parser* parser, bool* is_parenthesized_init, return init; } -/* Parse an initializer-clause. +/* Parse an initializer-clause. initializer-clause: assignment-expression { initializer-list , [opt] } { } - Returns an expression representing the initializer. + Returns an expression representing the initializer. If the `assignment-expression' production is used the value - returned is simply a representation for the expression. + returned is simply a representation for the expression. Otherwise, a CONSTRUCTOR is returned. The CONSTRUCTOR_ELTS will be the elements of the initializer-list (or NULL_TREE, if the last @@ -11506,7 +11521,7 @@ cp_parser_initializer_clause (cp_parser* parser, bool* non_constant_p) /* If it is not a `{', then we are looking at an assignment-expression. */ if (cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_BRACE)) - initializer + initializer = cp_parser_constant_expression (parser, /*allow_non_constant_p=*/true, non_constant_p); @@ -11517,7 +11532,7 @@ cp_parser_initializer_clause (cp_parser* parser, bool* non_constant_p) /* Create a CONSTRUCTOR to represent the braced-initializer. */ initializer = make_node (CONSTRUCTOR); /* Mark it with TREE_HAS_CONSTRUCTOR. This should not be - necessary, but check_initializer depends upon it, for + necessary, but check_initializer depends upon it, for now. */ TREE_HAS_CONSTRUCTOR (initializer) = 1; /* If it's not a `}', then there is a non-trivial initializer. */ @@ -11544,7 +11559,7 @@ cp_parser_initializer_clause (cp_parser* parser, bool* non_constant_p) initializer-list , initializer-clause GNU Extension: - + initializer-list: identifier : initializer-clause initializer-list, identifier : initializer-clause @@ -11586,7 +11601,7 @@ cp_parser_initializer_list (cp_parser* parser, bool* non_constant_p) identifier = NULL_TREE; /* Parse the initializer. */ - initializer = cp_parser_initializer_clause (parser, + initializer = cp_parser_initializer_clause (parser, &clause_non_constant_p); /* If any clause is non-constant, so is the entire initializer. */ if (clause_non_constant_p) @@ -11637,9 +11652,9 @@ cp_parser_initializer_list (cp_parser* parser, bool* non_constant_p) Returns the TYPE_DECL representing the class. */ static tree -cp_parser_class_name (cp_parser *parser, - bool typename_keyword_p, - bool template_keyword_p, +cp_parser_class_name (cp_parser *parser, + bool typename_keyword_p, + bool template_keyword_p, bool type_p, bool check_dependency_p, bool class_head_p, @@ -11657,20 +11672,20 @@ cp_parser_class_name (cp_parser *parser, cp_parser_error (parser, "expected class-name"); return error_mark_node; } - + /* PARSER->SCOPE can be cleared when parsing the template-arguments to a template-id, so we save it here. */ scope = parser->scope; if (scope == error_mark_node) return error_mark_node; - + /* Any name names a type if we're following the `typename' keyword in a qualified name where the enclosing scope is type-dependent. */ typename_p = (typename_keyword_p && scope && TYPE_P (scope) && dependent_type_p (scope)); /* Handle the common case (an identifier, but not a template-id) efficiently. */ - if (token->type == CPP_NAME + if (token->type == CPP_NAME && !cp_parser_nth_token_starts_template_argument_list_p (parser, 2)) { tree identifier; @@ -11698,7 +11713,7 @@ cp_parser_class_name (cp_parser *parser, if (cp_lexer_next_token_is (parser->lexer, CPP_SCOPE)) type_p = true; /* Look up the name. */ - decl = cp_parser_lookup_name (parser, identifier, + decl = cp_parser_lookup_name (parser, identifier, type_p, /*is_template=*/false, /*is_namespace=*/false, @@ -11726,13 +11741,13 @@ cp_parser_class_name (cp_parser *parser, } /* Check to see that it is really the name of a class. */ - if (TREE_CODE (decl) == TEMPLATE_ID_EXPR + if (TREE_CODE (decl) == TEMPLATE_ID_EXPR && TREE_CODE (TREE_OPERAND (decl, 0)) == IDENTIFIER_NODE && cp_lexer_next_token_is (parser->lexer, CPP_SCOPE)) /* Situations like this: template <typename T> struct A { - typename T::template X<int>::I i; + typename T::template X<int>::I i; }; are problematic. Is `T::template X<int>' a class-name? The @@ -11795,8 +11810,8 @@ cp_parser_class_specifier (cp_parser* parser) ++parser->num_classes_being_defined; /* Inside the class, surrounding template-parameter-lists do not apply. */ - saved_num_template_parameter_lists - = parser->num_template_parameter_lists; + saved_num_template_parameter_lists + = parser->num_template_parameter_lists; parser->num_template_parameter_lists = 0; /* Start the class. */ @@ -11848,7 +11863,7 @@ cp_parser_class_specifier (cp_parser* parser) struct A::B { void f() { } }; there is no need to delay the parsing of `A::B::f'. */ - if (--parser->num_classes_being_defined == 0) + if (--parser->num_classes_being_defined == 0) { tree queue_entry; tree fn; @@ -11856,9 +11871,9 @@ cp_parser_class_specifier (cp_parser* parser) /* In a first pass, parse default arguments to the functions. Then, in a second pass, parse the bodies of the functions. This two-phased approach handles cases like: - - struct S { - void f() { g(); } + + struct S { + void f() { g(); } void g(int i = 3); }; @@ -11913,14 +11928,14 @@ cp_parser_class_specifier (cp_parser* parser) class-head: class-key identifier [opt] base-clause [opt] class-key nested-name-specifier identifier base-clause [opt] - class-key nested-name-specifier [opt] template-id - base-clause [opt] + class-key nested-name-specifier [opt] template-id + base-clause [opt] GNU Extensions: class-key attributes identifier [opt] base-clause [opt] class-key attributes nested-name-specifier identifier base-clause [opt] - class-key attributes nested-name-specifier [opt] template-id - base-clause [opt] + class-key attributes nested-name-specifier [opt] template-id + base-clause [opt] Returns the TYPE of the indicated class. Sets *NESTED_NAME_SPECIFIER_P to TRUE iff one of the productions @@ -11931,7 +11946,7 @@ cp_parser_class_specifier (cp_parser* parser) body of the class. */ static tree -cp_parser_class_head (cp_parser* parser, +cp_parser_class_head (cp_parser* parser, bool* nested_name_specifier_p) { cp_token *token; @@ -11963,7 +11978,7 @@ cp_parser_class_head (cp_parser* parser, /* If the next token is `::', that is invalid -- but sometimes people do try to write: - struct ::S {}; + struct ::S {}; Handle this gracefully by accepting the extra qualifier, and then issuing an error about it later if this really is a @@ -11976,7 +11991,7 @@ cp_parser_class_head (cp_parser* parser, /* Determine the name of the class. Begin by looking for an optional nested-name-specifier. */ - nested_name_specifier + nested_name_specifier = cp_parser_nested_name_specifier_opt (parser, /*typename_keyword_p=*/false, /*check_dependency_p=*/false, @@ -11989,16 +12004,16 @@ cp_parser_class_head (cp_parser* parser, /* Although the grammar says `identifier', it really means `class-name' or `template-name'. You are only allowed to define a class that has already been declared with this - syntax. + syntax. The proposed resolution for Core Issue 180 says that whever you see `class T::X' you should treat `X' as a type-name. - + It is OK to define an inaccessible class; for example: - + class A { class B; }; class A::B {}; - + We do not know if we will see a class-name, or a template-name. We look for a class-name first, in case the class-name is a template-id; if we looked for the @@ -12025,16 +12040,16 @@ cp_parser_class_head (cp_parser* parser, nested_name_specifier = NULL_TREE; /* Otherwise, count the number of templates used in TYPE and its containing scopes. */ - else + else { tree scope; - for (scope = TREE_TYPE (type); + for (scope = TREE_TYPE (type); scope && TREE_CODE (scope) != NAMESPACE_DECL; - scope = (TYPE_P (scope) + scope = (TYPE_P (scope) ? TYPE_CONTEXT (scope) - : DECL_CONTEXT (scope))) - if (TYPE_P (scope) + : DECL_CONTEXT (scope))) + if (TYPE_P (scope) && CLASS_TYPE_P (scope) && CLASSTYPE_TEMPLATE_INFO (scope) && PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (scope)) @@ -12049,7 +12064,7 @@ cp_parser_class_head (cp_parser* parser, an identifier, or nothing at all. */ cp_parser_parse_tentatively (parser); /* Check for a template-id. */ - id = cp_parser_template_id (parser, + id = cp_parser_template_id (parser, /*template_keyword_p=*/false, /*check_dependency_p=*/true, /*is_declaration=*/true); @@ -12123,7 +12138,7 @@ cp_parser_class_head (cp_parser* parser, } /* An explicit-specialization must be preceded by "template <>". If it is not, try to recover gracefully. */ - if (at_namespace_scope_p () + if (at_namespace_scope_p () && parser->num_template_parameter_lists == 0 && template_id_p) { @@ -12314,23 +12329,23 @@ cp_parser_member_specification_opt (cp_parser* parser) } } -/* Parse a member-declaration. +/* Parse a member-declaration. member-declaration: decl-specifier-seq [opt] member-declarator-list [opt] ; function-definition ; [opt] :: [opt] nested-name-specifier template [opt] unqualified-id ; using-declaration - template-declaration + template-declaration member-declarator-list: member-declarator member-declarator-list , member-declarator member-declarator: - declarator pure-specifier [opt] + declarator pure-specifier [opt] declarator constant-initializer [opt] - identifier [opt] : constant-expression + identifier [opt] : constant-expression GNU Extensions: @@ -12381,9 +12396,9 @@ cp_parser_member_declaration (cp_parser* parser) return; } - + /* Parse the decl-specifier-seq. */ - decl_specifiers + decl_specifiers = cp_parser_decl_specifier_seq (parser, CP_PARSER_FLAGS_OPTIONAL, &prefix_attributes, @@ -12409,10 +12424,10 @@ cp_parser_member_declaration (cp_parser* parser) if (pedantic) pedwarn ("extra semicolon"); } - else + else { tree type; - + /* See if this declaration is a friend. */ friend_p = cp_parser_friend_p (decl_specifiers); /* If there were decl-specifiers, check to see if there was @@ -12428,17 +12443,17 @@ cp_parser_member_declaration (cp_parser* parser) error ("a class-key must be used when declaring a friend"); /* In this case: - template <typename T> struct A { - friend struct A<T>::B; + template <typename T> struct A { + friend struct A<T>::B; }; - + A<T>::B will be represented by a TYPENAME_TYPE, and therefore not recognized by check_tag_decl. */ if (!type) { tree specifier; - for (specifier = decl_specifiers; + for (specifier = decl_specifiers; specifier; specifier = TREE_CHAIN (specifier)) { @@ -12488,7 +12503,7 @@ cp_parser_member_declaration (cp_parser* parser) /* See if these declarations will be friends. */ friend_p = cp_parser_friend_p (decl_specifiers); - /* Keep going until we hit the `;' at the end of the + /* Keep going until we hit the `;' at the end of the declaration. */ while (cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON)) { @@ -12501,7 +12516,7 @@ cp_parser_member_declaration (cp_parser* parser) /* Check for a bitfield declaration. */ if (token->type == CPP_COLON || (token->type == CPP_NAME - && cp_lexer_peek_nth_token (parser->lexer, 2)->type + && cp_lexer_peek_nth_token (parser->lexer, 2)->type == CPP_COLON)) { tree identifier; @@ -12518,7 +12533,7 @@ cp_parser_member_declaration (cp_parser* parser) /* Consume the `:' token. */ cp_lexer_consume_token (parser->lexer); /* Get the width of the bitfield. */ - width + width = cp_parser_constant_expression (parser, /*allow_non_constant=*/false, NULL); @@ -12532,7 +12547,7 @@ cp_parser_member_declaration (cp_parser* parser) attributes = chainon (prefix_attributes, attributes); /* Create the bitfield declaration. */ - decl = grokbitfield (identifier, + decl = grokbitfield (identifier, decl_specifiers, width); /* Apply the attributes. */ @@ -12546,7 +12561,7 @@ cp_parser_member_declaration (cp_parser* parser) int ctor_dtor_or_conv_p; /* Parse the declarator. */ - declarator + declarator = cp_parser_declarator (parser, CP_PARSER_DECLARATOR_NAMED, &ctor_dtor_or_conv_p, /*parenthesized_p=*/NULL); @@ -12568,7 +12583,7 @@ cp_parser_member_declaration (cp_parser* parser) return; } - cp_parser_check_for_definition_in_return_type + cp_parser_check_for_definition_in_return_type (declarator, declares_class_or_enum); /* Look for an asm-specification. */ @@ -12593,11 +12608,11 @@ cp_parser_member_declaration (cp_parser* parser) /* In [class.mem]: A pure-specifier shall be used only in the declaration of - a virtual function. + a virtual function. A member-declarator can contain a constant-initializer only if it declares a static member of integral or - enumeration type. + enumeration type. Therefore, if the DECLARATOR is for a function, we look for a pure-specifier; otherwise, we look for a @@ -12618,7 +12633,7 @@ cp_parser_member_declaration (cp_parser* parser) member-declarator. Calling `grokfield' has side-effects, so we must not do it unless we are sure that we are looking at a member-declarator. */ - if (cp_parser_token_starts_function_definition_p + if (cp_parser_token_starts_function_definition_p (cp_lexer_peek_token (parser->lexer))) { /* The grammar does not allow a pure-specifier to be @@ -12645,7 +12660,7 @@ cp_parser_member_declaration (cp_parser* parser) else { /* Create the declaration. */ - decl = grokfield (declarator, decl_specifiers, + decl = grokfield (declarator, decl_specifiers, initializer, asm_specification, attributes); /* Any initialization must have been from a @@ -12751,11 +12766,11 @@ cp_parser_constant_initializer (cp_parser* parser) cp_parser_skip_to_closing_brace (parser); /* Look for the trailing `}'. */ cp_parser_require (parser, CPP_CLOSE_BRACE, "`}'"); - + return error_mark_node; } - return cp_parser_constant_expression (parser, + return cp_parser_constant_expression (parser, /*allow_non_constant=*/false, NULL); } @@ -12765,7 +12780,7 @@ cp_parser_constant_initializer (cp_parser* parser) /* Parse a base-clause. base-clause: - : base-specifier-list + : base-specifier-list base-specifier-list: base-specifier @@ -12773,7 +12788,7 @@ cp_parser_constant_initializer (cp_parser* parser) Returns a TREE_LIST representing the base-classes, in the order in which they were declared. The representation of each node is as - described by cp_parser_base_specifier. + described by cp_parser_base_specifier. In the case that no bases are specified, this function will return NULL_TREE, not ERROR_MARK_NODE. */ @@ -12832,7 +12847,7 @@ cp_parser_base_clause (cp_parser* parser) ACCESS_{DEFAULT,PUBLIC,PROTECTED,PRIVATE}_[VIRTUAL]_NODE to indicate the specifiers provided. The TREE_VALUE will be a TYPE (or the ERROR_MARK_NODE) indicating the type that was specified. */ - + static tree cp_parser_base_specifier (cp_parser* parser) { @@ -12920,7 +12935,7 @@ cp_parser_base_specifier (cp_parser* parser) type name. is to pretend that we have seen the `typename' keyword at this - point. */ + point. */ cp_parser_nested_name_specifier_opt (parser, /*typename_keyword_p=*/true, /*check_dependency_p=*/true, @@ -12930,9 +12945,9 @@ cp_parser_base_specifier (cp_parser* parser) we see are type names or templates, as appropriate. */ class_scope_p = (parser->scope && TYPE_P (parser->scope)); template_p = class_scope_p && cp_parser_optional_template_keyword (parser); - + /* Finally, look for the class-name. */ - type = cp_parser_class_name (parser, + type = cp_parser_class_name (parser, class_scope_p, template_p, /*type_p=*/true, @@ -13071,7 +13086,7 @@ cp_parser_function_try_block (cp_parser* parser) /* Let the rest of the front-end know where we are. */ try_block = begin_function_try_block (); /* Parse the function-body. */ - ctor_initializer_p + ctor_initializer_p = cp_parser_ctor_initializer_opt_and_function_body (parser); /* We're done with the `try' part. */ finish_function_try_block (try_block); @@ -13132,7 +13147,7 @@ cp_parser_handler (cp_parser* parser) type-specifier-seq declarator type-specifier-seq abstract-declarator type-specifier-seq - ... + ... Returns a VAR_DECL for the declaration, or NULL_TREE if the ellipsis variant is used. */ @@ -13173,7 +13188,7 @@ cp_parser_exception_declaration (cp_parser* parser) return start_handler_parms (type_specifiers, declarator); } -/* Parse a throw-expression. +/* Parse a throw-expression. throw-expression: throw assignment-expression [opt] @@ -13222,7 +13237,7 @@ cp_parser_asm_specification_opt (cp_parser* parser) /* Peek at the next token. */ token = cp_lexer_peek_token (parser->lexer); - /* If the next token isn't the `asm' keyword, then there's no + /* If the next token isn't the `asm' keyword, then there's no asm-specification. */ if (!cp_parser_is_keyword (token, RID_ASM)) return NULL_TREE; @@ -13245,14 +13260,14 @@ cp_parser_asm_specification_opt (cp_parser* parser) return asm_specification; } -/* Parse an asm-operand-list. +/* Parse an asm-operand-list. asm-operand-list: asm-operand asm-operand-list , asm-operand - + asm-operand: - string-literal ( expression ) + string-literal ( expression ) [ string-literal ] string-literal ( expression ) Returns a TREE_LIST representing the operands. The TREE_VALUE of @@ -13272,14 +13287,16 @@ cp_parser_asm_operand_list (cp_parser* parser) tree expression; tree name; cp_token *token; - - if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_SQUARE)) + + c_lex_string_translate = false; + + if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_SQUARE)) { /* Consume the `[' token. */ cp_lexer_consume_token (parser->lexer); /* Read the operand name. */ name = cp_parser_identifier (parser); - if (name != error_mark_node) + if (name != error_mark_node) name = build_string (IDENTIFIER_LENGTH (name), IDENTIFIER_POINTER (name)); /* Look for the closing `]'. */ @@ -13290,17 +13307,19 @@ cp_parser_asm_operand_list (cp_parser* parser) /* Look for the string-literal. */ token = cp_parser_require (parser, CPP_STRING, "string-literal"); string_literal = token ? token->value : error_mark_node; + c_lex_string_translate = true; /* Look for the `('. */ cp_parser_require (parser, CPP_OPEN_PAREN, "`('"); /* Parse the expression. */ expression = cp_parser_expression (parser); /* Look for the `)'. */ cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'"); + c_lex_string_translate = false; /* Add this operand to the list. */ asm_operands = tree_cons (build_tree_list (name, string_literal), - expression, + expression, asm_operands); - /* If the next token is not a `,', there are no more + /* If the next token is not a `,', there are no more operands. */ if (cp_lexer_next_token_is_not (parser->lexer, CPP_COMMA)) break; @@ -13311,11 +13330,11 @@ cp_parser_asm_operand_list (cp_parser* parser) return nreverse (asm_operands); } -/* Parse an asm-clobber-list. +/* Parse an asm-clobber-list. asm-clobber-list: string-literal - asm-clobber-list , string-literal + asm-clobber-list , string-literal Returns a TREE_LIST, indicating the clobbers in the order that they appeared. The TREE_VALUE of each node is a STRING_CST. */ @@ -13335,7 +13354,7 @@ cp_parser_asm_clobber_list (cp_parser* parser) string_literal = token ? token->value : error_mark_node; /* Add it to the list. */ clobbers = tree_cons (NULL_TREE, string_literal, clobbers); - /* If the next token is not a `,', then the list is + /* If the next token is not a `,', then the list is complete. */ if (cp_lexer_next_token_is_not (parser->lexer, CPP_COMMA)) break; @@ -13352,10 +13371,10 @@ cp_parser_asm_clobber_list (cp_parser* parser) attributes attribute attribute: - __attribute__ (( attribute-list [opt] )) + __attribute__ (( attribute-list [opt] )) The return value is as for cp_parser_attribute_list. */ - + static tree cp_parser_attributes_opt (cp_parser* parser) { @@ -13399,17 +13418,17 @@ cp_parser_attributes_opt (cp_parser* parser) return attributes; } -/* Parse an attribute-list. +/* Parse an attribute-list. - attribute-list: - attribute + attribute-list: + attribute attribute-list , attribute attribute: - identifier + identifier identifier ( identifier ) identifier ( identifier , expression-list ) - identifier ( expression-list ) + identifier ( expression-list ) Returns a TREE_LIST. Each node corresponds to an attribute. THe TREE_PURPOSE of each node is the identifier indicating which @@ -13421,6 +13440,7 @@ cp_parser_attribute_list (cp_parser* parser) { tree attribute_list = NULL_TREE; + c_lex_string_translate = false; while (true) { cp_token *token; @@ -13430,12 +13450,12 @@ cp_parser_attribute_list (cp_parser* parser) /* Look for the identifier. We also allow keywords here; for example `__attribute__ ((const))' is legal. */ token = cp_lexer_peek_token (parser->lexer); - if (token->type != CPP_NAME + if (token->type != CPP_NAME && token->type != CPP_KEYWORD) return error_mark_node; /* Consume the token. */ token = cp_lexer_consume_token (parser->lexer); - + /* Save away the identifier that indicates which attribute this is. */ identifier = token->value; attribute = build_tree_list (identifier, NULL_TREE); @@ -13447,7 +13467,7 @@ cp_parser_attribute_list (cp_parser* parser) { tree arguments; - arguments = (cp_parser_parenthesized_expression_list + arguments = (cp_parser_parenthesized_expression_list (parser, true, /*non_constant_p=*/NULL)); /* Save the identifier and arguments away. */ TREE_VALUE (attribute) = arguments; @@ -13466,6 +13486,7 @@ cp_parser_attribute_list (cp_parser* parser) /* Consume the comma and keep going. */ cp_lexer_consume_token (parser->lexer); } + c_lex_string_translate = true; /* We built up the list in reverse order. */ return nreverse (attribute_list); @@ -13564,7 +13585,7 @@ cp_parser_label_declaration (cp_parser* parser) types. */ static tree -cp_parser_lookup_name (cp_parser *parser, tree name, +cp_parser_lookup_name (cp_parser *parser, tree name, bool is_type, bool is_template, bool is_namespace, bool check_dependency) { @@ -13619,10 +13640,10 @@ cp_parser_lookup_name (cp_parser *parser, tree name, stored in PARSER->SCOPE at this point. */ my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 20000619); - + /* Perform the lookup. */ if (parser->scope) - { + { bool dependent_p; if (parser->scope == error_mark_node) @@ -13689,7 +13710,7 @@ cp_parser_lookup_name (cp_parser *parser, tree name, name, /*protect=*/0, is_type); /* Look it up in the enclosing context, too. */ - decl = lookup_name_real (name, is_type, /*nonclass=*/0, + decl = lookup_name_real (name, is_type, /*nonclass=*/0, is_namespace, /*flags=*/0); parser->object_scope = object_type; @@ -13699,7 +13720,7 @@ cp_parser_lookup_name (cp_parser *parser, tree name, } else { - decl = lookup_name_real (name, is_type, /*nonclass=*/0, + decl = lookup_name_real (name, is_type, /*nonclass=*/0, is_namespace, /*flags=*/0); parser->qualifying_scope = NULL_TREE; @@ -13707,9 +13728,9 @@ cp_parser_lookup_name (cp_parser *parser, tree name, } /* If the lookup failed, let our caller know. */ - if (!decl + if (!decl || decl == error_mark_node - || (TREE_CODE (decl) == FUNCTION_DECL + || (TREE_CODE (decl) == FUNCTION_DECL && DECL_ANTICIPATED (decl))) return error_mark_node; @@ -13726,7 +13747,7 @@ cp_parser_lookup_name (cp_parser *parser, tree name, return error_mark_node; } - my_friendly_assert (DECL_P (decl) + my_friendly_assert (DECL_P (decl) || TREE_CODE (decl) == OVERLOAD || TREE_CODE (decl) == SCOPE_REF || TREE_CODE (decl) == UNBOUND_CLASS_TEMPLATE @@ -13736,7 +13757,7 @@ cp_parser_lookup_name (cp_parser *parser, tree name, /* If we have resolved the name of a member declaration, check to see if the declaration is accessible. When the name resolves to set of overloaded functions, accessibility is checked when - overload resolution is done. + overload resolution is done. During an explicit instantiation, access is not checked at all, as per [temp.explicit]. */ @@ -13753,7 +13774,7 @@ cp_parser_lookup_name (cp_parser *parser, tree name, static tree cp_parser_lookup_name_simple (cp_parser* parser, tree name) { - return cp_parser_lookup_name (parser, name, + return cp_parser_lookup_name (parser, name, /*is_type=*/false, /*is_template=*/false, /*is_namespace=*/false, @@ -13773,12 +13794,12 @@ cp_parser_maybe_treat_template_as_class (tree decl, bool tag_name_p) /* If the TEMPLATE_DECL is being declared as part of a class-head, the translation from TEMPLATE_DECL to TYPE_DECL occurs: - struct A { + struct A { template <typename T> struct B; }; - template <typename T> struct A::B {}; - + template <typename T> struct A::B {}; + Similarly, in a elaborated-type-specifier: namespace N { struct X{}; } @@ -13809,7 +13830,7 @@ cp_parser_maybe_treat_template_as_class (tree decl, bool tag_name_p) and FALSE otherwise. */ static bool -cp_parser_check_declarator_template_parameters (cp_parser* parser, +cp_parser_check_declarator_template_parameters (cp_parser* parser, tree declarator) { unsigned num_templates; @@ -13826,7 +13847,7 @@ cp_parser_check_declarator_template_parameters (cp_parser* parser, { tree main_declarator = TREE_OPERAND (declarator, 0); return - cp_parser_check_declarator_template_parameters (parser, + cp_parser_check_declarator_template_parameters (parser, main_declarator); } @@ -13850,11 +13871,11 @@ cp_parser_check_declarator_template_parameters (cp_parser* parser, /* You're supposed to have one `template <...>' for every template class, but you don't need one for a full specialization. For example: - + template <class T> struct S{}; template <> struct S<int> { void f(); }; void S<int>::f () {} - + is correct; there shouldn't be a `template <>' for the definition of `S<int>::f'. */ if (CLASSTYPE_TEMPLATE_INFO (scope) @@ -13875,7 +13896,7 @@ cp_parser_check_declarator_template_parameters (cp_parser* parser, if (TREE_CODE (declarator) == TEMPLATE_ID_EXPR) ++num_templates; - return cp_parser_check_template_parameters (parser, + return cp_parser_check_template_parameters (parser, num_templates); } } @@ -13890,7 +13911,7 @@ cp_parser_check_template_parameters (cp_parser* parser, { /* If there are more template classes than parameter lists, we have something like: - + template <class T> void S<T>::R<T>::f (); */ if (parser->num_template_parameter_lists < num_templates) { @@ -13926,8 +13947,8 @@ cp_parser_check_template_parameters (cp_parser* parser, the two sub-expressions. */ static tree -cp_parser_binary_expression (cp_parser* parser, - const cp_parser_token_tree_map token_tree_map, +cp_parser_binary_expression (cp_parser* parser, + const cp_parser_token_tree_map token_tree_map, cp_parser_expression_fn fn) { tree lhs; @@ -13950,7 +13971,7 @@ cp_parser_binary_expression (cp_parser* parser, break; /* If we find one of the tokens we want, build the corresponding tree representation. */ - for (map_node = token_tree_map; + for (map_node = token_tree_map; map_node->token_type != CPP_EOF; ++map_node) if (map_node->token_type == token->type) @@ -14044,7 +14065,7 @@ cp_parser_constructor_declarator_p (cp_parser *parser, bool friend_p) cp_parser_global_scope_opt (parser, /*current_scope_valid_p=*/false); /* Look for the nested-name-specifier. */ - nested_name_p + nested_name_p = (cp_parser_nested_name_specifier_opt (parser, /*typename_keyword_p=*/false, /*check_dependency_p=*/false, @@ -14053,7 +14074,7 @@ cp_parser_constructor_declarator_p (cp_parser *parser, bool friend_p) != NULL_TREE); /* Outside of a class-specifier, there must be a nested-name-specifier. */ - if (!nested_name_p && + if (!nested_name_p && (!at_class_scope_p () || !TYPE_BEING_DEFINED (current_class_type) || friend_p)) constructor_p = false; @@ -14093,7 +14114,7 @@ cp_parser_constructor_declarator_p (cp_parser *parser, bool friend_p) is a constructor. (It is actually a function named `f' that takes one parameter (of type `int') and returns a value of type `S::S'. */ - if (constructor_p + if (constructor_p && cp_parser_require (parser, CPP_OPEN_PAREN, "`('")) { if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN) @@ -14112,7 +14133,7 @@ cp_parser_constructor_declarator_p (cp_parser *parser, bool friend_p) type = TREE_TYPE (type_decl); if (TREE_CODE (type) == TYPENAME_TYPE) { - type = resolve_typename_type (type, + type = resolve_typename_type (type, /*only_current_p=*/false); if (type == error_mark_node) { @@ -14172,8 +14193,8 @@ cp_parser_function_definition_from_specifiers_and_declarator bool success_p; /* Begin the function-definition. */ - success_p = begin_function_definition (decl_specifiers, - attributes, + success_p = begin_function_definition (decl_specifiers, + attributes, declarator); /* If there were names looked up in the decl-specifier-seq that we @@ -14203,8 +14224,8 @@ cp_parser_function_definition_from_specifiers_and_declarator Returns the function defined. */ -static tree -cp_parser_function_definition_after_declarator (cp_parser* parser, +static tree +cp_parser_function_definition_after_declarator (cp_parser* parser, bool inline_p) { tree fn; @@ -14231,13 +14252,13 @@ cp_parser_function_definition_after_declarator (cp_parser* parser, } /* The `extern' in `extern "C" void f () { ... }' does not apply to anything declared inside `f'. */ - saved_in_unbraced_linkage_specification_p + saved_in_unbraced_linkage_specification_p = parser->in_unbraced_linkage_specification_p; parser->in_unbraced_linkage_specification_p = false; /* Inside the function, surrounding template-parameter-lists do not apply. */ - saved_num_template_parameter_lists - = parser->num_template_parameter_lists; + saved_num_template_parameter_lists + = parser->num_template_parameter_lists; parser->num_template_parameter_lists = 0; /* If the next token is `try', then we are looking at a function-try-block. */ @@ -14246,18 +14267,18 @@ cp_parser_function_definition_after_declarator (cp_parser* parser, /* A function-try-block includes the function-body, so we only do this next part if we're not processing a function-try-block. */ else - ctor_initializer_p + ctor_initializer_p = cp_parser_ctor_initializer_opt_and_function_body (parser); /* Finish the function. */ - fn = finish_function ((ctor_initializer_p ? 1 : 0) | + fn = finish_function ((ctor_initializer_p ? 1 : 0) | (inline_p ? 2 : 0)); /* Generate code for it, if necessary. */ expand_or_defer_fn (fn); /* Restore the saved values. */ - parser->in_unbraced_linkage_specification_p + parser->in_unbraced_linkage_specification_p = saved_in_unbraced_linkage_specification_p; - parser->num_template_parameter_lists + parser->num_template_parameter_lists = saved_num_template_parameter_lists; return fn; @@ -14277,11 +14298,11 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p) /* Look for the `template' keyword. */ if (!cp_parser_require_keyword (parser, RID_TEMPLATE, "`template'")) return; - + /* And the `<'. */ if (!cp_parser_require (parser, CPP_LESS, "`<'")) return; - + /* If the next token is `>', then we have an invalid specialization. Rather than complain about an invalid template parameter, issue an error message here. */ @@ -14305,7 +14326,7 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p) ++parser->num_template_parameter_lists; /* If the next token is `template', there are more template parameters. */ - if (cp_lexer_next_token_is_keyword (parser->lexer, + if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TEMPLATE)) cp_parser_template_declaration_after_export (parser, member_p); else @@ -14340,11 +14361,11 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p) /* If DECL is a function template, we must return to parse it later. (Even though there is no definition, there might be default arguments that need handling.) */ - if (member_p && decl + if (member_p && decl && (TREE_CODE (decl) == FUNCTION_DECL || DECL_FUNCTION_TEMPLATE_P (decl))) TREE_VALUE (parser->unparsed_functions_queues) - = tree_cons (NULL_TREE, decl, + = tree_cons (NULL_TREE, decl, TREE_VALUE (parser->unparsed_functions_queues)); } @@ -14356,7 +14377,7 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p) *FRIEND_P is set to TRUE iff the declaration is a friend. */ static tree -cp_parser_single_declaration (cp_parser* parser, +cp_parser_single_declaration (cp_parser* parser, bool member_p, bool* friend_p) { @@ -14371,7 +14392,7 @@ cp_parser_single_declaration (cp_parser* parser, /* Try the `decl-specifier-seq [opt] init-declarator [opt]' alternative. */ - decl_specifiers + decl_specifiers = cp_parser_decl_specifier_seq (parser, CP_PARSER_FLAGS_OPTIONAL, &attributes, @@ -14404,7 +14425,7 @@ cp_parser_single_declaration (cp_parser* parser, if (!decl && (cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON) || !value_member (error_mark_node, decl_specifiers))) - decl = cp_parser_init_declarator (parser, + decl = cp_parser_init_declarator (parser, decl_specifiers, attributes, /*function_definition_allowed_p=*/true, @@ -14443,7 +14464,7 @@ cp_parser_functional_cast (cp_parser* parser, tree type) { tree expression_list; - expression_list + expression_list = cp_parser_parenthesized_expression_list (parser, false, /*non_constant_p=*/NULL); @@ -14471,7 +14492,7 @@ cp_parser_save_member_function_body (cp_parser* parser, if (fn == error_mark_node) { /* If there's a function-body, skip it. */ - if (cp_parser_token_starts_function_definition_p + if (cp_parser_token_starts_function_definition_p (cp_lexer_peek_token (parser->lexer))) cp_parser_skip_to_end_of_block_or_statement (parser); return error_mark_node; @@ -14482,7 +14503,7 @@ cp_parser_save_member_function_body (cp_parser* parser, /* Create a token cache. */ cache = cp_token_cache_new (); - /* Save away the tokens that make up the body of the + /* Save away the tokens that make up the body of the function. */ cp_parser_cache_group (parser, cache, CPP_CLOSE_BRACE, /*depth=*/0); /* Handle function try blocks. */ @@ -14503,7 +14524,7 @@ cp_parser_save_member_function_body (cp_parser* parser, /* Add FN to the queue of functions to be parsed later. */ TREE_VALUE (parser->unparsed_functions_queues) - = tree_cons (NULL_TREE, fn, + = tree_cons (NULL_TREE, fn, TREE_VALUE (parser->unparsed_functions_queues)); return fn; @@ -14527,7 +14548,7 @@ cp_parser_enclosed_template_argument_list (cp_parser* parser) When parsing a template-id, the first non-nested `>' is taken as the end of the template-argument-list rather than a greater-than operator. */ - saved_greater_than_is_operator_p + saved_greater_than_is_operator_p = parser->greater_than_is_operator_p; parser->greater_than_is_operator_p = false; /* Parsing the argument list may modify SCOPE, so we save it @@ -14566,7 +14587,7 @@ cp_parser_enclosed_template_argument_list (cp_parser* parser) else if (!cp_parser_require (parser, CPP_GREATER, "`>'")) error ("missing `>' to terminate the template argument list"); /* The `>' token might be a greater-than operator again now. */ - parser->greater_than_is_operator_p + parser->greater_than_is_operator_p = saved_greater_than_is_operator_p; /* Restore the SAVED_SCOPE. */ parser->scope = saved_scope; @@ -14620,26 +14641,26 @@ cp_parser_late_parsing_for_member (cp_parser* parser, tree member_function) function_scope = decl_function_context (member_function); if (function_scope) push_function_context_to (function_scope); - + /* Save away the current lexer. */ saved_lexer = parser->lexer; /* Make a new lexer to feed us the tokens saved for this function. */ parser->lexer = cp_lexer_new_from_tokens (tokens); parser->lexer->next = saved_lexer; - + /* Set the current source position to be the location of the first token in the saved inline body. */ cp_lexer_peek_token (parser->lexer); - + /* Let the front end know that we going to be defining this function. */ start_function (NULL_TREE, member_function, NULL_TREE, SF_PRE_PARSED | SF_INCLASS_INLINE); - + /* Now, parse the body of the function. */ cp_parser_function_definition_after_declarator (parser, /*inline_p=*/true); - + /* Leave the scope of the containing function. */ if (function_scope) pop_function_context_from (function_scope); @@ -14651,7 +14672,7 @@ cp_parser_late_parsing_for_member (cp_parser* parser, tree member_function) maybe_end_member_template_processing (); /* Restore the queue. */ - parser->unparsed_functions_queues + parser->unparsed_functions_queues = TREE_CHAIN (parser->unparsed_functions_queues); } @@ -14669,7 +14690,7 @@ cp_parser_save_default_args (cp_parser* parser, tree decl) if (TREE_PURPOSE (probe)) { TREE_PURPOSE (parser->unparsed_functions_queues) - = tree_cons (NULL_TREE, decl, + = tree_cons (NULL_TREE, decl, TREE_PURPOSE (parser->unparsed_functions_queues)); break; } @@ -14701,7 +14722,7 @@ cp_parser_late_parsing_default_args (cp_parser *parser, tree fn) if (!TREE_PURPOSE (parameters) || TREE_CODE (TREE_PURPOSE (parameters)) != DEFAULT_ARG) continue; - + /* Save away the current lexer. */ saved_lexer = parser->lexer; /* Create a new one, using the tokens we have saved. */ @@ -14729,7 +14750,7 @@ cp_parser_late_parsing_default_args (cp_parser *parser, tree fn) } /* Restore the queue. */ - parser->unparsed_functions_queues + parser->unparsed_functions_queues = TREE_CHAIN (parser->unparsed_functions_queues); } @@ -14754,8 +14775,8 @@ cp_parser_sizeof_operand (cp_parser* parser, enum rid keyword) old message. */ saved_message = parser->type_definition_forbidden_message; /* And create the new one. */ - parser->type_definition_forbidden_message - = xmalloc (strlen (format) + parser->type_definition_forbidden_message + = xmalloc (strlen (format) + strlen (IDENTIFIER_POINTER (ridpointers[keyword])) + 1 /* `\0' */); sprintf ((char *) parser->type_definition_forbidden_message, @@ -14825,7 +14846,7 @@ cp_parser_sizeof_operand (cp_parser* parser, enum rid keyword) static bool cp_parser_declares_only_class_p (cp_parser *parser) { - /* If the next token is a `;' or a `,' then there is no + /* If the next token is a `;' or a `,' then there is no declarator. */ return (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON) || cp_lexer_next_token_is (parser->lexer, CPP_COMMA)); @@ -14853,7 +14874,7 @@ cp_parser_friend_p (tree decl_specifiers) /* If the next token is of the indicated TYPE, consume it. Otherwise, issue an error message indicating that TOKEN_DESC was expected. - + Returns the token consumed, if the token had the appropriate type. Otherwise, returns NULL. */ @@ -14882,8 +14903,8 @@ cp_parser_require (cp_parser* parser, the next token is not as expected. */ static void -cp_parser_skip_until_found (cp_parser* parser, - enum cpp_ttype type, +cp_parser_skip_until_found (cp_parser* parser, + enum cpp_ttype type, const char* token_desc) { cp_token *token; @@ -14897,7 +14918,7 @@ cp_parser_skip_until_found (cp_parser* parser, { /* Peek at the next token. */ token = cp_lexer_peek_token (parser->lexer); - /* If we've reached the token we want, consume it and + /* If we've reached the token we want, consume it and stop. */ if (token->type == type && !nesting_depth) { @@ -14907,11 +14928,11 @@ cp_parser_skip_until_found (cp_parser* parser, /* If we've run out of tokens, stop. */ if (token->type == CPP_EOF) return; - if (token->type == CPP_OPEN_BRACE + if (token->type == CPP_OPEN_BRACE || token->type == CPP_OPEN_PAREN || token->type == CPP_OPEN_SQUARE) ++nesting_depth; - else if (token->type == CPP_CLOSE_BRACE + else if (token->type == CPP_CLOSE_BRACE || token->type == CPP_CLOSE_PAREN || token->type == CPP_CLOSE_SQUARE) { @@ -14925,7 +14946,7 @@ cp_parser_skip_until_found (cp_parser* parser, /* If the next token is the indicated keyword, consume it. Otherwise, issue an error message indicating that TOKEN_DESC was expected. - + Returns the token consumed, if the token had the appropriate type. Otherwise, returns NULL. */ @@ -14955,7 +14976,7 @@ cp_parser_require_keyword (cp_parser* parser, /* Returns TRUE iff TOKEN is a token that can begin the body of a function-definition. */ -static bool +static bool cp_parser_token_starts_function_definition_p (cp_token* token) { return (/* An ordinary function-body begins with an `{'. */ @@ -14991,7 +15012,7 @@ cp_parser_next_token_ends_template_argument_p (cp_parser *parser) cp_token *token; token = cp_lexer_peek_token (parser->lexer); - return (token->type == CPP_COMMA || token->type == CPP_GREATER + return (token->type == CPP_COMMA || token->type == CPP_GREATER || token->type == CPP_RSHIFT); } @@ -14999,7 +15020,7 @@ cp_parser_next_token_ends_template_argument_p (cp_parser *parser) (n+1)-th is a ":" (which is a possible digraph typo for "< ::"). */ static bool -cp_parser_nth_token_starts_template_argument_list_p (cp_parser * parser, +cp_parser_nth_token_starts_template_argument_list_p (cp_parser * parser, size_t n) { cp_token *token; @@ -15019,7 +15040,7 @@ cp_parser_nth_token_starts_template_argument_list_p (cp_parser * parser, } return false; } - + /* Returns the kind of tag indicated by TOKEN, if it is a class-key, or none_type otherwise. */ @@ -15034,7 +15055,7 @@ cp_parser_token_is_class_key (cp_token* token) return record_type; case RID_UNION: return union_type; - + default: return none_type; } @@ -15048,10 +15069,10 @@ cp_parser_check_class_key (enum tag_types class_key, tree type) if ((TREE_CODE (type) == UNION_TYPE) != (class_key == union_type)) pedwarn ("`%s' tag used in naming `%#T'", class_key == union_type ? "union" - : class_key == record_type ? "struct" : "class", + : class_key == record_type ? "struct" : "class", type); } - + /* Issue an error message if DECL is redeclared with different access than its original declaration [class.access.spec/3]. This applies to nested classes and nested class templates. @@ -15070,7 +15091,7 @@ static void cp_parser_check_access_in_redeclaration (tree decl) } /* Look for the `template' keyword, as a syntactic disambiguator. - Return TRUE iff it is present, in which case it will be + Return TRUE iff it is present, in which case it will be consumed. */ static bool @@ -15125,7 +15146,7 @@ cp_parser_pre_parsed_nested_name_specifier (cp_parser *parser) /* Add tokens to CACHE until a non-nested END token appears. */ static void -cp_parser_cache_group (cp_parser *parser, +cp_parser_cache_group (cp_parser *parser, cp_token_cache *cache, enum cpp_ttype end, unsigned depth) @@ -15261,7 +15282,7 @@ cp_parser_committed_to_tentative_parse (cp_parser* parser) /* Returns nonzero iff an error has occurred during the most recent tentative parse. */ - + static bool cp_parser_error_occurred (cp_parser* parser) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dda6ed78e95..8c5b63633df 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,31 @@ +2004-02-26 Eric Christopher <echristo@redhat.com> + + * lib/target-supports.exp (check-iconv-available): New function. + * lib/gcc-dg.exp (dg-require-iconv): New function. + Use above. + * gcc.dg/charset: New directory. + * gcc.dg/charset/charset.exp: New file. + * gcc.dg/charset/asm1.c: Ditto. + * gcc.dg/charset/asm2.c: Ditto. + * gcc.dg/charset/asm3.c: Ditto. + * gcc.dg/charset/asm4.c: Ditto. + * gcc.dg/charset/asm5.c: Ditto. + * gcc.dg/charset/attribute1.c: Ditto. + * gcc.dg/charset/attribute2.c: Ditto. + * gcc.dg/charset/string1.c: Ditto. + * g++.dg/charset: New directory. + * g++.dg/dg.exp: Add here. Special options. + * g++.dg/charset/charset.exp: New file. + * g++.dg/charset/asm1.c: Ditto. + * g++.dg/charset/asm2.c: Ditto. + * g++.dg/charset/asm3.c: Ditto. + * g++.dg/charset/asm4.c: Ditto. + * g++.dg/charset/attribute1.c: Ditto. + * g++.dg/charset/attribute2.c: Ditto. + * g++.dg/charset/extern1.cc: Ditto. + * g++.dg/charset/extern2.cc: Ditto. + * g++.dg/charset/string1.c: Ditto. + 2004-02-26 Mark Mitchell <mark@codesourcery.com> PR c++/14278 @@ -89,7 +117,7 @@ * gcc.dg/altivec-6.c: New test case. * gcc.dg/altivec-[7-9].c: Generalize target triple; add type casts as needed. - * gcc.dg/altivec-10.c: Include altivec_check.h and call + * gcc.dg/altivec-10.c: Include altivec_check.h and call altivec_check(). * gcc.dg/altivec-12.c: New test case. * gcc.dg/altivec-varargs-1.c: Generalize target triple; @@ -21063,5 +21091,3 @@ rlsruhe.de> correspond to c-torture 1.11. * New file. - - diff --git a/gcc/testsuite/g++.dg/charset/asm1.c b/gcc/testsuite/g++.dg/charset/asm1.c new file mode 100644 index 00000000000..9c0ff2866b0 --- /dev/null +++ b/gcc/testsuite/g++.dg/charset/asm1.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target *-*-* } } + { dg-require-iconv "IBM-1047" } + { dg-final { scan-assembler ".ascii bar" } } + { dg-final { scan-assembler ".ascii foo" } } + */ +extern int x, y; + +asm (".ascii bar"); + +int foo (void) +{ + __asm__ (".ascii foo"); + return 0; +} diff --git a/gcc/testsuite/g++.dg/charset/asm2.c b/gcc/testsuite/g++.dg/charset/asm2.c new file mode 100644 index 00000000000..7cc1379a8a9 --- /dev/null +++ b/gcc/testsuite/g++.dg/charset/asm2.c @@ -0,0 +1,33 @@ +/* Test for complex asm statements. Make sure it compiles + then test for some of the asm statements not being translated. */ +/* { dg-do compile } + { dg-require-iconv "IBM-1047" } + { dg-final { scan-assembler "std" } } + { dg-final { scan-assembler "cld" } } + { dg-final { scan-assembler "rep" } } + { dg-final { scan-assembler "movsb" } } */ +#define size_t int +void * +memmove (void *__dest, __const void *__src, size_t __n) +{ + register unsigned long int __d0, __d1, __d2; + if (__dest < __src) + __asm__ __volatile__ + ("cld\n\t" + "rep\n\t" + "movsb" + : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) + : "0" (__n), "1" (__src), "2" (__dest) + : "memory"); + else + __asm__ __volatile__ + ("std\n\t" + "rep\n\t" + "movsb\n\t" + "cld" + : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) + : "0" (__n), "1" (__n - 1 + (const char *) __src), + "2" (__n - 1 + (char *) __dest) + : "memory"); + return __dest; +} diff --git a/gcc/testsuite/g++.dg/charset/asm3.c b/gcc/testsuite/g++.dg/charset/asm3.c new file mode 100644 index 00000000000..cd850c3e81f --- /dev/null +++ b/gcc/testsuite/g++.dg/charset/asm3.c @@ -0,0 +1,10 @@ +/* Simple asm test. */ +/* { dg-do compile } + { dg-require-iconv "IBM-1047" } + { dg-final { scan-assembler "foo" } } */ +extern int bar; + +int main (void) +{ + asm ("foo %0" : "=r" (bar)); +} diff --git a/gcc/testsuite/g++.dg/charset/asm4.c b/gcc/testsuite/g++.dg/charset/asm4.c new file mode 100644 index 00000000000..fa93f40fdaf --- /dev/null +++ b/gcc/testsuite/g++.dg/charset/asm4.c @@ -0,0 +1,8 @@ +/* Test for string translation. */ +/* { dg-do compile } + { dg-require-iconv "IBM-1047" } + { dg-final { scan-assembler-not "translate" } } */ +void foo (void) +{ + asm ("xx" : : "r"("translate") : "cc"); +} diff --git a/gcc/testsuite/g++.dg/charset/attribute1.c b/gcc/testsuite/g++.dg/charset/attribute1.c new file mode 100644 index 00000000000..993c7934c80 --- /dev/null +++ b/gcc/testsuite/g++.dg/charset/attribute1.c @@ -0,0 +1,10 @@ +/* Test for attribute non-translation. */ +/* { dg-do compile } + { dg-require-iconv "IBM-1047" } + { dg-final { scan-assembler "foo" } } */ +int walrus __attribute__ ((section (".foo"))); + +int main (void) +{ + return 0; +} diff --git a/gcc/testsuite/g++.dg/charset/attribute2.c b/gcc/testsuite/g++.dg/charset/attribute2.c new file mode 100644 index 00000000000..3cb766aa63a --- /dev/null +++ b/gcc/testsuite/g++.dg/charset/attribute2.c @@ -0,0 +1,8 @@ +/* Test to make sure that invalid attributes aren't translated. + If error recovery is ever testable then "foobar" should be + translated. */ +/* { dg-do compile } + { dg-require-iconv "IBM-1047" } +*/ +int foo __attribute__ ((walrus)); /* { dg-error "walrus" "ignored" } */ +char x[] = "foobar"; diff --git a/gcc/testsuite/g++.dg/charset/charset.exp b/gcc/testsuite/g++.dg/charset/charset.exp new file mode 100644 index 00000000000..096dc3ec2ea --- /dev/null +++ b/gcc/testsuite/g++.dg/charset/charset.exp @@ -0,0 +1,44 @@ +# Copyright (C) 2004 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# GCC testsuite that uses the 'dg.exp' driver. + +# There's a bunch of headers we need. +if [is_remote host] { + foreach header [glob -nocomplain $srcdir/$subdir/*.{h,def} ] { + remote_download host $header + } +} + +# Load support procs. +load_lib g++-dg.exp +load_lib target-supports.exp + +# If a testcase doesn't have special options, use these. +global DEFAULT_CFLAGS +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS "-fexec-charset=IBM-1047" +} + +# Initialize `dg'. +dg-init + +# Main loop. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{c,S} ]] \ + "" $DEFAULT_CFLAGS + +# All done. +dg-finish diff --git a/gcc/testsuite/g++.dg/charset/extern1.cc b/gcc/testsuite/g++.dg/charset/extern1.cc new file mode 100644 index 00000000000..2a68ab7cf78 --- /dev/null +++ b/gcc/testsuite/g++.dg/charset/extern1.cc @@ -0,0 +1,15 @@ +/* Test extern statments not being translated. */ +/* { dg-do compile } + { dg-require-iconv "IBM-1047" } +*/ + +extern "C" { + + +int testbug (void) { + + return 0; + +} + +} //extern block diff --git a/gcc/testsuite/g++.dg/charset/extern2.cc b/gcc/testsuite/g++.dg/charset/extern2.cc new file mode 100644 index 00000000000..82157a6fea4 --- /dev/null +++ b/gcc/testsuite/g++.dg/charset/extern2.cc @@ -0,0 +1,5 @@ +/* Check that we push the declaration and then continue translation. */ +/* { dg-do compile } + { dg-require-iconv "IBM-1047" } + { dg-final { scan-assembler-not "foobar" } } */ +extern "C" { char *foo = "foobar"; } diff --git a/gcc/testsuite/g++.dg/charset/string.c b/gcc/testsuite/g++.dg/charset/string.c new file mode 100644 index 00000000000..375e28a2ed6 --- /dev/null +++ b/gcc/testsuite/g++.dg/charset/string.c @@ -0,0 +1,5 @@ +/* Simple character translation test. */ +/* { dg-do compile } + { dg-require-iconv "IBM-1047" } + { dg-final { scan-assembler-not "string foobar" } } */ +char *foo = "string foobar"; diff --git a/gcc/testsuite/g++.dg/dg.exp b/gcc/testsuite/g++.dg/dg.exp index d9839608733..f809f10f2db 100644 --- a/gcc/testsuite/g++.dg/dg.exp +++ b/gcc/testsuite/g++.dg/dg.exp @@ -4,15 +4,15 @@ # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # G++ testsuite that uses the `dg.exp' driver. @@ -32,6 +32,7 @@ dg-init # that are handled specially. set tests [lsort [find $srcdir/$subdir *.C]] set tests [prune $tests $srcdir/$subdir/bprob/*] +set tests [prune $tests $srcdir/$subdir/charset/*] set tests [prune $tests $srcdir/$subdir/compat/*] set tests [prune $tests $srcdir/$subdir/debug/*] set tests [prune $tests $srcdir/$subdir/gcov/*] diff --git a/gcc/testsuite/gcc.dg/charset/asm1.c b/gcc/testsuite/gcc.dg/charset/asm1.c new file mode 100644 index 00000000000..d7578d418f6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/asm1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } + { dg-require-iconv "IBM-1047" } + { dg-final { scan-assembler ".ascii bar" } } + { dg-final { scan-assembler ".ascii foo" } } + */ +extern int x, y; + +asm (".ascii bar"); + +int foo (void) +{ + __asm__ (".ascii foo"); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/charset/asm2.c b/gcc/testsuite/gcc.dg/charset/asm2.c new file mode 100644 index 00000000000..4af7a18cf81 --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/asm2.c @@ -0,0 +1,16 @@ +/* Test for execution character set encoding errors. + If we ever get a good way to test error recovery + the string "foobar" should be translated. */ +/* { dg-do compile } */ +/* { dg-require-iconv "IBM-1047" } */ +asm (not_a_string); /* { dg-error "syntax error before" "not_a_string" } */ +char x[] = "foobar"; + +void foo (void) +{ + char *y; + asm (not_a_string2); /* { dg-error "syntax error before" "not_a_string" } */ + +#define FOO "walrus" + y = FOO; +} diff --git a/gcc/testsuite/gcc.dg/charset/asm3.c b/gcc/testsuite/gcc.dg/charset/asm3.c new file mode 100644 index 00000000000..7cc1379a8a9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/asm3.c @@ -0,0 +1,33 @@ +/* Test for complex asm statements. Make sure it compiles + then test for some of the asm statements not being translated. */ +/* { dg-do compile } + { dg-require-iconv "IBM-1047" } + { dg-final { scan-assembler "std" } } + { dg-final { scan-assembler "cld" } } + { dg-final { scan-assembler "rep" } } + { dg-final { scan-assembler "movsb" } } */ +#define size_t int +void * +memmove (void *__dest, __const void *__src, size_t __n) +{ + register unsigned long int __d0, __d1, __d2; + if (__dest < __src) + __asm__ __volatile__ + ("cld\n\t" + "rep\n\t" + "movsb" + : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) + : "0" (__n), "1" (__src), "2" (__dest) + : "memory"); + else + __asm__ __volatile__ + ("std\n\t" + "rep\n\t" + "movsb\n\t" + "cld" + : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) + : "0" (__n), "1" (__n - 1 + (const char *) __src), + "2" (__n - 1 + (char *) __dest) + : "memory"); + return __dest; +} diff --git a/gcc/testsuite/gcc.dg/charset/asm4.c b/gcc/testsuite/gcc.dg/charset/asm4.c new file mode 100644 index 00000000000..cd850c3e81f --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/asm4.c @@ -0,0 +1,10 @@ +/* Simple asm test. */ +/* { dg-do compile } + { dg-require-iconv "IBM-1047" } + { dg-final { scan-assembler "foo" } } */ +extern int bar; + +int main (void) +{ + asm ("foo %0" : "=r" (bar)); +} diff --git a/gcc/testsuite/gcc.dg/charset/asm5.c b/gcc/testsuite/gcc.dg/charset/asm5.c new file mode 100644 index 00000000000..fa93f40fdaf --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/asm5.c @@ -0,0 +1,8 @@ +/* Test for string translation. */ +/* { dg-do compile } + { dg-require-iconv "IBM-1047" } + { dg-final { scan-assembler-not "translate" } } */ +void foo (void) +{ + asm ("xx" : : "r"("translate") : "cc"); +} diff --git a/gcc/testsuite/gcc.dg/charset/attribute1.c b/gcc/testsuite/gcc.dg/charset/attribute1.c new file mode 100644 index 00000000000..993c7934c80 --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/attribute1.c @@ -0,0 +1,10 @@ +/* Test for attribute non-translation. */ +/* { dg-do compile } + { dg-require-iconv "IBM-1047" } + { dg-final { scan-assembler "foo" } } */ +int walrus __attribute__ ((section (".foo"))); + +int main (void) +{ + return 0; +} diff --git a/gcc/testsuite/gcc.dg/charset/attribute2.c b/gcc/testsuite/gcc.dg/charset/attribute2.c new file mode 100644 index 00000000000..4ce95a51f84 --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/attribute2.c @@ -0,0 +1,8 @@ +/* Test to make sure that invalid attributes aren't translated. + If error recovery is ever testable then "foobar" should be + translated. */ +/* { dg-do compile } + { dg-require-iconv "IBM-1047" } + */ +int foo __attribute__ ((walrus)); /* { dg-error "walrus" "ignored" } */ +char x[] = "foobar"; diff --git a/gcc/testsuite/gcc.dg/charset/charset.exp b/gcc/testsuite/gcc.dg/charset/charset.exp new file mode 100644 index 00000000000..ad75cb55af8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/charset.exp @@ -0,0 +1,44 @@ +# Copyright (C) 2004 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# GCC testsuite that uses the 'dg.exp' driver. + +# There's a bunch of headers we need. +if [is_remote host] { + foreach header [glob -nocomplain $srcdir/$subdir/*.{h,def} ] { + remote_download host $header + } +} + +# Load support procs. +load_lib gcc-dg.exp +load_lib target-supports.exp + +# If a testcase doesn't have special options, use these. +global DEFAULT_CHARSETCFLAGS +if ![info exists DEFAULT_CHARSETCFLAGS] then { + set DEFAULT_CHARSETCFLAGS "-fexec-charset=IBM-1047" +} + +# Initialize `dg'. +dg-init + +# Main loop. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{c,S} ]] \ + "" $DEFAULT_CHARSETCFLAGS + +# All done. +dg-finish diff --git a/gcc/testsuite/gcc.dg/charset/string.c b/gcc/testsuite/gcc.dg/charset/string.c new file mode 100644 index 00000000000..375e28a2ed6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/string.c @@ -0,0 +1,5 @@ +/* Simple character translation test. */ +/* { dg-do compile } + { dg-require-iconv "IBM-1047" } + { dg-final { scan-assembler-not "string foobar" } } */ +char *foo = "string foobar"; diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp index c5f589eea27..d1a85a819c5 100644 --- a/gcc/testsuite/lib/gcc-dg.exp +++ b/gcc/testsuite/lib/gcc-dg.exp @@ -4,15 +4,15 @@ # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. load_lib dg.exp load_lib file-format.exp @@ -175,7 +175,7 @@ proc gcc-dg-runtest { testcases default-extra-flags } { global runtests foreach test $testcases { - # If we're only testing specific files and this isn't one of + # If we're only testing specific files and this isn't one of # them, skip it. if ![runtest_file_p $runtests $test] { continue @@ -226,7 +226,7 @@ proc gcc-dg-debug-runtest { target_compile trivial opt_opts testcases } { global runtests foreach test $testcases { - # If we're only testing specific files and this isn't one of + # If we're only testing specific files and this isn't one of # them, skip it. if ![runtest_file_p $runtests $test] { continue @@ -237,7 +237,7 @@ proc gcc-dg-debug-runtest { target_compile trivial opt_opts testcases } { foreach flags $DEBUG_TORTURE_OPTIONS { set doit 1 if { [string match {*/debug-[126].c} "$nshort"] \ - && [string match "*1" [lindex "$flags" 0] ] } { + && [string match "*1" [lindex "$flags" 0] ] } { set doit 0 } @@ -333,7 +333,7 @@ proc dg-require-profiling { args } { # If this target does not support DLL attributes skip this test. -proc dg-require-dll { args } { +proc dg-require-dll { args } { global target_triplet # As a special case, the mcore-*-elf supports dllimport/dllexport. if { [string match "mcore-*-elf" $target_triplet] } { @@ -348,6 +348,15 @@ proc dg-require-dll { args } { set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"] } +proc dg-require-iconv { args } { + if { ![ check_iconv_available ${args} ] } { + upvar dg-do-what dg-do-what + set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"] + return + } + return +} + # Prune any messages matching ARGS[1] (a regexp) from test output. proc dg-prune-output { args } { global additional_prunes diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 485a8d75dd9..ef2989043b3 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -4,15 +4,15 @@ # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Please email any bugs, comments, and/or additions to this file to: # gcc-patches@gcc.gnu.org @@ -31,13 +31,13 @@ proc check_weak_available { } { global target_cpu # All mips targets should support it - + if { [ string first "mips" $target_cpu ] >= 0 } { return 1 } # All solaris2 targets should support it - + if { [regexp ".*-solaris2.*" $target_triplet] } { return 1 } @@ -139,7 +139,7 @@ proc check_alias_available { } { } } } - + verbose "check_alias_available returning $alias_available_saved" 2 } @@ -187,7 +187,7 @@ proc check_profiling_available { test_what } { # exist on any irix6 system currently posting testsuite results. # Support for -pg on irix relies on gcrt1.o which doesn't exist yet. # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html - if { [istarget mips*-*-irix*] + if { [istarget mips*-*-irix*] && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } { return 0 } @@ -201,13 +201,44 @@ proc check_profiling_available { test_what } { || [istarget strongarm*-*-elf] || [istarget xscale*-*-elf] || [istarget cris-*-*] - || [istarget h8300-*-*] + || [istarget h8300-*-*] || [istarget *-*-windiss] } { set profiling_available_saved 0 } else { set profiling_available_saved 1 } } - + return $profiling_available_saved } + +# Return true if iconv is supported on the target. In particular IBM-1047. + +proc check_iconv_available { test_what } { + global tool + + set result "" + + verbose "check_iconv_available compiling testfile" 1 + set f [open "tmp.c" "w"] + # Compile a small test program. + puts $f "#include <iconv.h>\n" + puts $f "int main (void)\n {\n iconv_t cd; \n" + puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n" + puts $f "if (cd == (iconv_t) -1)\n return 1;\n" + puts $f "return 0;\n}" + close $f + + set lines [${tool}_target_compile "tmp.c" "tmp.x" executable ""] + + set result [${tool}_load "./tmp.x" "" ""] + set status [lindex $result 0]; + + verbose "status is <$status>" + + if { $status == "pass" } then { + return 1 + } + + return 0 +} |