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
This commit is contained in:
parent
a5e8cbd150
commit
e8b0383c13
@ -1,5 +1,9 @@
|
||||
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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
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.
|
||||
|
||||
|
36
gcc/testsuite/g++.dg/lookup/pr79377.C
Normal file
36
gcc/testsuite/g++.dg/lookup/pr79377.C
Normal file
@ -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 <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 ();
|
||||
}
|
Loading…
Reference in New Issue
Block a user