* [PR c++/87269] Mark string operator overload in template defn.
@ 2018-11-16 15:01 Nathan Sidwell
2018-11-16 20:50 ` [PATCH[ Fix pr87269.C testcase Jakub Jelinek
0 siblings, 1 reply; 4+ messages in thread
From: Nathan Sidwell @ 2018-11-16 15:01 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 149 bytes --]
This was a case of not marking the overloads of a lookup as immutable,
leading to an assert failure.
Applying to trunk.
nathan
--
Nathan Sidwell
[-- Attachment #2: pr87269.diff --]
[-- Type: text/x-patch, Size: 2310 bytes --]
2018-11-16 Nathan Sidwell <nathan@acm.org>
PR c++/87269
* parser.c (lookup_literal_operator): Mark overload for keeping
when inside template. Refactor.
* g++.dg/lookup/pr87269.C: New.
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 266204)
+++ cp/parser.c (working copy)
@@ -4259,20 +4259,21 @@ cp_parser_string_literal (cp_parser *par
static tree
lookup_literal_operator (tree name, vec<tree, va_gc> *args)
{
- tree decl;
- decl = lookup_name (name);
+ tree decl = lookup_name (name);
if (!decl || !is_overloaded_fn (decl))
return error_mark_node;
for (lkp_iterator iter (decl); iter; ++iter)
{
- unsigned int ix;
- bool found = true;
tree fn = *iter;
- tree parmtypes = TYPE_ARG_TYPES (TREE_TYPE (fn));
- if (parmtypes != NULL_TREE)
+
+ if (tree parmtypes = TYPE_ARG_TYPES (TREE_TYPE (fn)))
{
- for (ix = 0; ix < vec_safe_length (args) && parmtypes != NULL_TREE;
+ unsigned int ix;
+ bool found = true;
+
+ for (ix = 0;
+ found && ix < vec_safe_length (args) && parmtypes != NULL_TREE;
++ix, parmtypes = TREE_CHAIN (parmtypes))
{
tree tparm = TREE_VALUE (parmtypes);
@@ -4285,6 +4286,7 @@ lookup_literal_operator (tree name, vec<
TREE_TYPE (targ))))
found = false;
}
+
if (found
&& ix == vec_safe_length (args)
/* May be this should be sufficient_parms_p instead,
@@ -4292,7 +4294,11 @@ lookup_literal_operator (tree name, vec<
work in presence of default arguments on the literal
operator parameters. */
&& parmtypes == void_list_node)
- return decl;
+ {
+ if (processing_template_decl)
+ lookup_keep (decl);
+ return decl;
+ }
}
}
Index: testsuite/g++.dg/lookup/pr87269.C
===================================================================
--- testsuite/g++.dg/lookup/pr87269.C (revision 0)
+++ testsuite/g++.dg/lookup/pr87269.C (working copy)
@@ -0,0 +1,15 @@
+// { dg-do compile { target c++11 } }
+// PR c++/87269 ICE failing to keep a lookup
+
+namespace {
+ void operator"" _a (const char *, unsigned long) {}
+}
+
+void operator"" _a (unsigned long long);
+
+template <typename> void f () { ""_a; }
+
+void frob ()
+{
+ f<int> ();
+}
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH[ Fix pr87269.C testcase
2018-11-16 15:01 [PR c++/87269] Mark string operator overload in template defn Nathan Sidwell
@ 2018-11-16 20:50 ` Jakub Jelinek
2018-11-16 22:59 ` Nathan Sidwell
2018-12-06 1:12 ` Jason Merrill
0 siblings, 2 replies; 4+ messages in thread
From: Jakub Jelinek @ 2018-11-16 20:50 UTC (permalink / raw)
To: Nathan Sidwell, Jason Merrill; +Cc: GCC Patches
On Fri, Nov 16, 2018 at 10:01:05AM -0500, Nathan Sidwell wrote:
> 2018-11-16 Nathan Sidwell <nathan@acm.org>
>
> PR c++/87269
> * parser.c (lookup_literal_operator): Mark overload for keeping
> when inside template. Refactor.
>
> * g++.dg/lookup/pr87269.C: New.
This test fails on i686-linux (and on any other where std::size_t is
not unsigned long.
Fixed thusly, tested on x86_64-linux and i686-linux, ok for trunk?
2018-11-16 Jakub Jelinek <jakub@redhat.com>
PR c++/87269
* g++.dg/lookup/pr87269.C (std::size_t): New typedef.
(operator"" _a) Change unsigned long type to std::size_t.
--- gcc/testsuite/g++.dg/lookup/pr87269.C.jj 2018-11-16 17:33:44.534188632 +0100
+++ gcc/testsuite/g++.dg/lookup/pr87269.C 2018-11-16 21:48:00.243033194 +0100
@@ -1,8 +1,12 @@
// { dg-do compile { target c++11 } }
// PR c++/87269 ICE failing to keep a lookup
+namespace std {
+ typedef decltype (sizeof (0)) size_t;
+}
+
namespace {
- void operator"" _a (const char *, unsigned long) {}
+ void operator"" _a (const char *, std::size_t) {}
}
void operator"" _a (unsigned long long);
Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH[ Fix pr87269.C testcase
2018-11-16 20:50 ` [PATCH[ Fix pr87269.C testcase Jakub Jelinek
@ 2018-11-16 22:59 ` Nathan Sidwell
2018-12-06 1:12 ` Jason Merrill
1 sibling, 0 replies; 4+ messages in thread
From: Nathan Sidwell @ 2018-11-16 22:59 UTC (permalink / raw)
To: Jakub Jelinek, Jason Merrill; +Cc: GCC Patches
Yeah, thanks Jakubnathan-- Nathan Sidwell
-------- Original message --------From: Jakub Jelinek <jakub@redhat.com> Date: 11/16/18 15:50 (GMT-05:00) To: Nathan Sidwell <nathan@acm.org>, Jason Merrill <jason@redhat.com> Cc: GCC Patches <gcc-patches@gcc.gnu.org> Subject: [PATCH[ Fix pr87269.C testcase On Fri, Nov 16, 2018 at 10:01:05AM -0500, Nathan Sidwell wrote:> 2018-11-16 Nathan Sidwell <nathan@acm.org>> > PR c++/87269> * parser.c (lookup_literal_operator): Mark overload for keeping> when inside template. Refactor.> > * g++.dg/lookup/pr87269.C: New.This test fails on i686-linux (and on any other where std::size_t isnot unsigned long.Fixed thusly, tested on x86_64-linux and i686-linux, ok for trunk?2018-11-16 Jakub Jelinek <jakub@redhat.com> PR c++/87269 * g++.dg/lookup/pr87269.C (std::size_t): New typedef. (operator"" _a) Change unsigned long type to std::size_t.--- gcc/testsuite/g++.dg/lookup/pr87269.C.jj 2018-11-16 17:33:44.534188632 +0100+++ gcc/testsuite/g++.dg/lookup/pr87269.C 2018-11-16 21:48:00.243033194 +0100@@ -1,8 +1,12 @@ // { dg-do compile { target c++11 } } // PR c++/87269 ICE failing to keep a lookup +namespace std {+ typedef decltype (sizeof (0)) size_t;+}+ namespace {- void operator"" _a (const char *, unsigned long) {}+ void operator"" _a (const char *, std::size_t) {} } void operator"" _a (unsigned long long); Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH[ Fix pr87269.C testcase
2018-11-16 20:50 ` [PATCH[ Fix pr87269.C testcase Jakub Jelinek
2018-11-16 22:59 ` Nathan Sidwell
@ 2018-12-06 1:12 ` Jason Merrill
1 sibling, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2018-12-06 1:12 UTC (permalink / raw)
To: Jakub Jelinek, Nathan Sidwell; +Cc: GCC Patches
On 11/16/18 3:50 PM, Jakub Jelinek wrote:
> On Fri, Nov 16, 2018 at 10:01:05AM -0500, Nathan Sidwell wrote:
>> 2018-11-16 Nathan Sidwell <nathan@acm.org>
>>
>> PR c++/87269
>> * parser.c (lookup_literal_operator): Mark overload for keeping
>> when inside template. Refactor.
>>
>> * g++.dg/lookup/pr87269.C: New.
>
> This test fails on i686-linux (and on any other where std::size_t is
> not unsigned long.
>
> Fixed thusly, tested on x86_64-linux and i686-linux, ok for trunk?
OK. This sort of fix qualifies as obvious IMO.
> 2018-11-16 Jakub Jelinek <jakub@redhat.com>
>
> PR c++/87269
> * g++.dg/lookup/pr87269.C (std::size_t): New typedef.
> (operator"" _a) Change unsigned long type to std::size_t.
>
> --- gcc/testsuite/g++.dg/lookup/pr87269.C.jj 2018-11-16 17:33:44.534188632 +0100
> +++ gcc/testsuite/g++.dg/lookup/pr87269.C 2018-11-16 21:48:00.243033194 +0100
> @@ -1,8 +1,12 @@
> // { dg-do compile { target c++11 } }
> // PR c++/87269 ICE failing to keep a lookup
>
> +namespace std {
> + typedef decltype (sizeof (0)) size_t;
> +}
> +
> namespace {
> - void operator"" _a (const char *, unsigned long) {}
> + void operator"" _a (const char *, std::size_t) {}
> }
>
> void operator"" _a (unsigned long long);
>
>
> Jakub
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-12-06 1:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-16 15:01 [PR c++/87269] Mark string operator overload in template defn Nathan Sidwell
2018-11-16 20:50 ` [PATCH[ Fix pr87269.C testcase Jakub Jelinek
2018-11-16 22:59 ` Nathan Sidwell
2018-12-06 1:12 ` Jason Merrill
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).