diff options
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 43 | ||||
-rw-r--r-- | gcc/cp/decl.c | 4 | ||||
-rw-r--r-- | gcc/cp/error.c | 67 | ||||
-rw-r--r-- | gcc/cp/mangle.c | 5 | ||||
-rw-r--r-- | gcc/cp/method.c | 6 | ||||
-rw-r--r-- | gcc/cp/parser.c | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 10 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 10 |
8 files changed, 122 insertions, 29 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6ffebf1b0fe..3957d5ade63 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,46 @@ +2011-07-06 Jason Merrill <jason@redhat.com> + + PR c++/49353 + * semantics.c (expand_or_defer_fn_1): Clear DECL_EXTERNAL + on kept inlines. + + PR c++/49568 + * method.c (make_thunk, use_thunk): Copy DECL_COMDAT. + +2011-07-05 Jason Merrill <jason@redhat.com> + + PR c++/48157 + * pt.c (tsubst_qualified_id): Preserve TEMPLATE_ID_EXPR in + partial instantiation. + + PR c++/49598 + * semantics.c (finish_id_expression): convert_from_reference. + +2011-07-05 Richard Guenther <rguenther@suse.de> + + * decl.c (cxx_init_decl_processing): Defer building common + tree nodes to c_common_nodes_and_builtins. + +2011-07-04 Jason Merrill <jason@redhat.com> + + DR 1207 + PR c++/49589 + * mangle.c (write_expression): Handle 'this'. + * parser.c (cp_parser_postfix_dot_deref_expression): Allow + incomplete *this. + * semantics.c (potential_constant_expression_1): Check that + DECL_CONTEXT is set on 'this'. + + * error.c (dump_template_bindings): Don't print typenames + for a partial instantiation. + (dump_function_decl): If we aren't printing function arguments, + print template arguments as <args> rather than [with ...]. + (dump_expr): Don't print return type or template header. + [BASELINK]: Use BASELINK_FUNCTIONS rather than get_first_fn. + * pt.c (dependent_template_arg_p): Handle null arg. + + * error.c (type_to_string): Avoid redundant akas. + 2011-07-01 Jonathan Wakely <jwakely.gcc@gmail.com> PR c++/49605 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 94d686d3aef..e36739b38d6 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3518,8 +3518,6 @@ cxx_init_decl_processing (void) tree void_ftype; tree void_ftype_ptr; - build_common_tree_nodes (flag_signed_char); - /* Create all the identifiers we need. */ initialize_predefined_identifiers (); @@ -3536,8 +3534,6 @@ cxx_init_decl_processing (void) TREE_PUBLIC (global_namespace) = 1; begin_scope (sk_namespace, global_namespace); - current_lang_name = NULL_TREE; - if (flag_visibility_ms_compat) default_visibility = VISIBILITY_HIDDEN; diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 7c90ec45c17..b16fce68750 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -307,9 +307,12 @@ dump_template_bindings (tree parms, tree args, VEC(tree,gc)* typenames) parms = TREE_CHAIN (parms); } + /* Don't bother with typenames for a partial instantiation. */ + if (VEC_empty (tree, typenames) || uses_template_parms (args)) + return; + FOR_EACH_VEC_ELT (tree, typenames, i, t) { - bool dependent = uses_template_parms (args); if (need_comma) pp_separate_with_comma (cxx_pp); dump_type (t, TFF_PLAIN_IDENTIFIER); @@ -317,11 +320,7 @@ dump_template_bindings (tree parms, tree args, VEC(tree,gc)* typenames) pp_equal (cxx_pp); pp_cxx_whitespace (cxx_pp); push_deferring_access_checks (dk_no_check); - if (dependent) - ++processing_template_decl; t = tsubst (t, args, tf_none, NULL_TREE); - if (dependent) - --processing_template_decl; pop_deferring_access_checks (); /* Strip typedefs. We can't just use TFF_CHASE_TYPEDEF because pp_simple_type_specifier doesn't know about it. */ @@ -1379,17 +1378,37 @@ dump_function_decl (tree t, int flags) if (show_return) dump_type_suffix (TREE_TYPE (fntype), flags); - } - /* If T is a template instantiation, dump the parameter binding. */ - if (template_parms != NULL_TREE && template_args != NULL_TREE) + /* If T is a template instantiation, dump the parameter binding. */ + if (template_parms != NULL_TREE && template_args != NULL_TREE) + { + pp_cxx_whitespace (cxx_pp); + pp_cxx_left_bracket (cxx_pp); + pp_cxx_ws_string (cxx_pp, M_("with")); + pp_cxx_whitespace (cxx_pp); + dump_template_bindings (template_parms, template_args, typenames); + pp_cxx_right_bracket (cxx_pp); + } + } + else if (template_args) { - pp_cxx_whitespace (cxx_pp); - pp_cxx_left_bracket (cxx_pp); - pp_cxx_ws_string (cxx_pp, M_("with")); - pp_cxx_whitespace (cxx_pp); - dump_template_bindings (template_parms, template_args, typenames); - pp_cxx_right_bracket (cxx_pp); + bool need_comma = false; + int i; + pp_cxx_begin_template_argument_list (cxx_pp); + template_args = INNERMOST_TEMPLATE_ARGS (template_args); + for (i = 0; i < TREE_VEC_LENGTH (template_args); ++i) + { + tree arg = TREE_VEC_ELT (template_args, i); + if (need_comma) + pp_separate_with_comma (cxx_pp); + if (ARGUMENT_PACK_P (arg)) + pp_cxx_left_brace (cxx_pp); + dump_template_argument (arg, TFF_PLAIN_IDENTIFIER); + if (ARGUMENT_PACK_P (arg)) + pp_cxx_right_brace (cxx_pp); + need_comma = true; + } + pp_cxx_end_template_argument_list (cxx_pp); } } @@ -1724,7 +1743,9 @@ dump_expr (tree t, int flags) case OVERLOAD: case TYPE_DECL: case IDENTIFIER_NODE: - dump_decl (t, (flags & ~TFF_DECL_SPECIFIERS) | TFF_NO_FUNCTION_ARGUMENTS); + dump_decl (t, ((flags & ~(TFF_DECL_SPECIFIERS|TFF_RETURN_TYPE + |TFF_TEMPLATE_HEADER)) + | TFF_NO_FUNCTION_ARGUMENTS)); break; case INTEGER_CST: @@ -2289,7 +2310,7 @@ dump_expr (tree t, int flags) break; case BASELINK: - dump_expr (get_first_fn (t), flags & ~TFF_EXPR_IN_PARENS); + dump_expr (BASELINK_FUNCTIONS (t), flags & ~TFF_EXPR_IN_PARENS); break; case EMPTY_CLASS_EXPR: @@ -2634,14 +2655,28 @@ type_to_string (tree typ, int verbose) reinit_cxx_pp (); dump_type (typ, flags); + /* If we're printing a type that involves typedefs, also print the + stripped version. But sometimes the stripped version looks + exactly the same, so we don't want it after all. To avoid printing + it in that case, we play ugly obstack games. */ if (typ && TYPE_P (typ) && typ != TYPE_CANONICAL (typ) && !uses_template_parms (typ)) { + int aka_start; char *p; + struct obstack *ob = pp_base (cxx_pp)->buffer->obstack; + /* Remember the end of the initial dump. */ + int len = obstack_object_size (ob); tree aka = strip_typedefs (typ); pp_string (cxx_pp, " {aka"); pp_cxx_whitespace (cxx_pp); + /* And remember the start of the aka dump. */ + aka_start = obstack_object_size (ob); dump_type (aka, flags); pp_character (cxx_pp, '}'); + p = (char*)obstack_base (ob); + /* If they are identical, cut off the aka with a NUL. */ + if (memcmp (p, p+aka_start, len) == 0) + p[len] = '\0'; } return pp_formatted_text (cxx_pp); } diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 134c9ea7f19..81b772f6316 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -2495,6 +2495,11 @@ write_expression (tree expr) else if (TREE_CODE_CLASS (code) == tcc_constant || (abi_version_at_least (2) && code == CONST_DECL)) write_template_arg_literal (expr); + else if (code == PARM_DECL && DECL_ARTIFICIAL (expr)) + { + gcc_assert (!strcmp ("this", IDENTIFIER_POINTER (DECL_NAME (expr)))); + write_string ("fpT"); + } else if (code == PARM_DECL) { /* A function parameter used in a late-specified return type. */ diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 9b9eb9a9df9..d41a4dd4238 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -140,11 +140,12 @@ make_thunk (tree function, bool this_adjusting, THUNK_VIRTUAL_OFFSET (thunk) = virtual_offset; THUNK_ALIAS (thunk) = NULL_TREE; - /* The thunk itself is not a constructor or destructor, even if - the thing it is thunking to is. */ DECL_INTERFACE_KNOWN (thunk) = 1; DECL_NOT_REALLY_EXTERN (thunk) = 1; + DECL_COMDAT (thunk) = DECL_COMDAT (function); DECL_SAVED_FUNCTION_DATA (thunk) = NULL; + /* The thunk itself is not a constructor or destructor, even if + the thing it is thunking to is. */ DECL_DESTRUCTOR_P (thunk) = 0; DECL_CONSTRUCTOR_P (thunk) = 0; DECL_EXTERNAL (thunk) = 1; @@ -342,6 +343,7 @@ use_thunk (tree thunk_fndecl, bool emit_p) DECL_VISIBILITY (thunk_fndecl) = DECL_VISIBILITY (function); DECL_VISIBILITY_SPECIFIED (thunk_fndecl) = DECL_VISIBILITY_SPECIFIED (function); + DECL_COMDAT (thunk_fndecl) = DECL_COMDAT (function); if (DECL_ONE_ONLY (function) || DECL_WEAK (function)) make_decl_one_only (thunk_fndecl, cxx_comdat_group (thunk_fndecl)); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index d79326d2808..6bb15ed9508 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -5281,7 +5281,11 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser, postfix_expression); scope = NULL_TREE; } - else + /* Unlike the object expression in other contexts, *this is not + required to be of complete type for purposes of class member + access (5.2.5) outside the member function body. */ + else if (scope != current_class_ref + && !(processing_template_decl && scope == current_class_type)) scope = complete_type_or_else (scope, NULL_TREE); /* Let the name lookup machinery know that we are processing a class member access expression. */ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 7236e7e5168..17ca44cde0d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11287,8 +11287,12 @@ tsubst_qualified_id (tree qualified_id, tree args, expr = name; if (dependent_scope_p (scope)) - return build_qualified_name (NULL_TREE, scope, expr, - QUALIFIED_NAME_IS_TEMPLATE (qualified_id)); + { + if (is_template) + expr = build_min_nt (TEMPLATE_ID_EXPR, expr, template_args); + return build_qualified_name (NULL_TREE, scope, expr, + QUALIFIED_NAME_IS_TEMPLATE (qualified_id)); + } if (!BASELINK_P (name) && !DECL_P (expr)) { @@ -18848,7 +18852,7 @@ dependent_template_arg_p (tree arg) is dependent. This is consistent with what any_dependent_template_arguments_p [that calls this function] does. */ - if (arg == error_mark_node) + if (!arg || arg == error_mark_node) return true; if (TREE_CODE (arg) == ARGUMENT_PACK_SELECT) diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index e29705c5782..5c53a18511c 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2942,7 +2942,7 @@ finish_id_expression (tree id_expression, tree containing_function = current_function_decl; tree lambda_stack = NULL_TREE; tree lambda_expr = NULL_TREE; - tree initializer = decl; + tree initializer = convert_from_reference (decl); /* Core issue 696: "[At the July 2009 meeting] the CWG expressed support for an approach in which a reference to a local @@ -3633,7 +3633,10 @@ expand_or_defer_fn_1 (tree fn) && !DECL_REALLY_EXTERN (fn)) || (flag_keep_inline_dllexport && lookup_attribute ("dllexport", DECL_ATTRIBUTES (fn)))) - mark_needed (fn); + { + mark_needed (fn); + DECL_EXTERNAL (fn) = 0; + } } /* There's no reason to do any of the work here if we're only doing @@ -7791,7 +7794,8 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags) STRIP_NOPS (x); if (is_this_parameter (x)) { - if (DECL_CONSTRUCTOR_P (DECL_CONTEXT (x)) && want_rval) + if (want_rval && DECL_CONTEXT (x) + && DECL_CONSTRUCTOR_P (DECL_CONTEXT (x))) { if (flags & tf_error) sorry ("use of the value of the object being constructed " |