summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2018-07-13 16:46:08 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2018-07-13 16:46:08 +0000
commit950c7ddb563d0f91ef6db973f0393e7edba811f1 (patch)
tree1db811f5b5e5de41434893f82e01b42288f053df
parent2fb81a3d553e384cc647cf44c854d82147a3a0c9 (diff)
[PR c++/86374] Name lookup failure in enclosing template
https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00701.html PR c++/86374 * pt.c (lookup_template_class_1): Use tsubst_aggr_type for contexts that are classes. PR c++/86374 * g++.dg/pr86374.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-8-branch@262639 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c11
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/pr86374.C20
4 files changed, 40 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index fff998d29a42..cc79aabc5725 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2018-07-13 Nathan Sidwell <nathan@acm.org>
+
+ PR c++/86374
+ * pt.c (lookup_template_class_1): Use tsubst_aggr_type for
+ contexts that are classes.
+
2018-07-12 Jakub Jelinek <jakub@redhat.com>
* decl2.c (cplus_decl_attributes): Don't diagnose vars without mappable
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index a57e737d8806..66b0957cf652 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -9373,8 +9373,15 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context,
return found;
}
- context = tsubst (DECL_CONTEXT (gen_tmpl), arglist,
- complain, in_decl);
+ context = DECL_CONTEXT (gen_tmpl);
+ if (context && TYPE_P (context))
+ {
+ context = tsubst_aggr_type (context, arglist, complain, in_decl, true);
+ context = complete_type (context);
+ }
+ else
+ context = tsubst (context, arglist, complain, in_decl);
+
if (context == error_mark_node)
return error_mark_node;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8bc77b3acc29..687aaed9a90a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-07-13 Nathan Sidwell <nathan@acm.org>
+
+ PR c++/86374
+ * g++.dg/pr86374.C: New.
+
2018-07-12 Jakub Jelinek <jakub@redhat.com>
* c-c++-common/gomp/declare-target-3.c: New test.
diff --git a/gcc/testsuite/g++.dg/pr86374.C b/gcc/testsuite/g++.dg/pr86374.C
new file mode 100644
index 000000000000..fd7115626e10
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr86374.C
@@ -0,0 +1,20 @@
+// pr C++/86374
+// bogus lookup error
+template<typename LIST>
+struct list {
+ static const int index = 1;
+ template <typename> struct addWithChecking {};
+};
+
+template<typename container, int ix = container::index>
+struct find {
+ static const int result = 0;
+};
+
+template <class LIST>
+template<class O>
+struct list<LIST>::addWithChecking<O*>
+{
+ static const int xres =
+ find<list<LIST> >::result; // bogus error about index here.
+};