diff options
author | Nathan Sidwell <nathan@acm.org> | 2018-12-13 15:57:24 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2018-12-13 15:57:24 +0000 |
commit | 2139fd74f31449c01f347bd1005cfab52cde7969 (patch) | |
tree | d074b17ab6572bf9768b2c594b39ccb3092705fb /gcc/cp | |
parent | f1d42e85ad96f0c2977118c019a8a31e895ea1da (diff) | |
download | gcc-2139fd74f31449c01f347bd1005cfab52cde7969.zip gcc-2139fd74f31449c01f347bd1005cfab52cde7969.tar.gz gcc-2139fd74f31449c01f347bd1005cfab52cde7969.tar.bz2 |
[PR c++/87531] Fix second bug
https://gcc.gnu.org/ml/gcc-patches/2018-12/msg00929.html
PR c++/87531
* class.c (finish_struct): Set DECL_CONTEXT of template assign op.
* name-lookup.c (get_class_binding_direct): Don't strip using-decl
of overload here.
* parser.c (cp_parser_postfix_expression): Cope with using decl in
overload set.
* semantics.c (finish_id_expr): Likewise.
* g++.dg/lookup/pr87531-2.C: New.
From-SVN: r267096
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cp/class.c | 1 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 11 | ||||
-rw-r--r-- | gcc/cp/parser.c | 9 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 7 |
5 files changed, 22 insertions, 16 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a32e1d0..503bbbb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2018-12-13 Nathan Sidwell <nathan@acm.org> + + PR c++/87531 + * class.c (finish_struct): Set DECL_CONTEXT of template assign op. + * name-lookup.c (get_class_binding_direct): Don't strip using-decl + of overload here. + * parser.c (cp_parser_postfix_expression): Cope with using decl in + overload set. + * semantics.c (finish_id_expr): Likewise. + 2018-12-12 Paolo Carlini <paolo.carlini@oracle.com> * decl.c (grokdeclarator): Fix location of error message about diff --git a/gcc/cp/class.c b/gcc/cp/class.c index fec1c5d..36e1757 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -7158,6 +7158,7 @@ finish_struct (tree t, tree attributes) time. */ tree ass_op = build_lang_decl (USING_DECL, assign_op_identifier, NULL_TREE); + DECL_CONTEXT (ass_op) = t; USING_DECL_SCOPE (ass_op) = t; DECL_DEPENDENT_P (ass_op) = true; DECL_ARTIFICIAL (ass_op) = true; diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index cadf380..39710fc 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -1242,17 +1242,6 @@ get_class_binding_direct (tree klass, tree name, int type_or_fns) } else if (STAT_HACK_P (val)) val = STAT_DECL (val); - - if (val && TREE_CODE (val) == OVERLOAD - && TREE_CODE (OVL_FUNCTION (val)) == USING_DECL) - { - /* An overload with a dependent USING_DECL. Does the caller - want the USING_DECL or the functions? */ - if (type_or_fns < 0) - val = OVL_CHAIN (val); - else - val = OVL_FUNCTION (val); - } } else { diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 8b669a8..7ff113f 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -7240,14 +7240,19 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, else if (!args->is_empty () && is_overloaded_fn (postfix_expression)) { + /* We only need to look at the first function, + because all the fns share the attribute we're + concerned with (all member fns or all local + fns). */ tree fn = get_first_fn (postfix_expression); fn = STRIP_TEMPLATE (fn); /* Do not do argument dependent lookup if regular lookup finds a member function or a block-scope function declaration. [basic.lookup.argdep]/3 */ - if (!DECL_FUNCTION_MEMBER_P (fn) - && !DECL_LOCAL_FUNCTION_P (fn)) + if (!((TREE_CODE (fn) == USING_DECL && DECL_DEPENDENT_P (fn)) + || DECL_FUNCTION_MEMBER_P (fn) + || DECL_LOCAL_FUNCTION_P (fn))) { koenig_p = true; if (!any_type_dependent_arguments_p (args)) diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index c1240cc..09ed97d 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3805,9 +3805,10 @@ finish_id_expression (tree id_expression, return error_mark_node; if (!template_arg_p - && TREE_CODE (first_fn) == FUNCTION_DECL - && DECL_FUNCTION_MEMBER_P (first_fn) - && !shared_member_p (decl)) + && (TREE_CODE (first_fn) == USING_DECL + || (TREE_CODE (first_fn) == FUNCTION_DECL + && DECL_FUNCTION_MEMBER_P (first_fn) + && !shared_member_p (decl)))) { /* A set of member functions. */ decl = maybe_dummy_object (DECL_CONTEXT (first_fn), 0); |