aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2017-11-16 12:11:36 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2017-11-16 12:11:36 +0000
commitc757ad4cf61f982a05cb5f424308ec199aa2923d (patch)
treeb6a8e8b5fa835fe7c7f6def7b55f34b44dbfa080
parent81825e283f6cec28db73af9769602b953d683e3e (diff)
downloadgcc-c757ad4cf61f982a05cb5f424308ec199aa2923d.zip
gcc-c757ad4cf61f982a05cb5f424308ec199aa2923d.tar.gz
gcc-c757ad4cf61f982a05cb5f424308ec199aa2923d.tar.bz2
[PR c++/81060] ICE with invalid initialzer via lambda
https://gcc.gnu.org/ml/gcc-patches/2017-11/msg01323.html PR c++/81060 * decl.c (xref_tag_1): Push lambda into current scope. * name-lookup.c (do_pushtag): Don't deal with ts_lambda here. PR c++81060 * g++.dg/cpp0x/lambda/lambda-template13.C: Avoid undefined template using local type error. * g++.dg/cpp0x/pr81060.C: New. From-SVN: r254817
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c8
-rw-r--r--gcc/cp/name-lookup.c6
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template13.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/pr81060.C11
6 files changed, 32 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index e8c882f..31de2a6 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2017-11-16 Nathan Sidwell <nathan@acm.org>
+
+ PR c++/81060
+ * decl.c (xref_tag_1): Push lambda into current scope.
+ * name-lookup.c (do_pushtag): Don't deal with ts_lambda here.
+
2017-11-15 Nathan Sidwell <nathan@acm.org>
PR c++/81574
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 7e16f7b..54e0656 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -13546,8 +13546,12 @@ xref_tag_1 (enum tag_types tag_code, tree name,
t = make_class_type (code);
TYPE_CONTEXT (t) = context;
if (scope == ts_lambda)
- /* Mark it as a lambda type. */
- CLASSTYPE_LAMBDA_EXPR (t) = error_mark_node;
+ {
+ /* Mark it as a lambda type. */
+ CLASSTYPE_LAMBDA_EXPR (t) = error_mark_node;
+ /* And push it into current scope. */
+ scope = ts_current;
+ }
t = pushtag (name, t, scope);
}
}
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index b4976d8..e9d44e4 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -6242,9 +6242,7 @@ do_pushtag (tree name, tree type, tag_scope scope)
view of the language. */
|| (b->kind == sk_template_parms
&& (b->explicit_spec_p || scope == ts_global))
- /* Pushing into a class is ok for lambdas or when we want current */
|| (b->kind == sk_class
- && scope != ts_lambda
&& (scope != ts_current
/* We may be defining a new type in the initializer
of a static member variable. We allow this when
@@ -6267,7 +6265,6 @@ do_pushtag (tree name, tree type, tag_scope scope)
tree cs = current_scope ();
if (scope == ts_current
- || scope == ts_lambda
|| (cs && TREE_CODE (cs) == FUNCTION_DECL))
context = cs;
else if (cs && TYPE_P (cs))
@@ -6304,8 +6301,7 @@ do_pushtag (tree name, tree type, tag_scope scope)
if (b->kind == sk_class)
{
- if (!TYPE_BEING_DEFINED (current_class_type)
- && scope != ts_lambda)
+ if (!TYPE_BEING_DEFINED (current_class_type))
return error_mark_node;
if (!PROCESSING_REAL_TEMPLATE_DECL_P ())
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 57bdc1c..36a8449 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2017-11-16 Nathan Sidwell <nathan@acm.org>
+
+ PR c++81060
+ * g++.dg/cpp0x/lambda/lambda-template13.C: Avoid undefined
+ template using local type error.
+ * g++.dg/cpp0x/pr81060.C: New.
+
2017-11-16 Wilco Dijkstra <wdijkstr@arm.com>
Jackson Woodruff <jackson.woodruff@arm.com>
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template13.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template13.C
index 01fe3f6..8aaf5b2 100644
--- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template13.C
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template13.C
@@ -4,7 +4,7 @@
struct function
{
template < typename _Functor>
- function (_Functor);
+ function (_Functor) {}
};
template <class U>
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr81060.C b/gcc/testsuite/g++.dg/cpp0x/pr81060.C
new file mode 100644
index 0000000..67b2b38
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr81060.C
@@ -0,0 +1,11 @@
+// { dg-do compile { target c++11 } }
+// PR 81050 ICE in invalid after error
+
+template<typename... T> struct A
+{
+ static const int i;
+};
+
+template<typename... T>
+const int A<T>::i // { dg-error "template definition of non-template" }
+= []{ return 0; }(); // BOOM!