diff options
author | Jason Merrill <jason@redhat.com> | 2017-05-30 17:13:27 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2017-05-30 17:13:27 -0400 |
commit | 3c1f5a3a6d6425158ee35ef4ff67ac54010190f1 (patch) | |
tree | 232b2b27bf148eba86b45cb90e902fa16978fb7e /gcc | |
parent | f012c8ef4b35dcee9b5a3807868d050812d5b3b9 (diff) | |
download | gcc-3c1f5a3a6d6425158ee35ef4ff67ac54010190f1.zip gcc-3c1f5a3a6d6425158ee35ef4ff67ac54010190f1.tar.gz gcc-3c1f5a3a6d6425158ee35ef4ff67ac54010190f1.tar.bz2 |
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: r248699
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/local-fn2.C | 21 |
3 files changed, 38 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2dac610..8cc3ca3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-05-30 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. + 2017-05-30 David Malcolm <dmalcolm@redhat.com> * call.c (perform_implicit_conversion_flags): Convert diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 87b9534..99c61e5 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2316,13 +2316,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_min_nt_call_vec (fn, *args); + result = build_min_nt_call_vec (orig_fn, *args); SET_EXPR_LOCATION (result, EXPR_LOC_OR_LOC (fn, input_location)); KOENIG_LOOKUP_P (result) = koenig_p; if (is_overloaded_fn (fn)) diff --git a/gcc/testsuite/g++.dg/template/local-fn2.C b/gcc/testsuite/g++.dg/template/local-fn2.C new file mode 100644 index 0000000..98525fd --- /dev/null +++ b/gcc/testsuite/g++.dg/template/local-fn2.C @@ -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); +} |