From 90e3c064aa9d5812f597ee1865ec169bd86436cc Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Fri, 6 Oct 2017 16:26:00 +0000 Subject: re PR c++/47791 (finish function is using literal value instead of a #defined one) 2017-10-06 Paolo Carlini PR c++/47791 * decl.c (finish_function): Take a bool intead of an int; adjust. * cp-tree.h (finish_function): Adjust declaration. * decl2.c (generate_tls_wrapper, finish_objects, finish_static_storage_duration_function): Adjust calls. * lambda.c (maybe_add_lambda_conv_op, finish_lambda_function): Likewise. * method.c (synthesize_method): Likewise. * optimize.c (maybe_thunk_body, maybe_clone_body): Likewise. * pt.c (instantiate_decl): Likewise. * parser.c (cp_parser_function_definition_after_declarator, cp_parser_late_parsing_for_member, cp_parser_omp_declare_reduction): Likewise. (cp_parser_ctor_initializer_opt, cp_parser_ctor_initializer_opt_and_function_body, cp_parser_function_try_block, cp_parser_function_definition_after_declarator, cp_parser_function_transaction): Return void; adjust declarations. From-SVN: r253497 --- gcc/cp/ChangeLog | 21 ++++++++++++++++++ gcc/cp/cp-tree.h | 2 +- gcc/cp/decl.c | 18 ++++++---------- gcc/cp/decl2.c | 10 ++++----- gcc/cp/lambda.c | 6 +++--- gcc/cp/method.c | 2 +- gcc/cp/optimize.c | 4 ++-- gcc/cp/parser.c | 64 ++++++++++++++++++++----------------------------------- gcc/cp/pt.c | 2 +- 9 files changed, 64 insertions(+), 65 deletions(-) (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b2813eb..6e18dd2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,24 @@ +2017-10-06 Paolo Carlini + + PR c++/47791 + * decl.c (finish_function): Take a bool intead of an int; adjust. + * cp-tree.h (finish_function): Adjust declaration. + * decl2.c (generate_tls_wrapper, finish_objects, + finish_static_storage_duration_function): Adjust calls. + * lambda.c (maybe_add_lambda_conv_op, finish_lambda_function): + Likewise. + * method.c (synthesize_method): Likewise. + * optimize.c (maybe_thunk_body, maybe_clone_body): Likewise. + * pt.c (instantiate_decl): Likewise. + * parser.c (cp_parser_function_definition_after_declarator, + cp_parser_late_parsing_for_member, cp_parser_omp_declare_reduction): + Likewise. + (cp_parser_ctor_initializer_opt, + cp_parser_ctor_initializer_opt_and_function_body, + cp_parser_function_try_block, + cp_parser_function_definition_after_declarator, + cp_parser_function_transaction): Return void; adjust declarations. + 2017-10-06 Nathan Sidwell PR c++/82424 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index cac5f3d..b29e4e0 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -6125,7 +6125,7 @@ extern bool start_function (cp_decl_specifier_seq *, extern tree begin_function_body (void); extern void finish_function_body (tree); extern tree outer_curly_brace_block (tree); -extern tree finish_function (int); +extern tree finish_function (bool); extern tree grokmethod (cp_decl_specifier_seq *, const cp_declarator *, tree); extern void maybe_register_incomplete_var (tree); extern void maybe_commonize_var (tree); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 6f36aa1..0e70bb5 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7827,7 +7827,7 @@ start_cleanup_fn (void) static void end_cleanup_fn (void) { - expand_or_defer_fn (finish_function (0)); + expand_or_defer_fn (finish_function (/*inline_p=*/false)); pop_from_top_level (); } @@ -15459,20 +15459,16 @@ maybe_save_function_definition (tree fun) /* Finish up a function declaration and compile that function all the way to assembler language output. The free the storage - for the function definition. - - FLAGS is a bitwise or of the following values: - 2 - INCLASS_INLINE - We just finished processing the body of an in-class inline - function definition. (This processing will have taken place - after the class definition is complete.) */ + for the function definition. INLINE_P is TRUE if we just + finished processing the body of an in-class inline function + definition. (This processing will have taken place after the + class definition is complete.) */ tree -finish_function (int flags) +finish_function (bool inline_p) { tree fndecl = current_function_decl; tree fntype, ctype = NULL_TREE; - int inclass_inline = (flags & 2) != 0; /* When we get some parse errors, we can end up without a current_function_decl, so cope. */ @@ -15732,7 +15728,7 @@ finish_function (int flags) bindings for the template parameters that we added in maybe_begin_member_template_processing when start_function was called. */ - if (inclass_inline) + if (inline_p) maybe_end_member_template_processing (); /* Leave the scope of the class. */ diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index ee4c800..1cbd11d 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -3328,7 +3328,7 @@ generate_tls_wrapper (tree fn) TREE_READONLY (fn) = true; finish_return_stmt (convert_from_reference (var)); finish_function_body (body); - expand_or_defer_fn (finish_function (0)); + expand_or_defer_fn (finish_function (/*inline_p=*/false)); } /* Start the process of running a particular set of global constructors @@ -3395,7 +3395,7 @@ finish_objects (int method_type, int initp, tree body) /* Finish up. */ finish_compound_stmt (body); - fn = finish_function (0); + fn = finish_function (/*inline_p=*/false); if (method_type == 'I') { @@ -3535,7 +3535,7 @@ finish_static_storage_duration_function (tree body) { /* Close out the function. */ finish_compound_stmt (body); - expand_or_defer_fn (finish_function (0)); + expand_or_defer_fn (finish_function (/*inline_p=*/false)); } /* Return the information about the indicated PRIORITY level. If no @@ -4284,7 +4284,7 @@ handle_tls_init (void) finish_then_clause (if_stmt); finish_if_stmt (if_stmt); finish_function_body (body); - expand_or_defer_fn (finish_function (0)); + expand_or_defer_fn (finish_function (/*inline_p=*/false)); } /* We're at the end of compilation, so generate any mangling aliases that @@ -5249,7 +5249,7 @@ vtv_finish_verification_constructor_init_function (tree function_body) tree fn; finish_compound_stmt (function_body); - fn = finish_function (0); + fn = finish_function (/*inline_p=*/false); DECL_STATIC_CONSTRUCTOR (fn) = 1; decl_init_priority_insert (fn, MAX_RESERVED_INIT_PRIORITY - 1); diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index 66d510e..78bd897 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -1223,7 +1223,7 @@ maybe_add_lambda_conv_op (tree type) finish_compound_stmt (compound_stmt); finish_function_body (body); - fn = finish_function (/*inline*/2); + fn = finish_function (/*inline_p=*/true); if (!generic_lambda_p) expand_or_defer_fn (fn); @@ -1241,7 +1241,7 @@ maybe_add_lambda_conv_op (tree type) finish_compound_stmt (compound_stmt); finish_function_body (body); - fn = finish_function (/*inline*/2); + fn = finish_function (/*inline_p=*/true); if (!generic_lambda_p) expand_or_defer_fn (fn); @@ -1362,7 +1362,7 @@ finish_lambda_function (tree body) finish_function_body (body); /* Finish the function and generate code for it if necessary. */ - tree fn = finish_function (/*inline*/2); + tree fn = finish_function (/*inline_p=*/true); /* Only expand if the call op is not a template. */ if (!DECL_TEMPLATE_INFO (fn)) diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 7788afb..4e56874 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -953,7 +953,7 @@ synthesize_method (tree fndecl) } finish_function_body (stmt); - expand_or_defer_fn (finish_function (0)); + expand_or_defer_fn (finish_function (/*inline_p=*/false)); input_location = save_input_location; diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index 09ffbda..2645ae4 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -416,7 +416,7 @@ maybe_thunk_body (tree fn, bool force) } DECL_ABSTRACT_ORIGIN (clone) = NULL; - expand_or_defer_fn (finish_function (0)); + expand_or_defer_fn (finish_function (/*inline_p=*/false)); } return 1; } @@ -657,7 +657,7 @@ maybe_clone_body (tree fn) cp_function_chain->can_throw = !TREE_NOTHROW (fn); /* Now, expand this function into RTL, if appropriate. */ - finish_function (0); + finish_function (/*inline_p=*/false); BLOCK_ABSTRACT_ORIGIN (DECL_INITIAL (clone)) = DECL_INITIAL (fn); if (alias) { diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 3b0ee39..7883c64 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -2257,7 +2257,7 @@ static cp_expr cp_parser_braced_list static vec *cp_parser_initializer_list (cp_parser *, bool *); -static bool cp_parser_ctor_initializer_opt_and_function_body +static void cp_parser_ctor_initializer_opt_and_function_body (cp_parser *, bool); static tree cp_parser_late_parsing_omp_declare_simd @@ -2310,7 +2310,7 @@ static tree cp_parser_conversion_type_id (cp_parser *); static cp_declarator *cp_parser_conversion_declarator_opt (cp_parser *); -static bool cp_parser_ctor_initializer_opt +static void cp_parser_ctor_initializer_opt (cp_parser *); static void cp_parser_mem_initializer_list (cp_parser *); @@ -2353,7 +2353,7 @@ static void cp_parser_explicit_specialization static tree cp_parser_try_block (cp_parser *); -static bool cp_parser_function_try_block +static void cp_parser_function_try_block (cp_parser *); static void cp_parser_handler_seq (cp_parser *); @@ -2438,7 +2438,7 @@ static tree cp_parser_transaction (cp_parser *, cp_token *); static tree cp_parser_transaction_expression (cp_parser *, enum rid); -static bool cp_parser_function_transaction +static void cp_parser_function_transaction (cp_parser *, enum rid); static tree cp_parser_transaction_cancel (cp_parser *); @@ -14253,11 +14253,9 @@ 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. */ - -static bool +static void cp_parser_ctor_initializer_opt (cp_parser* parser) { /* If the next token is not a `:', then there is no @@ -14267,16 +14265,13 @@ cp_parser_ctor_initializer_opt (cp_parser* parser) /* Do default initialization of any bases and members. */ if (DECL_CONSTRUCTOR_P (current_function_decl)) finish_mem_initializers (NULL_TREE); - - return false; + return; } /* Consume the `:' token. */ cp_lexer_consume_token (parser->lexer); /* And the mem-initializer-list. */ cp_parser_mem_initializer_list (parser); - - return true; } /* Parse a mem-initializer-list. @@ -21701,12 +21696,11 @@ cp_parser_function_body (cp_parser *parser, bool in_function_try_block) true if a ctor-initializer was present. When IN_FUNCTION_TRY_BLOCK is true we are parsing a function-try-block. */ -static bool +static void cp_parser_ctor_initializer_opt_and_function_body (cp_parser *parser, bool in_function_try_block) { tree body, list; - bool ctor_initializer_p; const bool check_body_p = DECL_CONSTRUCTOR_P (current_function_decl) && DECL_DECLARED_CONSTEXPR_P (current_function_decl); @@ -21715,7 +21709,7 @@ cp_parser_ctor_initializer_opt_and_function_body (cp_parser *parser, /* Begin the function body. */ body = begin_function_body (); /* Parse the optional ctor-initializer. */ - ctor_initializer_p = cp_parser_ctor_initializer_opt (parser); + cp_parser_ctor_initializer_opt (parser); /* If we're parsing a constexpr constructor definition, we need to check that the constructor body is indeed empty. However, @@ -21735,8 +21729,6 @@ cp_parser_ctor_initializer_opt_and_function_body (cp_parser *parser, check_constexpr_ctor_body (last, list, /*complain=*/true); /* Finish the function body. */ finish_function_body (body); - - return ctor_initializer_p; } /* Parse an initializer. @@ -24364,20 +24356,19 @@ cp_parser_try_block (cp_parser* parser) function-try-block: try ctor-initializer [opt] function-body handler-seq */ -static bool +static void cp_parser_function_try_block (cp_parser* parser) { tree compound_stmt; tree try_block; - bool ctor_initializer_p; /* Look for the `try' keyword. */ if (!cp_parser_require_keyword (parser, RID_TRY, RT_TRY)) - return false; + return; /* Let the rest of the front end know where we are. */ try_block = begin_function_try_block (&compound_stmt); /* Parse the function-body. */ - ctor_initializer_p = cp_parser_ctor_initializer_opt_and_function_body + cp_parser_ctor_initializer_opt_and_function_body (parser, /*in_function_try_block=*/true); /* We're done with the `try' part. */ finish_function_try_block (try_block); @@ -24385,8 +24376,6 @@ cp_parser_function_try_block (cp_parser* parser) cp_parser_handler_seq (parser); /* We're done with the handlers. */ finish_function_handler_sequence (try_block, compound_stmt); - - return ctor_initializer_p; } /* Parse a handler-seq. @@ -26561,7 +26550,6 @@ cp_parser_function_definition_after_declarator (cp_parser* parser, bool inline_p) { tree fn; - bool ctor_initializer_p = false; bool saved_in_unbraced_linkage_specification_p; bool saved_in_function_body; unsigned saved_num_template_parameter_lists; @@ -26619,21 +26607,18 @@ cp_parser_function_definition_after_declarator (cp_parser* parser, or function-transaction-block. Note that all of these include the function-body. */ if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TRANSACTION_ATOMIC)) - ctor_initializer_p = cp_parser_function_transaction (parser, - RID_TRANSACTION_ATOMIC); + cp_parser_function_transaction (parser, RID_TRANSACTION_ATOMIC); else if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TRANSACTION_RELAXED)) - ctor_initializer_p = cp_parser_function_transaction (parser, - RID_TRANSACTION_RELAXED); + cp_parser_function_transaction (parser, RID_TRANSACTION_RELAXED); else if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TRY)) - ctor_initializer_p = cp_parser_function_try_block (parser); + cp_parser_function_try_block (parser); else - ctor_initializer_p = cp_parser_ctor_initializer_opt_and_function_body + cp_parser_ctor_initializer_opt_and_function_body (parser, /*in_function_try_block=*/false); /* Finish the function. */ - fn = finish_function ((ctor_initializer_p ? 1 : 0) | - (inline_p ? 2 : 0)); + fn = finish_function (inline_p); /* Generate code for it, if necessary. */ expand_or_defer_fn (fn); /* Restore the saved values. */ @@ -27504,7 +27489,7 @@ cp_parser_late_parsing_for_member (cp_parser* parser, tree member_function) { parser->lexer->in_pragma = true; cp_parser_omp_declare_reduction_exprs (member_function, parser); - finish_function (/*inline*/2); + finish_function (/*inline_p=*/true); cp_check_omp_declare_reduction (member_function); } else @@ -37692,7 +37677,7 @@ cp_parser_omp_declare_reduction (cp_parser *parser, cp_token *pragma_tok, if (!cp_parser_omp_declare_reduction_exprs (fndecl, parser)) { if (!block_scope) - finish_function (0); + finish_function (/*inline_p=*/false); else DECL_CONTEXT (fndecl) = current_function_decl; if (cp) @@ -37702,7 +37687,7 @@ cp_parser_omp_declare_reduction (cp_parser *parser, cp_token *pragma_tok, if (cp) cp_parser_pop_lexer (parser); if (!block_scope) - finish_function (0); + finish_function (/*inline_p=*/false); else { DECL_CONTEXT (fndecl) = current_function_decl; @@ -38397,13 +38382,12 @@ cp_parser_transaction_expression (cp_parser *parser, enum rid keyword) __transaction_relaxed function-try-block */ -static bool +static void cp_parser_function_transaction (cp_parser *parser, enum rid keyword) { unsigned char old_in = parser->in_transaction; unsigned char new_in = 1; tree compound_stmt, stmt, attrs; - bool ctor_initializer_p; cp_token *token; gcc_assert (keyword == RID_TRANSACTION_ATOMIC @@ -38427,16 +38411,14 @@ cp_parser_function_transaction (cp_parser *parser, enum rid keyword) parser->in_transaction = new_in; if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TRY)) - ctor_initializer_p = cp_parser_function_try_block (parser); + cp_parser_function_try_block (parser); else - ctor_initializer_p = cp_parser_ctor_initializer_opt_and_function_body + cp_parser_ctor_initializer_opt_and_function_body (parser, /*in_function_try_block=*/false); parser->in_transaction = old_in; finish_transaction_stmt (stmt, compound_stmt, new_in, NULL_TREE); - - return ctor_initializer_p; } /* Parse a __transaction_cancel statement. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 36c8c10..52fc4d6 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -23281,7 +23281,7 @@ instantiate_decl (tree d, bool defer_ok, bool expl_inst_class_mem_p) DECL_SAVED_TREE (d) = pop_stmt_list (block); else { - d = finish_function (0); + d = finish_function (/*inline_p=*/false); expand_or_defer_fn (d); } -- cgit v1.1