diff options
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r-- | gcc/cp/parser.c | 64 |
1 files changed, 38 insertions, 26 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index b988850..07f0375 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -6135,7 +6135,7 @@ cp_parser_cast_expression (cp_parser *parser, bool address_p, bool cast_p, return error_mark_node; /* Perform the cast. */ - expr = build_c_cast (type, expr); + expr = build_c_cast (input_location, type, expr); return expr; } else @@ -7093,7 +7093,7 @@ cp_parser_label_for_labeled_statement (cp_parser* parser) expr_hi = NULL_TREE; if (parser->in_switch_statement_p) - finish_case_label (expr, expr_hi); + finish_case_label (token->location, expr, expr_hi); else error ("%Hcase label %qE not within a switch statement", &token->location, expr); @@ -7105,7 +7105,7 @@ cp_parser_label_for_labeled_statement (cp_parser* parser) cp_lexer_consume_token (parser->lexer); if (parser->in_switch_statement_p) - finish_case_label (NULL_TREE, NULL_TREE); + finish_case_label (token->location, NULL_TREE, NULL_TREE); else error ("%Hcase label not within a switch statement", &token->location); break; @@ -7326,7 +7326,7 @@ cp_parser_selection_statement (cp_parser* parser, bool *if_p) if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON)) { location_t loc = cp_lexer_peek_token (parser->lexer)->location; - add_stmt (build_empty_stmt ()); + add_stmt (build_empty_stmt (loc)); cp_lexer_consume_token (parser->lexer); if (!cp_lexer_next_token_is_keyword (parser->lexer, RID_ELSE)) warning_at (loc, OPT_Wempty_body, "suggest braces around " @@ -7349,10 +7349,12 @@ cp_parser_selection_statement (cp_parser* parser, bool *if_p) /* Parse the else-clause. */ if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON)) { - warning_at (cp_lexer_peek_token (parser->lexer)->location, + location_t loc; + loc = cp_lexer_peek_token (parser->lexer)->location; + warning_at (loc, OPT_Wempty_body, "suggest braces around " "empty body in an %<else%> statement"); - add_stmt (build_empty_stmt ()); + add_stmt (build_empty_stmt (loc)); cp_lexer_consume_token (parser->lexer); } else @@ -7860,8 +7862,9 @@ cp_parser_implicitly_scoped_statement (cp_parser* parser, bool *if_p) /* Mark if () ; with a special NOP_EXPR. */ if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON)) { + location_t loc = cp_lexer_peek_token (parser->lexer)->location; cp_lexer_consume_token (parser->lexer); - statement = add_stmt (build_empty_stmt ()); + statement = add_stmt (build_empty_stmt (loc)); } /* if a compound is opened, we simply parse the statement directly. */ else if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) @@ -9680,14 +9683,17 @@ cp_parser_template_parameter_list (cp_parser* parser) tree parameter; bool is_non_type; bool is_parameter_pack; + location_t parm_loc; /* Parse the template-parameter. */ + parm_loc = cp_lexer_peek_token (parser->lexer)->location; parameter = cp_parser_template_parameter (parser, &is_non_type, &is_parameter_pack); /* Add it to the list. */ if (parameter != error_mark_node) parameter_list = process_template_parm (parameter_list, + parm_loc, parameter, is_non_type, is_parameter_pack); @@ -15862,7 +15868,8 @@ cp_parser_member_declaration (cp_parser* parser) know it is an anonymous aggregate. */ fixup_anonymous_aggr (type); /* And make the corresponding data member. */ - decl = build_decl (FIELD_DECL, NULL_TREE, type); + decl = build_decl (decl_spec_token_start->location, + FIELD_DECL, NULL_TREE, type); /* Add it to the class. */ finish_member_declaration (decl); } @@ -19432,6 +19439,7 @@ cp_parser_objc_selector_expression (cp_parser* parser) tree sel_seq = NULL_TREE; bool maybe_unary_selector_p = true; cp_token *token; + location_t loc = cp_lexer_peek_token (parser->lexer)->location; cp_lexer_consume_token (parser->lexer); /* Eat '@selector'. */ cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); @@ -19483,7 +19491,7 @@ cp_parser_objc_selector_expression (cp_parser* parser) finish_selector: cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); - return objc_build_selector_expr (sel_seq); + return objc_build_selector_expr (loc, sel_seq); } /* Parse a list of identifiers. @@ -20256,6 +20264,7 @@ cp_parser_objc_synchronized_statement (cp_parser *parser) { static tree cp_parser_objc_throw_statement (cp_parser *parser) { tree expr = NULL_TREE; + location_t loc = cp_lexer_peek_token (parser->lexer)->location; cp_parser_require_keyword (parser, RID_AT_THROW, "%<@throw%>"); @@ -20264,7 +20273,7 @@ cp_parser_objc_throw_statement (cp_parser *parser) { cp_parser_consume_semicolon_at_end_of_statement (parser); - return objc_build_throw_stmt (expr); + return objc_build_throw_stmt (loc, expr); } /* Parse an Objective-C statement. */ @@ -20418,7 +20427,7 @@ cp_parser_omp_var_list_no_open (cp_parser *parser, enum omp_clause_code kind, cp_parser_name_lookup_error (parser, name, decl, NULL, token->location); else if (kind != 0) { - tree u = build_omp_clause (kind); + tree u = build_omp_clause (token->location, kind); OMP_CLAUSE_DECL (u) = decl; OMP_CLAUSE_CHAIN (u) = list; list = u; @@ -20496,7 +20505,7 @@ cp_parser_omp_clause_collapse (cp_parser *parser, tree list, location_t location } check_no_duplicate_clause (list, OMP_CLAUSE_COLLAPSE, "collapse", location); - c = build_omp_clause (OMP_CLAUSE_COLLAPSE); + c = build_omp_clause (loc, OMP_CLAUSE_COLLAPSE); OMP_CLAUSE_CHAIN (c) = list; OMP_CLAUSE_COLLAPSE_EXPR (c) = num; @@ -20554,7 +20563,7 @@ cp_parser_omp_clause_default (cp_parser *parser, tree list, location_t location) return list; check_no_duplicate_clause (list, OMP_CLAUSE_DEFAULT, "default", location); - c = build_omp_clause (OMP_CLAUSE_DEFAULT); + c = build_omp_clause (location, OMP_CLAUSE_DEFAULT); OMP_CLAUSE_CHAIN (c) = list; OMP_CLAUSE_DEFAULT_KIND (c) = kind; @@ -20582,7 +20591,7 @@ cp_parser_omp_clause_if (cp_parser *parser, tree list, location_t location) check_no_duplicate_clause (list, OMP_CLAUSE_IF, "if", location); - c = build_omp_clause (OMP_CLAUSE_IF); + c = build_omp_clause (location, OMP_CLAUSE_IF); OMP_CLAUSE_IF_EXPR (c) = t; OMP_CLAUSE_CHAIN (c) = list; @@ -20600,7 +20609,7 @@ cp_parser_omp_clause_nowait (cp_parser *parser ATTRIBUTE_UNUSED, check_no_duplicate_clause (list, OMP_CLAUSE_NOWAIT, "nowait", location); - c = build_omp_clause (OMP_CLAUSE_NOWAIT); + c = build_omp_clause (location, OMP_CLAUSE_NOWAIT); OMP_CLAUSE_CHAIN (c) = list; return c; } @@ -20628,7 +20637,7 @@ cp_parser_omp_clause_num_threads (cp_parser *parser, tree list, check_no_duplicate_clause (list, OMP_CLAUSE_NUM_THREADS, "num_threads", location); - c = build_omp_clause (OMP_CLAUSE_NUM_THREADS); + c = build_omp_clause (location, OMP_CLAUSE_NUM_THREADS); OMP_CLAUSE_NUM_THREADS_EXPR (c) = t; OMP_CLAUSE_CHAIN (c) = list; @@ -20647,7 +20656,7 @@ cp_parser_omp_clause_ordered (cp_parser *parser ATTRIBUTE_UNUSED, check_no_duplicate_clause (list, OMP_CLAUSE_ORDERED, "ordered", location); - c = build_omp_clause (OMP_CLAUSE_ORDERED); + c = build_omp_clause (location, OMP_CLAUSE_ORDERED); OMP_CLAUSE_CHAIN (c) = list; return c; } @@ -20729,7 +20738,7 @@ cp_parser_omp_clause_schedule (cp_parser *parser, tree list, location_t location if (!cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>")) return list; - c = build_omp_clause (OMP_CLAUSE_SCHEDULE); + c = build_omp_clause (location, OMP_CLAUSE_SCHEDULE); if (cp_lexer_next_token_is (parser->lexer, CPP_NAME)) { @@ -20817,7 +20826,7 @@ cp_parser_omp_clause_untied (cp_parser *parser ATTRIBUTE_UNUSED, check_no_duplicate_clause (list, OMP_CLAUSE_UNTIED, "untied", location); - c = build_omp_clause (OMP_CLAUSE_UNTIED); + c = build_omp_clause (location, OMP_CLAUSE_UNTIED); OMP_CLAUSE_CHAIN (c) = list; return c; } @@ -21110,7 +21119,7 @@ cp_parser_omp_critical (cp_parser *parser, cp_token *pragma_tok) cp_parser_require_pragma_eol (parser, pragma_tok); stmt = cp_parser_omp_structured_block (parser); - return c_finish_omp_critical (stmt, name); + return c_finish_omp_critical (input_location, stmt, name); } /* OpenMP 2.5: @@ -21487,7 +21496,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses) { /* Add lastprivate (decl) clause to OMP_FOR_CLAUSES, change it to shared (decl) in OMP_PARALLEL_CLAUSES. */ - tree l = build_omp_clause (OMP_CLAUSE_LASTPRIVATE); + tree l = build_omp_clause (loc, OMP_CLAUSE_LASTPRIVATE); OMP_CLAUSE_DECL (l) = real_decl; OMP_CLAUSE_CHAIN (l) = clauses; CP_OMP_CLAUSE_INFO (l) = CP_OMP_CLAUSE_INFO (*c); @@ -21525,7 +21534,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses) } if (c == NULL) { - c = build_omp_clause (OMP_CLAUSE_PRIVATE); + c = build_omp_clause (loc, OMP_CLAUSE_PRIVATE); OMP_CLAUSE_DECL (c) = decl; c = finish_omp_clauses (c); if (c) @@ -21692,7 +21701,8 @@ static tree cp_parser_omp_master (cp_parser *parser, cp_token *pragma_tok) { cp_parser_require_pragma_eol (parser, pragma_tok); - return c_finish_omp_master (cp_parser_omp_structured_block (parser)); + return c_finish_omp_master (input_location, + cp_parser_omp_structured_block (parser)); } /* OpenMP 2.5: @@ -21702,8 +21712,9 @@ cp_parser_omp_master (cp_parser *parser, cp_token *pragma_tok) static tree cp_parser_omp_ordered (cp_parser *parser, cp_token *pragma_tok) { + location_t loc = cp_lexer_peek_token (parser->lexer)->location; cp_parser_require_pragma_eol (parser, pragma_tok); - return c_finish_omp_ordered (cp_parser_omp_structured_block (parser)); + return c_finish_omp_ordered (loc, cp_parser_omp_structured_block (parser)); } /* OpenMP 2.5: @@ -21838,6 +21849,7 @@ cp_parser_omp_parallel (cp_parser *parser, cp_token *pragma_tok) tree stmt, clauses, par_clause, ws_clause, block; unsigned int mask = OMP_PARALLEL_CLAUSE_MASK; unsigned int save; + location_t loc = cp_lexer_peek_token (parser->lexer)->location; if (cp_lexer_next_token_is_keyword (parser->lexer, RID_FOR)) { @@ -21873,12 +21885,12 @@ cp_parser_omp_parallel (cp_parser *parser, cp_token *pragma_tok) break; case PRAGMA_OMP_PARALLEL_FOR: - c_split_parallel_clauses (clauses, &par_clause, &ws_clause); + c_split_parallel_clauses (loc, clauses, &par_clause, &ws_clause); cp_parser_omp_for_loop (parser, ws_clause, &par_clause); break; case PRAGMA_OMP_PARALLEL_SECTIONS: - c_split_parallel_clauses (clauses, &par_clause, &ws_clause); + c_split_parallel_clauses (loc, clauses, &par_clause, &ws_clause); stmt = cp_parser_omp_sections_scope (parser); if (stmt) OMP_SECTIONS_CLAUSES (stmt) = ws_clause; |