diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2019-04-01 17:09:47 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2019-04-01 17:09:47 +0000 |
commit | 5ed22cbbfce94c6fca8e4247a74315aacb759918 (patch) | |
tree | 91764802e7bfe18eb7c2076b882c9d762085d8d6 | |
parent | ddeae8c8ac2681f5fb738f78df747782afa6ac15 (diff) | |
download | gcc-5ed22cbbfce94c6fca8e4247a74315aacb759918.zip gcc-5ed22cbbfce94c6fca8e4247a74315aacb759918.tar.gz gcc-5ed22cbbfce94c6fca8e4247a74315aacb759918.tar.bz2 |
re PR c++/62207 (ICE: tree check: expected tree that contains 'decl minimal' structure, have 'overload' in tsubst_copy, at cp/pt.c)
/cp
2019-04-01 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/62207
* pt.c (tsubst_copy): Deal with lookup_name not returing a variable.
/testsuite
2019-04-01 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/62207
* g++.dg/template/crash130.C: New.
* g++.dg/template/crash131.C: Likewise.
From-SVN: r270064
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/pt.c | 23 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/crash130.C | 15 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/crash131.C | 16 |
5 files changed, 59 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8c6e993..3501f6b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-04-01 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/62207 + * pt.c (tsubst_copy): Deal with lookup_name not returing a variable. + 2019-03-31 Marek Polacek <polacek@redhat.com> PR c++/89852 - ICE with C++11 functional cast with { }. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index f3faa89..d5249a0 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -15591,12 +15591,23 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) { /* First try name lookup to find the instantiation. */ r = lookup_name (DECL_NAME (t)); - if (r && !is_capture_proxy (r)) + if (r) { - /* Make sure that the one we found is the one we want. */ - tree ctx = enclosing_instantiation_of (DECL_CONTEXT (t)); - if (ctx != DECL_CONTEXT (r)) - r = NULL_TREE; + if (!VAR_P (r)) + { + /* During error-recovery we may find a non-variable, + even an OVERLOAD: just bail out and avoid ICEs and + duplicate diagnostics (c++/62207). */ + gcc_assert (seen_error ()); + return error_mark_node; + } + if (!is_capture_proxy (r)) + { + /* Make sure the one we found is the one we want. */ + tree ctx = enclosing_instantiation_of (DECL_CONTEXT (t)); + if (ctx != DECL_CONTEXT (r)) + r = NULL_TREE; + } } if (r) @@ -15632,7 +15643,7 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) } gcc_assert (cp_unevaluated_operand || TREE_STATIC (r) || decl_constant_var_p (r) - || errorcount || sorrycount); + || seen_error ()); if (!processing_template_decl && !TREE_STATIC (r)) r = process_outer_var_ref (r, complain); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1c516a9..244ae87 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-04-01 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/62207 + * g++.dg/template/crash130.C: New. + * g++.dg/template/crash131.C: Likewise. + 2019-04-01 Martin Sebor <msebor@redhat.com> PR c/89685 diff --git a/gcc/testsuite/g++.dg/template/crash130.C b/gcc/testsuite/g++.dg/template/crash130.C new file mode 100644 index 0000000..c3e154f --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash130.C @@ -0,0 +1,15 @@ +// PR c++/62207 + +template<typename T> void foo(T) +{ + X; // { dg-error "not declared" } + X; +} + +void X(); +void X(int); + +void bar() +{ + foo(0); +} diff --git a/gcc/testsuite/g++.dg/template/crash131.C b/gcc/testsuite/g++.dg/template/crash131.C new file mode 100644 index 0000000..7b3a47d --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash131.C @@ -0,0 +1,16 @@ +// PR c++/62207 + +template<class F> +class X { +public: + template<F f> class Y {}; + template<F f> void y() {} + X(F f) + { + Y<f> y; // { dg-error "not a constant" } + + y.value(); + } +}; + +int main() { X<int> x(1); } |