aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@gcc.gnu.org>2016-03-05 01:59:04 +0000
committerPatrick Palka <ppalka@gcc.gnu.org>2016-03-05 01:59:04 +0000
commit7a3a3fadb050d9e49b18d052cfc20191acdf4126 (patch)
tree254c9fbf70248291f4be405898f6b1b4c374240f /gcc/cp
parentb554db5b0390f394bf9b8269c0398da9c8a3cbdb (diff)
downloadgcc-7a3a3fadb050d9e49b18d052cfc20191acdf4126.zip
gcc-7a3a3fadb050d9e49b18d052cfc20191acdf4126.tar.gz
gcc-7a3a3fadb050d9e49b18d052cfc20191acdf4126.tar.bz2
Fix PR c++/66786 (ICE with nested lambdas in variable template)
gcc/cp/ChangeLog: PR c++/66786 * pt.c (template_class_depth): Given a lambda type, iterate into its LAMBDA_TYPE_EXTRA_SCOPE field instead of its TYPE_CONTEXT. Given a VAR_DECL, iterate into its CP_DECL_CONTEXT. gcc/testsuite/ChangeLog: PR c++/66786 * g++.dg/cpp1y/var-templ48.C: New test. * g++.dg/cpp1y/var-templ49.C: New test. From-SVN: r233997
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/pt.c12
2 files changed, 16 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f4c8744..0ef1ac7 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2016-03-05 Patrick Palka <ppalka@gcc.gnu.org>
+
+ PR c++/66786
+ * pt.c (template_class_depth): Given a lambda type, iterate
+ into its LAMBDA_TYPE_EXTRA_SCOPE field instead of its
+ TYPE_CONTEXT. Given a VAR_DECL, iterate into its
+ CP_DECL_CONTEXT.
+
2016-03-04 Jason Merrill <jason@redhat.com>
PR c++/69203
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index e8cd736..f6dd75a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -370,16 +370,20 @@ template_class_depth (tree type)
{
int depth;
- for (depth = 0;
- type && TREE_CODE (type) != NAMESPACE_DECL;
- type = (TREE_CODE (type) == FUNCTION_DECL)
- ? CP_DECL_CONTEXT (type) : CP_TYPE_CONTEXT (type))
+ for (depth = 0; type && TREE_CODE (type) != NAMESPACE_DECL; )
{
tree tinfo = get_template_info (type);
if (tinfo && PRIMARY_TEMPLATE_P (TI_TEMPLATE (tinfo))
&& uses_template_parms (INNERMOST_TEMPLATE_ARGS (TI_ARGS (tinfo))))
++depth;
+
+ if (VAR_OR_FUNCTION_DECL_P (type))
+ type = CP_DECL_CONTEXT (type);
+ else if (LAMBDA_TYPE_P (type))
+ type = LAMBDA_TYPE_EXTRA_SCOPE (type);
+ else
+ type = CP_TYPE_CONTEXT (type);
}
return depth;