Commit b1fe8605 by Nathan Sidwell Committed by Nathan Sidwell

[PR c++/87269] Mark string operator overload in template defn.

https://gcc.gnu.org/ml/gcc-patches/2018-11/msg01458.html
	PR c++/87269
	* parser.c (lookup_literal_operator): Mark overload for keeping
	when inside template.  Refactor.

	* g++.dg/lookup/pr87269.C: New.

From-SVN: r266210
parent ac28df7e
2018-11-16 Nathan Sidwell <nathan@acm.org>
PR c++/87269
* parser.c (lookup_literal_operator): Mark overload for keeping
when inside template. Refactor.
2018-11-15 Nathan Sidwell <nathan@acm.org> 2018-11-15 Nathan Sidwell <nathan@acm.org>
PR c++/86246 PR c++/86246
......
...@@ -4259,20 +4259,21 @@ cp_parser_string_literal (cp_parser *parser, bool translate, bool wide_ok, ...@@ -4259,20 +4259,21 @@ cp_parser_string_literal (cp_parser *parser, bool translate, bool wide_ok,
static tree static tree
lookup_literal_operator (tree name, vec<tree, va_gc> *args) lookup_literal_operator (tree name, vec<tree, va_gc> *args)
{ {
tree decl; tree decl = lookup_name (name);
decl = lookup_name (name);
if (!decl || !is_overloaded_fn (decl)) if (!decl || !is_overloaded_fn (decl))
return error_mark_node; return error_mark_node;
for (lkp_iterator iter (decl); iter; ++iter) for (lkp_iterator iter (decl); iter; ++iter)
{ {
unsigned int ix;
bool found = true;
tree fn = *iter; 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)) ++ix, parmtypes = TREE_CHAIN (parmtypes))
{ {
tree tparm = TREE_VALUE (parmtypes); tree tparm = TREE_VALUE (parmtypes);
...@@ -4285,6 +4286,7 @@ lookup_literal_operator (tree name, vec<tree, va_gc> *args) ...@@ -4285,6 +4286,7 @@ lookup_literal_operator (tree name, vec<tree, va_gc> *args)
TREE_TYPE (targ)))) TREE_TYPE (targ))))
found = false; found = false;
} }
if (found if (found
&& ix == vec_safe_length (args) && ix == vec_safe_length (args)
/* May be this should be sufficient_parms_p instead, /* May be this should be sufficient_parms_p instead,
...@@ -4292,9 +4294,13 @@ lookup_literal_operator (tree name, vec<tree, va_gc> *args) ...@@ -4292,9 +4294,13 @@ lookup_literal_operator (tree name, vec<tree, va_gc> *args)
work in presence of default arguments on the literal work in presence of default arguments on the literal
operator parameters. */ operator parameters. */
&& parmtypes == void_list_node) && parmtypes == void_list_node)
{
if (processing_template_decl)
lookup_keep (decl);
return decl; return decl;
} }
} }
}
return error_mark_node; return error_mark_node;
} }
2018-11-16 Nathan Sidwell <nathan@acm.org>
PR c++/87269
* g++.dg/lookup/pr87269.C: New.
2018-11-16 Richard Biener <rguenther@suse.de> 2018-11-16 Richard Biener <rguenther@suse.de>
PR testsuite/88053 PR testsuite/88053
......
// { 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> ();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment