diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-04-04 13:28:27 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-04-04 13:28:27 +0000 |
commit | faf8a5f7f39235b059c7fe7994dc909b1ad856bd (patch) | |
tree | 5cd1d9847625ae6fa60e392483a1ca0f224b8bd3 /gcc/cp | |
parent | c486bd8cad61831663994e24c0e8fe205369a810 (diff) | |
download | gcc-faf8a5f7f39235b059c7fe7994dc909b1ad856bd.tar.gz |
2012-04-04 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 186135 using svnmerge
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@186137 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 39 | ||||
-rw-r--r-- | gcc/cp/call.c | 2 | ||||
-rw-r--r-- | gcc/cp/class.c | 39 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 3 | ||||
-rw-r--r-- | gcc/cp/decl.c | 21 | ||||
-rw-r--r-- | gcc/cp/method.c | 2 | ||||
-rw-r--r-- | gcc/cp/pt.c | 48 | ||||
-rw-r--r-- | gcc/cp/tree.c | 5 |
8 files changed, 112 insertions, 47 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b8a6b5cb4c5..4b42e41de0e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,42 @@ +2012-04-03 Jason Merrill <jason@redhat.com> + + PR c++/52796 + * pt.c (tsubst_initializer_list): A pack expansion with no elements + means value-initialization. + +2012-04-01 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/50043 + * class.c (deduce_noexcept_on_destructor, + deduce_noexcept_on_destructors): New. + (check_bases_and_members): Call the latter. + * decl.c (grokfndecl): Call the former. + * method.c (implicitly_declare_fn): Not static. + * cp-tree.h (deduce_noexcept_on_destructor, implicitly_declare_fn): + Declare + +2012-03-29 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/52718 + * decl.c (check_default_argument): With -Wzero-as-null-pointer-constant + warn for a zero as null pointer constant default argument. + +2012-03-29 Jason Merrill <jason@redhat.com> + + PR c++/52685 + * tree.c (copy_binfo): Handle BINFO_DEPENDENT_BASE_P. + +2012-03-29 Jakub Jelinek <jakub@redhat.com> + + PR c++/52759 + * decl.c (start_decl): Don't call maybe_apply_pragma_weak + if processing_template_decl. + +2012-03-29 Jason Merrill <jason@redhat.com> + + PR c++/52743 + * call.c (compare_ics): Handle ck_aggr like ck_list. + 2012-03-28 Jason Merrill <jason@redhat.com> PR c++/52746 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 88733f50227..3c3dabb74a0 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -7620,7 +7620,7 @@ compare_ics (conversion *ics1, conversion *ics2) Specifically, we need to do the reference binding comparison at the end of this function. */ - if (ics1->user_conv_p || ics1->kind == ck_list) + if (ics1->user_conv_p || ics1->kind == ck_list || ics1->kind == ck_aggr) { conversion *t1; conversion *t2; diff --git a/gcc/cp/class.c b/gcc/cp/class.c index bc17c82c6a0..7b6559c4231 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4321,6 +4321,41 @@ clone_constructors_and_destructors (tree t) clone_function_decl (OVL_CURRENT (fns), /*update_method_vec_p=*/1); } +/* Deduce noexcept for a destructor DTOR. */ + +void +deduce_noexcept_on_destructor (tree dtor) +{ + if (!TYPE_RAISES_EXCEPTIONS (TREE_TYPE (dtor))) + { + tree ctx = DECL_CONTEXT (dtor); + tree implicit_fn = implicitly_declare_fn (sfk_destructor, ctx, + /*const_p=*/false); + tree eh_spec = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (implicit_fn)); + TREE_TYPE (dtor) = build_exception_variant (TREE_TYPE (dtor), eh_spec); + } +} + +/* For each destructor in T, deduce noexcept: + + 12.4/3: A declaration of a destructor that does not have an + exception-specification is implicitly considered to have the + same exception-specification as an implicit declaration (15.4). */ + +static void +deduce_noexcept_on_destructors (tree t) +{ + tree fns; + + /* If for some reason we don't have a CLASSTYPE_METHOD_VEC, we bail + out now. */ + if (!CLASSTYPE_METHOD_VEC (t)) + return; + + for (fns = CLASSTYPE_DESTRUCTORS (t); fns; fns = OVL_NEXT (fns)) + deduce_noexcept_on_destructor (OVL_CURRENT (fns)); +} + /* Subroutine of set_one_vmethod_tm_attributes. Search base classes of TYPE for virtual functions which FNDECL overrides. Return a mask of the tm attributes found therein. */ @@ -4994,6 +5029,10 @@ check_bases_and_members (tree t) cant_have_const_ctor = 0; no_const_asn_ref = 0; + /* Deduce noexcept on destructors. */ + if (cxx_dialect >= cxx0x) + deduce_noexcept_on_destructors (t); + /* Check all the base-classes. */ check_bases (t, &cant_have_const_ctor, &no_const_asn_ref); diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 7d986a8cf73..8bca1fa0b63 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4978,6 +4978,7 @@ extern void fixup_attribute_variants (tree); extern tree* decl_cloned_function_p (const_tree, bool); extern void clone_function_decl (tree, int); extern void adjust_clone_args (tree); +extern void deduce_noexcept_on_destructor (tree); /* in cvt.c */ extern tree convert_to_reference (tree, tree, int, int, tree); @@ -5264,6 +5265,8 @@ extern tree get_copy_assign (tree); extern tree get_default_ctor (tree); extern tree get_dtor (tree, tsubst_flags_t); extern tree locate_ctor (tree); +extern tree implicitly_declare_fn (special_function_kind, tree, + bool); /* In optimize.c */ extern bool maybe_clone_body (tree); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index f021edf36e5..d210f199a2d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4431,7 +4431,8 @@ start_decl (const cp_declarator *declarator, } /* If #pragma weak was used, mark the decl weak now. */ - maybe_apply_pragma_weak (decl); + if (!processing_template_decl) + maybe_apply_pragma_weak (decl); if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl) @@ -7447,6 +7448,13 @@ grokfndecl (tree ctype, if (ctype != NULL_TREE) grokclassfn (ctype, decl, flags); + /* 12.4/3 */ + if (cxx_dialect >= cxx0x + && DECL_DESTRUCTOR_P (decl) + && !TYPE_BEING_DEFINED (DECL_CONTEXT (decl)) + && !processing_template_decl) + deduce_noexcept_on_destructor (decl); + decl = check_explicit_specialization (orig_declarator, decl, template_count, 2 * funcdef_flag + @@ -10595,6 +10603,17 @@ check_default_argument (tree decl, tree arg) return error_mark_node; } + if (warn_zero_as_null_pointer_constant + && c_inhibit_evaluation_warnings == 0 + && (POINTER_TYPE_P (decl_type) || TYPE_PTR_TO_MEMBER_P (decl_type)) + && null_ptr_cst_p (arg) + && !NULLPTR_TYPE_P (TREE_TYPE (arg))) + { + warning (OPT_Wzero_as_null_pointer_constant, + "zero as null pointer constant"); + return nullptr_node; + } + /* [dcl.fct.default] Local variables shall not be used in default argument diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 0d4793eb23b..79bed4a053f 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -1444,7 +1444,7 @@ explain_implicit_non_constexpr (tree decl) reference argument or a non-const reference. Returns the FUNCTION_DECL for the implicitly declared function. */ -static tree +tree implicitly_declare_fn (special_function_kind kind, tree type, bool const_p) { tree fn; diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9b410a75fd4..ee38254bd8c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -17132,46 +17132,6 @@ more_specialized_fn (tree pat1, tree pat2, int len) quals2 = cp_type_quals (arg2); } - if ((quals1 < 0) != (quals2 < 0)) - { - /* Only of the args is a reference, see if we should apply - array/function pointer decay to it. This is not part of - DR214, but is, IMHO, consistent with the deduction rules - for the function call itself, and with our earlier - implementation of the underspecified partial ordering - rules. (nathan). */ - if (quals1 >= 0) - { - switch (TREE_CODE (arg1)) - { - case ARRAY_TYPE: - arg1 = TREE_TYPE (arg1); - /* FALLTHROUGH. */ - case FUNCTION_TYPE: - arg1 = build_pointer_type (arg1); - break; - - default: - break; - } - } - else - { - switch (TREE_CODE (arg2)) - { - case ARRAY_TYPE: - arg2 = TREE_TYPE (arg2); - /* FALLTHROUGH. */ - case FUNCTION_TYPE: - arg2 = build_pointer_type (arg2); - break; - - default: - break; - } - } - } - arg1 = TYPE_MAIN_VARIANT (arg1); arg2 = TYPE_MAIN_VARIANT (arg2); @@ -18965,6 +18925,7 @@ tsubst_initializer_list (tree t, tree argvec) } else { + tree tmp; decl = tsubst_copy (TREE_PURPOSE (t), argvec, tf_warning_or_error, NULL_TREE); @@ -18973,10 +18934,17 @@ tsubst_initializer_list (tree t, tree argvec) in_base_initializer = 1; init = TREE_VALUE (t); + tmp = init; if (init != void_type_node) init = tsubst_expr (init, argvec, tf_warning_or_error, NULL_TREE, /*integral_constant_expression_p=*/false); + if (init == NULL_TREE && tmp != NULL_TREE) + /* If we had an initializer but it instantiated to nothing, + value-initialize the object. This will only occur when + the initializer was a pack expansion where the parameter + packs used in that expansion were of length zero. */ + init = void_type_node; in_base_initializer = 0; } diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 87e9be84ecc..30ad5e1b7be 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1237,12 +1237,11 @@ copy_binfo (tree binfo, tree type, tree t, tree *igo_prev, int virt) TREE_CHAIN (*igo_prev) = new_binfo; *igo_prev = new_binfo; - if (binfo) + if (binfo && !BINFO_DEPENDENT_BASE_P (binfo)) { int ix; tree base_binfo; - gcc_assert (!BINFO_DEPENDENT_BASE_P (binfo)); gcc_assert (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), type)); BINFO_OFFSET (new_binfo) = BINFO_OFFSET (binfo); @@ -1255,8 +1254,6 @@ copy_binfo (tree binfo, tree type, tree t, tree *igo_prev, int virt) for (ix = 0; BINFO_BASE_ITERATE (binfo, ix, base_binfo); ix++) { tree new_base_binfo; - - gcc_assert (!BINFO_DEPENDENT_BASE_P (base_binfo)); new_base_binfo = copy_binfo (base_binfo, BINFO_TYPE (base_binfo), t, igo_prev, BINFO_VIRTUAL_P (base_binfo)); |