re PR c++/84925 (ICE with segfault in __PRETTY_FUNCTION__)
authorMarek Polacek <polacek@redhat.com>
Mon, 19 Mar 2018 20:34:45 +0000 (20:34 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 19 Mar 2018 20:34:45 +0000 (20:34 +0000)
PR c++/84925
* pt.c (enclosing_instantiation_of): Check if fn is null.

* g++.dg/cpp1z/lambda-__func__.C: New test.

From-SVN: r258660

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1z/lambda-__func__.C [new file with mode: 0644]

index 194b46890825d186252a063c58f72abaf7422dff..712d4d8bc2d31ecd6b221511a8017decc508356c 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-19  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/84925
+       * pt.c (enclosing_instantiation_of): Check if fn is null.
+
 2018-03-16  Jason Merrill  <jason@redhat.com>
 
        PR c++/71834 - template-id with too few arguments.
index 086cdc20781b7ecd173d40dbce7987a23d0ae55c..21a4de57745f60ff083b2e9c7f1a73577d4bf99b 100644 (file)
@@ -12917,7 +12917,7 @@ enclosing_instantiation_of (tree otctx)
       for (; flambda_count < lambda_count && fn && LAMBDA_FUNCTION_P (fn);
           fn = decl_function_context (fn))
        ++flambda_count;
-      if (DECL_TEMPLATE_INFO (fn)
+      if ((fn && DECL_TEMPLATE_INFO (fn))
          ? most_general_template (fn) != most_general_template (tctx)
          : fn != tctx)
        continue;
index e3309b33d1b5367be4b0d42cd51d6b8787b17ea6..882dc9ab92d32897fee63bf6aa60b115099dcfd2 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-19  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/84925
+       * g++.dg/cpp1z/lambda-__func__.C: New test.
+
 2018-03-19  Maxim Ostapenko  <m.ostapenko@samsung.com>
 
        PR sanitizer/78651
diff --git a/gcc/testsuite/g++.dg/cpp1z/lambda-__func__.C b/gcc/testsuite/g++.dg/cpp1z/lambda-__func__.C
new file mode 100644 (file)
index 0000000..d5d1c1c
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/84925
+// { dg-options "-std=c++17" }
+
+template <typename>
+struct A {
+  static const int value = 0;
+  static auto constexpr fn = [] { return __func__; };
+};
+
+template <typename type>
+int x = A<type>::value;
+
+auto s = x<int>;