diff options
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/c/c-objc-common.h | 2 | ||||
-rw-r--r-- | gcc/c/c-parser.c | 20 | ||||
-rw-r--r-- | gcc/c/c-typeck.c | 8 |
4 files changed, 38 insertions, 1 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 14d7f63..f981266 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,12 @@ +2017-12-12 Alexandre Oliva <aoliva@redhat.com> + + * c-objc-common.h (LANG_HOOKS_EMITS_BEGIN_STMT): Redefine as true. + * c-parser.c (add_debug_begin_stmt): New. + (c_parser_declaration_or_fndef): Call it. + (c_parser_compound_statement_nostart): Likewise. + (c_parser_statement_after_labels): Likewise. + * c-typeck (c_finish_stmt_expr): Skip begin stmts markers. + 2017-12-07 Joseph Myers <joseph@codesourcery.com> * c-decl.c (build_compound_literal): Add parameter alignas_align diff --git a/gcc/c/c-objc-common.h b/gcc/c/c-objc-common.h index bee06e9..27ceabc 100644 --- a/gcc/c/c-objc-common.h +++ b/gcc/c/c-objc-common.h @@ -60,6 +60,8 @@ along with GCC; see the file COPYING3. If not see #define LANG_HOOKS_BUILTIN_FUNCTION c_builtin_function #undef LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE #define LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE c_builtin_function_ext_scope +#undef LANG_HOOKS_EMITS_BEGIN_STMT +#define LANG_HOOKS_EMITS_BEGIN_STMT true /* Attribute hooks. */ #undef LANG_HOOKS_COMMON_ATTRIBUTE_TABLE diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index d398548..f1bae8a 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -1649,6 +1649,19 @@ c_parser_external_declaration (c_parser *parser) static void c_finish_omp_declare_simd (c_parser *, tree, tree, vec<c_token>); static void c_finish_oacc_routine (struct oacc_routine_data *, tree, bool); +/* Build and add a DEBUG_BEGIN_STMT statement with location LOC. */ + +static void +add_debug_begin_stmt (location_t loc) +{ + if (!MAY_HAVE_DEBUG_MARKER_STMTS) + return; + + tree stmt = build0 (DEBUG_BEGIN_STMT, void_type_node); + SET_EXPR_LOCATION (stmt, loc); + add_stmt (stmt); +} + /* Parse a declaration or function definition (C90 6.5, 6.7.1, C99 6.7, 6.9.1, C11 6.7, 6.9.1). If FNDEF_OK is true, a function definition is accepted; otherwise (old-style parameter declarations) only other @@ -1749,6 +1762,8 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, bool diagnosed_no_specs = false; location_t here = c_parser_peek_token (parser)->location; + add_debug_begin_stmt (c_parser_peek_token (parser)->location); + if (static_assert_ok && c_parser_next_token_is_keyword (parser, RID_STATIC_ASSERT)) { @@ -4911,6 +4926,7 @@ c_parser_compound_statement_nostart (c_parser *parser) location_t label_loc = UNKNOWN_LOCATION; /* Quiet warning. */ if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE)) { + add_debug_begin_stmt (c_parser_peek_token (parser)->location); c_parser_consume_token (parser); return; } @@ -5365,6 +5381,10 @@ c_parser_statement_after_labels (c_parser *parser, bool *if_p, parser->in_if_block = false; if (if_p != NULL) *if_p = false; + + if (c_parser_peek_token (parser)->type != CPP_OPEN_BRACE) + add_debug_begin_stmt (loc); + switch (c_parser_peek_token (parser)->type) { case CPP_OPEN_BRACE: diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 676dbbd..13b2684 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -10710,6 +10710,10 @@ c_finish_stmt_expr (location_t loc, tree body) } else i = tsi_last (last); + if (TREE_CODE (tsi_stmt (i)) == DEBUG_BEGIN_STMT) + do + tsi_prev (&i); + while (TREE_CODE (tsi_stmt (i)) == DEBUG_BEGIN_STMT); last_p = tsi_stmt_ptr (i); last = *last_p; } @@ -10729,7 +10733,9 @@ c_finish_stmt_expr (location_t loc, tree body) /* In the case that the BIND_EXPR is not necessary, return the expression out from inside it. */ - if (last == BIND_EXPR_BODY (body) + if ((last == BIND_EXPR_BODY (body) + /* Skip nested debug stmts. */ + || last == expr_first (BIND_EXPR_BODY (body))) && BIND_EXPR_VARS (body) == NULL) { /* Even if this looks constant, do not allow it in a constant |