]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/65727 (Segfault With Decltype In Lambda Expression Used To Initialize Stati...
authorMarek Polacek <polacek@redhat.com>
Thu, 23 Apr 2015 13:20:14 +0000 (13:20 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 23 Apr 2015 13:20:14 +0000 (09:20 -0400)
PR c++/65727
* semantics.c (maybe_resolve_dummy): Handle null return.

From-SVN: r222364

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-decltype2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice3.C

index e8835aea547e34f59e2814f03e2b4c9387f16d20..58f9161c078fd5b0a4721059258088f2ac933159 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-23  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/65727
+       * semantics.c (maybe_resolve_dummy): Handle null return.
+
 2015-04-23  Jason Merrill  <jason@redhat.com>
 
        PR c++/65721
index 329f12f09004a8db1f9fef175a9fe3894bf7c202..b833b079a6baec6f7a8173cba25a6f1baa2a1bcf 100644 (file)
@@ -9633,8 +9633,9 @@ maybe_resolve_dummy (tree object)
       /* In a lambda, need to go through 'this' capture.  */
       tree lam = CLASSTYPE_LAMBDA_EXPR (current_class_type);
       tree cap = lambda_expr_this_capture (lam);
-      object = build_x_indirect_ref (EXPR_LOCATION (object), cap,
-                                    RO_NULL, tf_warning_or_error);
+      if (cap && cap != error_mark_node)
+       object = build_x_indirect_ref (EXPR_LOCATION (object), cap,
+                                      RO_NULL, tf_warning_or_error);
     }
 
   return object;
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-decltype2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-decltype2.C
new file mode 100644 (file)
index 0000000..51bf0ec
--- /dev/null
@@ -0,0 +1,25 @@
+// PR c++/65727
+// { dg-do compile { target c++11 } }
+
+struct type_a { void(*cb)(); };
+
+struct type_b
+{
+    type_b(type_a p);
+    void dummy();
+};
+
+template<class T>
+constexpr T function_c(T**t) {return **t;}
+
+class type_d {
+    public:
+        static void dummy();
+};
+class type_e {
+    public:
+        static type_b b;
+        type_d *d[1];
+};
+
+type_b type_e::b = {{[](){decltype(function_c(type_e::d))::dummy();}}};
index 8ff36478d538bbe869b2d4cb70879485f4d45c39..8d32fac0a6c5ff5979168dfe95ad7c10c09ff805 100644 (file)
@@ -3,7 +3,7 @@
 
 class Klass
 {
-  unsigned int local;
+  unsigned int local;          // { dg-message "" }
 public:
   bool dostuff();
 };
@@ -11,7 +11,7 @@ public:
 bool Klass::dostuff()
 {
   auto f = []() -> bool {
-    if (local & 1) { return true; } // { dg-error "not captured" }
+    if (local & 1) { return true; } // { dg-error "" }
     return false;
   };
 }