PR c++/80856 - ICE with local extern in template

* semantics.c (finish_call_expr): Replace a local extern overload
	set in a template with the IDENTIFIER_NODE.

From-SVN: r248754
This commit is contained in:
Jason Merrill 2017-05-31 13:53:12 -04:00 committed by Jason Merrill
parent bb399e300f
commit 78578b7e04
3 changed files with 36 additions and 1 deletions

View File

@ -1,5 +1,9 @@
2017-05-31 Jason Merrill <jason@redhat.com>
PR c++/80856 - ICE with local extern in template
* semantics.c (finish_call_expr): Replace a local extern overload
set in a template with the IDENTIFIER_NODE.
PR c++/80605 - __is_standard_layout and zero-length array
* class.c (check_bases): Use DECL_FIELD_IS_BASE.

View File

@ -2298,13 +2298,23 @@ finish_call_expr (tree fn, vec<tree, va_gc> **args, bool disallow_virtual,
if (processing_template_decl)
{
/* If FN is a local extern declaration or set thereof, look them up
again at instantiation time. */
if (is_overloaded_fn (fn))
{
tree ifn = get_first_fn (fn);
if (TREE_CODE (ifn) == FUNCTION_DECL
&& DECL_LOCAL_FUNCTION_P (ifn))
orig_fn = DECL_NAME (ifn);
}
/* If the call expression is dependent, build a CALL_EXPR node
with no type; type_dependent_expression_p recognizes
expressions with no type as being dependent. */
if (type_dependent_expression_p (fn)
|| any_type_dependent_arguments_p (*args))
{
result = build_nt_call_vec (fn, *args);
result = build_nt_call_vec (orig_fn, *args);
SET_EXPR_LOCATION (result, EXPR_LOC_OR_LOC (fn, input_location));
KOENIG_LOOKUP_P (result) = koenig_p;
if (cfun)

View File

@ -0,0 +1,21 @@
// PR c++/80856
// { dg-do compile { target c++11 } }
template<typename T>
inline T WrapToCycle(T degrees)
{
int Wrap(int x, int lower_bound, int upper_bound);
auto p = Wrap;
p (1, 0, 360);
double Wrap(double x, int lower_bound, int upper_bound);
Wrap(1, 0, 360);
return Wrap(degrees, 0, 360);
}
void GenerateOldReportPage()
{
WrapToCycle(0);
}