diff options
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r-- | gcc/cp/parser.c | 56 |
1 files changed, 37 insertions, 19 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 03606084258..15b66b03b95 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -2162,7 +2162,8 @@ cp_parser_check_decl_spec (cp_decl_specifier_seq *decl_specs, error ("%H%<long long long%> is too long for GCC", &location); else if (pedantic && !in_system_header && warn_long_long && cxx_dialect == cxx98) - pedwarn ("%HISO C++ 1998 does not support %<long long%>", + pedwarn (OPT_Wlong_long, + "%HISO C++ 1998 does not support %<long long%>", &location); } else if (count > 1) @@ -3214,9 +3215,9 @@ cp_parser_primary_expression (cp_parser *parser, && cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) { /* Statement-expressions are not allowed by the standard. */ - if (pedantic) - pedwarn ("%HISO C++ forbids braced-groups within expressions", - &token->location); + pedwarn (OPT_pedantic, + "%HISO C++ forbids braced-groups within expressions", + &token->location); /* And they're not allowed outside of a function-body; you cannot, for example, write: @@ -4545,8 +4546,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, { /* Warn the user that a compound literal is not allowed in standard C++. */ - if (pedantic) - pedwarn ("ISO C++ forbids compound-literals"); + pedwarn (OPT_pedantic, "ISO C++ forbids compound-literals"); /* For simplicity, we disallow compound literals in constant-expressions. We could allow compound literals of integer type, whose @@ -7610,8 +7610,7 @@ cp_parser_jump_statement (cp_parser* parser) if (cp_lexer_next_token_is (parser->lexer, CPP_MULT)) { /* Issue a warning about this use of a GNU extension. */ - if (pedantic) - pedwarn ("%HISO C++ forbids computed gotos", &token->location); + pedwarn (OPT_pedantic, "%HISO C++ forbids computed gotos", &token->location); /* Consume the '*' token. */ cp_lexer_consume_token (parser->lexer); /* Parse the dependent expression. */ @@ -7750,8 +7749,8 @@ cp_parser_declaration_seq_opt (cp_parser* parser) /* A declaration consisting of a single semicolon is invalid. Allow it unless we're being pedantic. */ cp_lexer_consume_token (parser->lexer); - if (pedantic && !in_system_header) - pedwarn ("extra %<;%>"); + if (!in_system_header) + pedwarn (OPT_pedantic, "extra %<;%>"); continue; } @@ -11734,8 +11733,8 @@ cp_parser_enumerator_list (cp_parser* parser, tree type) /* If the next token is a `}', there is a trailing comma. */ if (cp_lexer_next_token_is (parser->lexer, CPP_CLOSE_BRACE)) { - if (pedantic && !in_system_header) - pedwarn ("comma at end of enumerator list"); + if (!in_system_header) + pedwarn (OPT_pedantic, "comma at end of enumerator list"); break; } } @@ -12379,7 +12378,7 @@ cp_parser_init_declarator (cp_parser* parser, tree initializer; tree decl = NULL_TREE; tree scope; - bool is_initialized; + int is_initialized; /* Only valid if IS_INITIALIZED is true. In that case, CPP_EQ if initialized with "= ..", CPP_OPEN_PAREN if initialized with "(...)". */ @@ -12515,8 +12514,18 @@ cp_parser_init_declarator (cp_parser* parser, || token->type == CPP_OPEN_PAREN || token->type == CPP_OPEN_BRACE) { - is_initialized = true; + is_initialized = 1; initialization_kind = token->type; + + if (token->type == CPP_EQ + && function_declarator_p (declarator)) + { + cp_token *t2 = cp_lexer_peek_nth_token (parser->lexer, 2); + if (t2->keyword == RID_DEFAULT) + is_initialized = 2; + else if (t2->keyword == RID_DELETE) + is_initialized = 3; + } } else { @@ -12528,7 +12537,7 @@ cp_parser_init_declarator (cp_parser* parser, cp_parser_error (parser, "expected initializer"); return error_mark_node; } - is_initialized = false; + is_initialized = 0; initialization_kind = CPP_EOF; } @@ -14369,8 +14378,8 @@ cp_parser_initializer_list (cp_parser* parser, bool* non_constant_p) && cp_lexer_peek_nth_token (parser->lexer, 2)->type == CPP_COLON) { /* Warn the user that they are using an extension. */ - if (pedantic) - pedwarn ("ISO C++ does not allow designated initializers"); + pedwarn (OPT_pedantic, + "ISO C++ does not allow designated initializers"); /* Consume the identifier. */ identifier = cp_lexer_consume_token (parser->lexer)->u.value; /* Consume the `:'. */ @@ -15386,8 +15395,8 @@ cp_parser_member_declaration (cp_parser* parser) if (!decl_specifiers.any_specifiers_p) { cp_token *token = cp_lexer_peek_token (parser->lexer); - if (pedantic && !in_system_header_at (token->location)) - pedwarn ("%Hextra %<;%>", &token->location); + if (!in_system_header_at (token->location)) + pedwarn (OPT_pedantic, "%Hextra %<;%>", &token->location); } else { @@ -15682,6 +15691,15 @@ cp_parser_pure_specifier (cp_parser* parser) return error_mark_node; /* Look for the `0' token. */ token = cp_lexer_consume_token (parser->lexer); + + /* Accept = default or = delete in c++0x mode. */ + if (token->keyword == RID_DEFAULT + || token->keyword == RID_DELETE) + { + maybe_warn_cpp0x ("defaulted and deleted functions"); + return token->u.value; + } + /* c_lex_with_flags marks a single digit '0' with PURE_ZERO. */ if (token->type != CPP_NUMBER || !(token->flags & PURE_ZERO)) { |