diff options
Diffstat (limited to 'contrib/gcc/cp/decl.c')
-rw-r--r-- | contrib/gcc/cp/decl.c | 102 |
1 files changed, 43 insertions, 59 deletions
diff --git a/contrib/gcc/cp/decl.c b/contrib/gcc/cp/decl.c index 03b9008..559e4e2 100644 --- a/contrib/gcc/cp/decl.c +++ b/contrib/gcc/cp/decl.c @@ -20,6 +20,8 @@ along with GNU CC; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $FreeBSD$ */ + /* Process declarations and symbol lookup for C front end. Also constructs types; the standard scalar types at initialization, @@ -52,6 +54,13 @@ Boston, MA 02111-1307, USA. */ #include "timevar.h" #include "input.h" +#ifndef HOST_PTR_PRINTF_FORMAT +#define HOST_PTR_PRINTF_FORMAT HOST_PTR_PRINTF +#endif +#ifndef HOST_PTR_PRINTF_TYPE +#define HOST_PTR_PRINTF_TYPE (void *) +#endif + static tree grokparms PARAMS ((tree)); static const char *redeclaration_error_message PARAMS ((tree, tree)); @@ -72,7 +81,7 @@ static tree lookup_tag_reverse PARAMS ((tree, tree)); static tree lookup_name_real PARAMS ((tree, int, int, int)); static void push_local_name PARAMS ((tree)); static void warn_extern_redeclared_static PARAMS ((tree, tree)); -static tree grok_reference_init PARAMS ((tree, tree, tree, tree *)); +static tree grok_reference_init PARAMS ((tree, tree, tree)); static tree grokfndecl PARAMS ((tree, tree, tree, tree, int, enum overload_flags, tree, tree, int, int, int, int, int, int, tree)); @@ -123,7 +132,7 @@ static void pop_labels PARAMS ((tree)); static void maybe_deduce_size_from_array_init PARAMS ((tree, tree)); static void layout_var_decl PARAMS ((tree)); static void maybe_commonize_var PARAMS ((tree)); -static tree check_initializer (tree, tree, int, tree *); +static tree check_initializer (tree, tree, int); static void make_rtl_for_nonlocal_decl PARAMS ((tree, tree, const char *)); static void save_function_data PARAMS ((tree)); static void check_function_type PARAMS ((tree, tree)); @@ -461,7 +470,7 @@ binding_table_reverse_maybe_remap (binding_table table, tree type, tree name) { const size_t chain_count = table->chain_count; binding_entry entry = NULL; - binding_entry *p = NULL; + binding_entry *p; size_t i; for (i = 0; i < chain_count && entry == NULL; ++i) @@ -922,14 +931,6 @@ kept_level_p () && !current_binding_level->tag_transparent)); } -/* Returns the kind of the innermost scope. */ - -bool -innermost_scope_is_class_p () -{ - return current_binding_level->parm_flag == 2; -} - static void declare_namespace_level () { @@ -2230,7 +2231,7 @@ print_binding_level (lvl) tree t; int i = 0, len; fprintf (stderr, " blocks="); - fprintf (stderr, HOST_PTR_PRINTF, lvl->blocks); + fprintf (stderr, HOST_PTR_PRINTF_FORMAT, HOST_PTR_PRINTF_TYPE lvl->blocks); if (lvl->tag_transparent) fprintf (stderr, " tag-transparent"); if (lvl->more_cleanups_ok) @@ -2305,7 +2306,7 @@ print_other_binding_stack (stack) for (level = stack; !global_scope_p (level); level = level->level_chain) { fprintf (stderr, "binding level "); - fprintf (stderr, HOST_PTR_PRINTF, level); + fprintf (stderr, HOST_PTR_PRINTF_FORMAT, HOST_PTR_PRINTF_TYPE level); fprintf (stderr, "\n"); print_binding_level (level); } @@ -2316,12 +2317,12 @@ print_binding_stack () { struct cp_binding_level *b; fprintf (stderr, "current_binding_level="); - fprintf (stderr, HOST_PTR_PRINTF, current_binding_level); + fprintf (stderr, HOST_PTR_PRINTF_FORMAT, HOST_PTR_PRINTF_TYPE current_binding_level); fprintf (stderr, "\nclass_binding_level="); - fprintf (stderr, HOST_PTR_PRINTF, class_binding_level); + fprintf (stderr, HOST_PTR_PRINTF_FORMAT, HOST_PTR_PRINTF_TYPE class_binding_level); fprintf (stderr, "\nNAMESPACE_LEVEL (global_namespace)="); - fprintf (stderr, HOST_PTR_PRINTF, - (void *) NAMESPACE_LEVEL (global_namespace)); + fprintf (stderr, HOST_PTR_PRINTF_FORMAT, + HOST_PTR_PRINTF_TYPE NAMESPACE_LEVEL (global_namespace)); fprintf (stderr, "\n"); if (class_binding_level) { @@ -3388,9 +3389,9 @@ duplicate_decls (newdecl, olddecl) if (DECL_ANTICIPATED (olddecl)) ; /* Do nothing yet. */ else if ((DECL_EXTERN_C_P (newdecl) - && DECL_EXTERN_C_P (olddecl)) - || compparms (TYPE_ARG_TYPES (TREE_TYPE (newdecl)), - TYPE_ARG_TYPES (TREE_TYPE (olddecl)))) + && DECL_EXTERN_C_P (olddecl)) + || compparms (TYPE_ARG_TYPES (TREE_TYPE (newdecl)), + TYPE_ARG_TYPES (TREE_TYPE (olddecl)))) { /* A near match; override the builtin. */ @@ -3417,10 +3418,6 @@ duplicate_decls (newdecl, olddecl) else if (DECL_ANTICIPATED (olddecl)) TREE_TYPE (olddecl) = TREE_TYPE (newdecl); - /* Whether or not the builtin can throw exceptions has no - bearing on this declarator. */ - TREE_NOTHROW (olddecl) = 0; - if (DECL_THIS_STATIC (newdecl) && !DECL_THIS_STATIC (olddecl)) { /* If a builtin function is redeclared as `static', merge @@ -5410,7 +5407,8 @@ check_goto (decl) } /* Define a label, specifying the location in the source file. - Return the LABEL_DECL node for the label. */ + Return the LABEL_DECL node for the label, if the definition is valid. + Otherwise return 0. */ tree define_label (filename, line, name) @@ -5437,7 +5435,10 @@ define_label (filename, line, name) pedwarn ("label named wchar_t"); if (DECL_INITIAL (decl) != NULL_TREE) - error ("duplicate label `%D'", decl); + { + error ("duplicate label `%D'", decl); + POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE); + } else { /* Mark label as having been defined. */ @@ -5451,10 +5452,9 @@ define_label (filename, line, name) ent->binding_level = current_binding_level; } check_previous_gotos (decl); + POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, decl); } - timevar_pop (TV_NAME_LOOKUP); - return decl; } struct cp_switch @@ -7908,18 +7908,15 @@ start_decl_1 (decl) DECL_INITIAL (decl) = NULL_TREE; } -/* Handle initialization of references. DECL, TYPE, and INIT have the - same meaning as in cp_finish_decl. *CLEANUP must be NULL on entry, - but will be set to a new CLEANUP_STMT if a temporary is created - that must be destroeyd subsequently. - - Returns an initializer expression to use to initialize DECL, or - NULL if the initialization can be performed statically. +/* Handle initialization of references. + These three arguments are from `cp_finish_decl', and have the + same meaning here that they do there. Quotes on semantics can be found in ARM 8.4.3. */ - + static tree -grok_reference_init (tree decl, tree type, tree init, tree *cleanup) +grok_reference_init (decl, type, init) + tree decl, type, init; { tree tmp; @@ -7961,7 +7958,7 @@ grok_reference_init (tree decl, tree type, tree init, tree *cleanup) DECL_INITIAL for local references (instead assigning to them explicitly); we need to allow the temporary to be initialized first. */ - tmp = initialize_reference (type, init, decl, cleanup); + tmp = initialize_reference (type, init, decl); if (tmp == error_mark_node) return NULL_TREE; @@ -8392,14 +8389,13 @@ reshape_init (tree type, tree *initp) } /* Verify INIT (the initializer for DECL), and record the - initialization in DECL_INITIAL, if appropriate. CLEANUP is as for - grok_reference_init. + initialization in DECL_INITIAL, if appropriate. If the return value is non-NULL, it is an expression that must be evaluated dynamically to initialize DECL. */ static tree -check_initializer (tree decl, tree init, int flags, tree *cleanup) +check_initializer (tree decl, tree init, int flags) { tree type = TREE_TYPE (decl); @@ -8449,7 +8445,7 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup) init = NULL_TREE; } else if (!DECL_EXTERNAL (decl) && TREE_CODE (type) == REFERENCE_TYPE) - init = grok_reference_init (decl, type, init, cleanup); + init = grok_reference_init (decl, type, init); else if (init) { if (TREE_CODE (init) == CONSTRUCTOR && TREE_HAS_CONSTRUCTOR (init)) @@ -8758,9 +8754,8 @@ cp_finish_decl (decl, init, asmspec_tree, flags) tree asmspec_tree; int flags; { - tree type; + register tree type; tree ttype = NULL_TREE; - tree cleanup; const char *asmspec = NULL; int was_readonly = 0; @@ -8771,9 +8766,6 @@ cp_finish_decl (decl, init, asmspec_tree, flags) return; } - /* Assume no cleanup is required. */ - cleanup = NULL_TREE; - /* If a name was specified, get the string. */ if (global_scope_p (current_binding_level)) asmspec_tree = maybe_apply_renaming_pragma (decl, asmspec_tree); @@ -8874,7 +8866,7 @@ cp_finish_decl (decl, init, asmspec_tree, flags) make_decl_rtl (decl, asmspec); } else if (TREE_CODE (decl) == RESULT_DECL) - init = check_initializer (decl, init, flags, &cleanup); + init = check_initializer (decl, init, flags); else if (TREE_CODE (decl) == VAR_DECL) { /* Only PODs can have thread-local storage. Other types may require @@ -8891,7 +8883,7 @@ cp_finish_decl (decl, init, asmspec_tree, flags) is *not* defined. */ && (!DECL_EXTERNAL (decl) || init)) { - init = check_initializer (decl, init, flags, &cleanup); + init = check_initializer (decl, init, flags); /* Thread-local storage cannot be dynamically initialized. */ if (DECL_THREAD_LOCAL (decl) && init) { @@ -9010,11 +9002,6 @@ cp_finish_decl (decl, init, asmspec_tree, flags) } } - /* If a CLEANUP_STMT was created to destroy a temporary bound to a - reference, insert it in the statement-tree now. */ - if (cleanup) - add_stmt (cleanup); - finish_end: if (was_readonly) @@ -12337,10 +12324,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) members of other classes. */ /* All method decls are public, so tell grokfndecl to set TREE_PUBLIC, also. */ - decl = grokfndecl (ctype, type, - TREE_CODE (declarator) != TEMPLATE_ID_EXPR - ? declarator : dname, - declarator, + decl = grokfndecl (ctype, type, declarator, declarator, virtualp, flags, quals, raises, friendp ? -1 : 0, friendp, 1, 0, funcdef_flag, template_count, in_namespace); @@ -14289,7 +14273,7 @@ start_function (declspecs, declarator, attrs, flags) } else { - decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, &attrs); + decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, NULL); /* If the declarator is not suitable for a function definition, cause a syntax error. */ if (decl1 == NULL_TREE || TREE_CODE (decl1) != FUNCTION_DECL) |