public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98231] New: [11 Regression] bogus error: no match for ‘operator<<’
@ 2020-12-11 2:30 mpolacek at gcc dot gnu.org
2020-12-11 2:31 ` [Bug c++/98231] " mpolacek at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-12-11 2:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98231
Bug ID: 98231
Summary: [11 Regression] bogus error: no match for ‘operator<<’
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mpolacek at gcc dot gnu.org
Target Milestone: ---
template <typename, typename = int> struct basic_ostream {};
namespace N {
template <typename Char, typename CharTraits, typename T>
void operator<<(basic_ostream<Char, CharTraits>, T);
}
basic_ostream<char> os;
template<typename T> void
foo (T value)
{
using N::operator<<;
os << value;
}
void bar() { foo (1); }
gives
$ ./cc1plus -quiet ceph.C
ceph.C: In instantiation of ‘void foo(T) [with T = int]’:
ceph.C:14:20: required from here
ceph.C:12:6: error: no match for ‘operator<<’ (operand types are
‘basic_ostream<char>’ and ‘int’)
12 | os << value;
| ~~~^~~~~~~~
Started with r11-4690.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/98231] [11 Regression] bogus error: no match for ‘operator<<’
2020-12-11 2:30 [Bug c++/98231] New: [11 Regression] bogus error: no match for ‘operator<<’ mpolacek at gcc dot gnu.org
@ 2020-12-11 2:31 ` mpolacek at gcc dot gnu.org
2021-01-13 16:08 ` mpolacek at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-12-11 2:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98231
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Target Milestone|--- |11.0
Priority|P3 |P1
Last reconfirmed| |2020-12-11
Ever confirmed|0 |1
Keywords| |rejects-valid
CC| |nathan at gcc dot gnu.org
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/98231] [11 Regression] bogus error: no match for ‘operator<<’
2020-12-11 2:30 [Bug c++/98231] New: [11 Regression] bogus error: no match for ‘operator<<’ mpolacek at gcc dot gnu.org
2020-12-11 2:31 ` [Bug c++/98231] " mpolacek at gcc dot gnu.org
@ 2021-01-13 16:08 ` mpolacek at gcc dot gnu.org
2021-01-13 17:00 ` mpolacek at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-01-13 16:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98231
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This seems to work...
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -9279,4 +9279,14 @@ push_operator_bindings ()
}
}
+/* Wrapper around push_local_binding to push the bindings for
+ a non-member USING_DECL that were found during template parsing. */
+
+void
+push_using_decl_bindings (tree decl)
+{
+ push_local_binding (DECL_NAME (decl), USING_DECL_DECLS (decl),
+ /*using*/true);
+}
+
#include "gt-cp-name-lookup.h"
diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h
index 7172079b274..bac3fa71fc9 100644
--- a/gcc/cp/name-lookup.h
+++ b/gcc/cp/name-lookup.h
@@ -478,6 +478,7 @@ extern void push_to_top_level (void);
extern void pop_from_top_level (void);
extern void maybe_save_operator_binding (tree);
extern void push_operator_bindings (void);
+extern void push_using_decl_bindings (tree);
extern void discard_operator_bindings (tree);
/* Lower level interface for modules. */
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 100c35f053c..c27ef6d9fe0 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -18133,6 +18133,9 @@ tsubst_expr (tree t, tree args, tsubst_flags_t
complain, tree in_decl,
tree scope = USING_DECL_SCOPE (decl);
gcc_checking_assert (scope
== tsubst (scope, args, complain, in_decl));
+ /* We still need to push the bindings so that we can look up
+ this name later. */
+ push_using_decl_bindings (decl);
}
else if (is_capture_proxy (decl)
&& !DECL_TEMPLATE_INSTANTIATION (current_function_decl))
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/98231] [11 Regression] bogus error: no match for ‘operator<<’
2020-12-11 2:30 [Bug c++/98231] New: [11 Regression] bogus error: no match for ‘operator<<’ mpolacek at gcc dot gnu.org
2020-12-11 2:31 ` [Bug c++/98231] " mpolacek at gcc dot gnu.org
2021-01-13 16:08 ` mpolacek at gcc dot gnu.org
@ 2021-01-13 17:00 ` mpolacek at gcc dot gnu.org
2021-01-13 22:16 ` cvs-commit at gcc dot gnu.org
2021-01-13 22:17 ` mpolacek at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-01-13 17:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98231
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/98231] [11 Regression] bogus error: no match for ‘operator<<’
2020-12-11 2:30 [Bug c++/98231] New: [11 Regression] bogus error: no match for ‘operator<<’ mpolacek at gcc dot gnu.org
` (2 preceding siblings ...)
2021-01-13 17:00 ` mpolacek at gcc dot gnu.org
@ 2021-01-13 22:16 ` cvs-commit at gcc dot gnu.org
2021-01-13 22:17 ` mpolacek at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-13 22:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98231
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:796ead19f85372e59217c9888db688a2fe11b54f
commit r11-6652-g796ead19f85372e59217c9888db688a2fe11b54f
Author: Marek Polacek <polacek@redhat.com>
Date: Wed Jan 13 11:09:14 2021 -0500
c++: Failure to lookup using-decl name [PR98231]
In r11-4690 we removed the call to finish_nonmember_using_decl in
tsubst_expr/DECL_EXPR in the USING_DECL block. This was done not
to perform name lookup twice for a non-dependent using-decl, which
sounds sensible.
However, finish_nonmember_using_decl also pushes the decl's bindings
which we still have to do so that we can find the USING_DECL's name
later. In this case, we've got a USING_DECL N::operator<< that we are
tsubstituting. We already looked it up while parsing the template
"foo", and lookup_using_decl stashed the OVERLOAD it found into
USING_DECL_DECLS. Now we just have to update the IDENTIFIER_BINDING of
the identifier for operator<< with the overload the name is bound to.
I didn't want to export push_local_binding so I've introduced a new
wrapper.
gcc/cp/ChangeLog:
PR c++/98231
* name-lookup.c (push_using_decl_bindings): New.
* name-lookup.h (push_using_decl_bindings): Declare.
* pt.c (tsubst_expr): Call push_using_decl_bindings.
gcc/testsuite/ChangeLog:
PR c++/98231
* g++.dg/lookup/using63.C: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/98231] [11 Regression] bogus error: no match for ‘operator<<’
2020-12-11 2:30 [Bug c++/98231] New: [11 Regression] bogus error: no match for ‘operator<<’ mpolacek at gcc dot gnu.org
` (3 preceding siblings ...)
2021-01-13 22:16 ` cvs-commit at gcc dot gnu.org
@ 2021-01-13 22:17 ` mpolacek at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-01-13 22:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98231
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-01-13 22:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-11 2:30 [Bug c++/98231] New: [11 Regression] bogus error: no match for ‘operator<<’ mpolacek at gcc dot gnu.org
2020-12-11 2:31 ` [Bug c++/98231] " mpolacek at gcc dot gnu.org
2021-01-13 16:08 ` mpolacek at gcc dot gnu.org
2021-01-13 17:00 ` mpolacek at gcc dot gnu.org
2021-01-13 22:16 ` cvs-commit at gcc dot gnu.org
2021-01-13 22:17 ` mpolacek at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).