PR c++/88120 - ICE when calling save_expr in a template.
authorMarek Polacek <polacek@redhat.com>
Mon, 26 Nov 2018 23:26:40 +0000 (23:26 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 26 Nov 2018 23:26:40 +0000 (23:26 +0000)
* typeck.c (cp_build_binary_op): Call cp_save_expr instead of
save_expr.

* g++.dg/cpp0x/pr88120.C: New test.

From-SVN: r266492

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/pr88120.C [new file with mode: 0644]

index e870205541b5828e9ec7cc1aa4ffa6ae22806bac..8e157f6c25c1a20c04e4f372b2622e2137e2d96f 100644 (file)
@@ -1,3 +1,9 @@
+2018-11-26  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/88120 - ICE when calling save_expr in a template.
+       * typeck.c (cp_build_binary_op): Call cp_save_expr instead of
+       save_expr.
+
 2018-11-22  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/87386
index 81cb4057a5b424882bdc82392ab00a15fccabaa8..f45c06e3fe42f50df9ba11269a097bf01b620ee2 100644 (file)
@@ -4919,7 +4919,7 @@ cp_build_binary_op (location_t location,
              tree pfn0, delta0, e1, e2;
 
              if (TREE_SIDE_EFFECTS (op0))
-               op0 = save_expr (op0);
+               op0 = cp_save_expr (op0);
 
              pfn0 = pfn_from_ptrmemfunc (op0);
              delta0 = delta_from_ptrmemfunc (op0);
index 234885aa44fdb9b72094e05c8ea4dc979809932a..989b548276e4fca3ebd872da78e382c15674e9b6 100644 (file)
@@ -1,3 +1,8 @@
+2018-11-26  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/88120 - ICE when calling save_expr in a template.
+       * g++.dg/cpp0x/pr88120.C: New test.
+
 2018-11-26  Jozef Lawrynowicz  <jozef.l@mittosystems.com>
 
        * c-c++-common/Warray-bounds-3.c (test_strcpy_bounds): Use long instead
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr88120.C b/gcc/testsuite/g++.dg/cpp0x/pr88120.C
new file mode 100644 (file)
index 0000000..7004e03
--- /dev/null
@@ -0,0 +1,23 @@
+// PR c++/88120
+// { dg-do compile { target c++11 } }
+
+typedef int a;
+enum b : a;
+class c {
+  enum f { d };
+  c(f);
+  friend c operator&(c, c);
+  typedef void (c::*e)();
+  operator e();
+};
+class g {
+  template <typename, typename> b h();
+  struct k {
+    c i;
+  };
+};
+template <typename, typename> b g::h() {
+  k j;
+  &j || j.i &c::d;
+  return b();
+}