From: Jakub Jelinek Date: Mon, 6 Feb 2017 20:05:09 +0000 (+0100) Subject: re PR c++/79377 (ICE with increment operator in -fpermissive mode) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e8b0383c1324a80e554e9e0401dc5830c700bb0e;p=gcc.git re PR c++/79377 (ICE with increment operator in -fpermissive mode) 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. * g++.dg/lookup/pr79377.C: New test. From-SVN: r245219 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9889c171b01..a318c7fb8b8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2017-02-06 Jakub Jelinek + 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 diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 3ecc2b00fef..afd442f5801 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2938,8 +2938,10 @@ build_min_non_dep_op_overload (enum tree_code op, 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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 954851b961d..3313268a639 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2017-02-06 Jakub Jelinek + PR c++/79377 + * g++.dg/lookup/pr79377.C: New test. + PR c++/79372 * g++.dg/cpp1z/decomp25.C: New test. diff --git a/gcc/testsuite/g++.dg/lookup/pr79377.C b/gcc/testsuite/g++.dg/lookup/pr79377.C new file mode 100644 index 00000000000..baf9a256c7c --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/pr79377.C @@ -0,0 +1,36 @@ +// 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 +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 (a); + if (A::c != 4 || a.a != 4) __builtin_abort (); +}