2017-02-06 Jakub Jelinek <jakub@redhat.com>
+ PR c++/79377
+ * tree.c (build_min_non_dep_op_overload): For POST{INC,DEC}REMENT_EXPR
+ allow one fewer than expected arguments if flag_permissive.
+
PR c++/79372
* decl.c (cp_finish_decomp): On error set decl type to error_mark_node.
* pt.c (tsubst_expr): Don't call tsubst_decomp_names on decompositions
nargs = call_expr_nargs (non_dep);
expected_nargs = cp_tree_code_length (op);
- if (op == POSTINCREMENT_EXPR
- || op == POSTDECREMENT_EXPR)
+ if ((op == POSTINCREMENT_EXPR
+ || op == POSTDECREMENT_EXPR)
+ /* With -fpermissive non_dep could be operator++(). */
+ && (!flag_permissive || nargs != expected_nargs))
expected_nargs += 1;
gcc_assert (nargs == expected_nargs);
2017-02-06 Jakub Jelinek <jakub@redhat.com>
+ PR c++/79377
+ * g++.dg/lookup/pr79377.C: New test.
+
PR c++/79372
* g++.dg/cpp1z/decomp25.C: New test.
--- /dev/null
+// PR c++/79377
+// { dg-do run }
+// { dg-options "-fpermissive" }
+
+struct A
+{
+ A () : a (0) {}
+ A& operator++ () { ++a; ++c; return *this; }
+ int a;
+ static int c;
+};
+
+int A::c = 0;
+
+template <typename>
+void
+foo (A& a)
+{
+ a++; // { dg-warning "trying prefix operator instead" }
+ if (A::c != 3 || a.a != 3) __builtin_abort ();
+ ++a;
+ if (A::c != 4 || a.a != 4) __builtin_abort ();
+}
+
+int
+main ()
+{
+ A a;
+ if (A::c != 0 || a.a != 0) __builtin_abort ();
+ ++a;
+ if (A::c != 1 || a.a != 1) __builtin_abort ();
+ a++; // { dg-warning "trying prefix operator instead" }
+ if (A::c != 2 || a.a != 2) __builtin_abort ();
+ foo<int> (a);
+ if (A::c != 4 || a.a != 4) __builtin_abort ();
+}