PR c++/85141 - ICE with compound assignment and static member fn.
authorJason Merrill <jason@redhat.com>
Wed, 4 Apr 2018 16:42:39 +0000 (12:42 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 4 Apr 2018 16:42:39 +0000 (12:42 -0400)
* typeck.c (cp_build_modify_expr): Call decay_conversion for RHS of
compound assignment.

From-SVN: r259089

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/g++.dg/expr/assign2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/parse/crash60.C

index 61483a5fa79ec1599970eb589187f607b1fc32e0..8ab7cce4732106ac88d5f477906880e85b0f1b74 100644 (file)
@@ -1,5 +1,9 @@
 2018-04-04  Jason Merrill  <jason@redhat.com>
 
+       PR c++/85141 - ICE with compound assignment and static member fn.
+       * typeck.c (cp_build_modify_expr): Call decay_conversion for RHS of
+       compound assignment.
+
        PR c++/85148 - ICE with 'this' in array NSDMI.
        * tree.c (replace_placeholders_r): Use handled_component_p.
 
index 2b7a771bbeb300178617097dc004f7c607ca98c7..e5ad54dbcd19ef05dd86ae9982de33d6b014c4e4 100644 (file)
@@ -8083,7 +8083,7 @@ cp_build_modify_expr (location_t loc, tree lhs, enum tree_code modifycode,
             side effect associated with any single compound assignment
             operator. -- end note ]  */
          lhs = cp_stabilize_reference (lhs);
-         rhs = rvalue (rhs);
+         rhs = decay_conversion (rhs, complain);
          if (rhs == error_mark_node)
            return error_mark_node;
          rhs = stabilize_expr (rhs, &init);
diff --git a/gcc/testsuite/g++.dg/expr/assign2.C b/gcc/testsuite/g++.dg/expr/assign2.C
new file mode 100644 (file)
index 0000000..759584a
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/85141
+// { dg-options "-w -fpermissive" }
+
+struct A
+{
+  static int foo();
+};
+
+void bar(int i)
+{
+  i += A().foo;
+}
index e515396771ec8071ea7848ed93ef39bc0b525eb2..8e545a253c59371edc0a4b3509cee61df4d4c17c 100644 (file)
@@ -10,5 +10,5 @@ void foo()
   int result = 0;
   M m;
 
-  result += m.pop();  // { dg-error "invalid operands|in evaluation" }
+  result += m.pop();  // { dg-error "" }
 }