diff options
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 89 |
1 files changed, 40 insertions, 49 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 17b625f668c..21f82548eaa 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -51,6 +51,7 @@ Boston, MA 02111-1307, USA. */ #include "diagnostic.h" #include "debug.h" #include "timevar.h" +#include "tree-flow.h" static tree grokparms (tree, tree *); static const char *redeclaration_error_message (tree, tree); @@ -114,7 +115,6 @@ static tree check_special_function_return_type static tree push_cp_library_fn (enum tree_code, tree); static tree build_cp_library_fn (tree, enum tree_code, tree); static void store_parm_decls (tree); -static int cp_missing_noreturn_ok_p (tree); static void initialize_local_var (tree, tree); static void expand_static_init (tree, tree); static tree next_initializable_field (tree); @@ -499,28 +499,6 @@ poplevel (int keep, int reverse, int functionbody) else decls = current_binding_level->names; - /* Output any nested inline functions within this block - if they weren't already output. */ - for (decl = decls; decl; decl = TREE_CHAIN (decl)) - if (TREE_CODE (decl) == FUNCTION_DECL - && ! TREE_ASM_WRITTEN (decl) - && DECL_INITIAL (decl) != NULL_TREE - && TREE_ADDRESSABLE (decl) - && decl_function_context (decl) == current_function_decl) - { - /* If this decl was copied from a file-scope decl - on account of a block-scope extern decl, - propagate TREE_ADDRESSABLE to the file-scope decl. */ - if (DECL_ABSTRACT_ORIGIN (decl) != NULL_TREE) - TREE_ADDRESSABLE (DECL_ABSTRACT_ORIGIN (decl)) = 1; - else - { - push_function_context (); - output_inline_function (decl); - pop_function_context (); - } - } - /* When not in function-at-a-time mode, expand_end_bindings will warn about unused variables. But, in function-at-a-time mode expand_end_bindings is not passed the list of variables in the @@ -2406,9 +2384,11 @@ push_switch (tree switch_stmt) void pop_switch (void) { - struct cp_switch *cs; + struct cp_switch *cs = switch_stack; + + /* Emit warnings as needed. */ + c_do_switch_warnings (cs->cases, cs->switch_stmt); - cs = switch_stack; splay_tree_delete (cs->cases); switch_stack = switch_stack->next; free (cs); @@ -2878,9 +2858,6 @@ cxx_init_decl_processing (void) /* Create all the identifiers we need. */ initialize_predefined_identifiers (); - /* Fill in back-end hooks. */ - lang_missing_noreturn_ok_p = &cp_missing_noreturn_ok_p; - /* Create the global variables. */ push_to_top_level (); @@ -3060,7 +3037,8 @@ cxx_init_decl_processing (void) start_fname_decls (); /* Show we use EH for cleanups. */ - using_eh_for_cleanups (); + if (flag_exceptions) + using_eh_for_cleanups (); } /* Generate an initializer for a function naming variable from @@ -4544,7 +4522,7 @@ make_rtl_for_nonlocal_decl (tree decl, tree init, const char* asmspec) asm-specification, indicates that the variable should be placed in a particular register. */ if (DECL_REGISTER (decl)) - DECL_C_HARD_REGISTER (decl) = 1; + DECL_HARD_REGISTER (decl) = 1; } /* We don't create any RTL for local variables. */ @@ -7283,6 +7261,13 @@ grokdeclarator (tree declarator, type = create_array_type_for_decl (dname, type, size); + if (declarator + && (TREE_CODE (declarator) == INDIRECT_REF + || TREE_CODE (declarator) == ADDR_EXPR)) + /* We can never complete an array type which is the target of a + pointer, so go ahead and lay it out. */ + layout_type (type); + ctype = NULL_TREE; } break; @@ -7768,6 +7753,7 @@ grokdeclarator (tree declarator, } if (declarator == NULL_TREE + || TREE_CODE (declarator) == ERROR_MARK || TREE_CODE (declarator) == IDENTIFIER_NODE || (TREE_CODE (declarator) == TEMPLATE_ID_EXPR && (TREE_CODE (type) == FUNCTION_TYPE @@ -9935,7 +9921,9 @@ build_enumerator (tree name, tree value, tree enumtype) decl = build_decl (CONST_DECL, name, type); DECL_CONTEXT (decl) = FROB_CONTEXT (context); - TREE_CONSTANT (decl) = TREE_READONLY (decl) = 1; + TREE_CONSTANT (decl) = 1; + TREE_INVARIANT (decl) = 1; + TREE_READONLY (decl) = 1; DECL_INITIAL (decl) = value; if (context && context == current_class_type) @@ -10730,10 +10718,8 @@ finish_function (int flags) of curly braces for a function. */ my_friendly_assert (stmts_are_full_exprs_p (), 19990831); - /* Set up the named return value optimization, if we can. Here, we - eliminate the copy from the nrv into the RESULT_DECL and any cleanup - for the nrv. genrtl_start_function and declare_return_variable - handle making the nrv and RESULT_DECL share space. */ + /* Set up the named return value optimization, if we can. Candidate + variables are selected in check_return_value. */ if (current_function_return_value) { tree r = current_function_return_value; @@ -10750,16 +10736,9 @@ finish_function (int flags) /* Skip the artificial function body block. */ && (outer = BLOCK_SUBBLOCKS (BLOCK_SUBBLOCKS (DECL_INITIAL (fndecl))), chain_member (r, BLOCK_VARS (outer)))) - { - - DECL_ALIGN (r) = DECL_ALIGN (DECL_RESULT (fndecl)); - walk_tree_without_duplicates (&DECL_SAVED_TREE (fndecl), - nullify_returns_r, r); - } - else - /* Clear it so genrtl_start_function and declare_return_variable - know we're not optimizing. */ - current_function_return_value = NULL_TREE; + finalize_nrv (&DECL_SAVED_TREE (fndecl), r, DECL_RESULT (fndecl)); + + current_function_return_value = NULL_TREE; } /* Remember that we were in class scope. */ @@ -10802,9 +10781,21 @@ finish_function (int flags) && (DECL_INLINE (fndecl) || processing_template_decl)) warning ("no return statement in function returning non-void"); - /* We're leaving the context of this function, so zap cfun. - It's still in DECL_STRUCT_FUNCTION, and we'll restore it in - tree_rest_of_compilation. */ + /* Store the end of the function, so that we get good line number + info for the epilogue. */ + cfun->function_end_locus = input_location; + + /* Genericize before inlining. */ + if (!processing_template_decl) + { + c_genericize (fndecl); + + /* Handle attribute((warn_unused_result)). Relies on gimple input. */ + c_warn_unused_result (&DECL_SAVED_TREE (fndecl)); + } + + /* We're leaving the context of this function, so zap cfun. It's still in + DECL_STRUCT_FUNCTION, and we'll restore it in tree_rest_of_compilation. */ cfun = NULL; current_function_decl = NULL; @@ -11178,7 +11169,7 @@ build_void_list_node (void) return t; } -static int +bool cp_missing_noreturn_ok_p (tree decl) { /* A missing noreturn is ok for the `main' function. */ |