]> 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:21:22 +0000 (13:21 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 23 Apr 2015 13:21:22 +0000 (09:21 -0400)
PR c++/65727
* lambda.c (maybe_resolve_dummy): Handle null return.

From-SVN: r222368

gcc/cp/ChangeLog
gcc/cp/lambda.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 27fd9a9de024729cd38d2849f817910306d6a072..1f029ad09e845dc4f2681445a32927d077360260 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-23  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/65727
+       * lambda.c (maybe_resolve_dummy): Handle null return.
+
 2015-04-23  Jason Merrill  <jason@redhat.com>
 
        PR c++/65695
index 6acbdd9ee2bafdbba967b4f3b8a001bc96a45154..7391dd9b1d1b286eb30dcbc18c10c29b38810e75 100644 (file)
@@ -764,8 +764,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 03a7a4bb60d0539ad13d23b9e8e98aae9f3591eb..09e046fbe8529ee89cc162b51e4461390662663a 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;
   };
 }