re PR c++/16696 (Strange message when operator++ not found)

2009-08-04  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR c++/16696
cp/
	* call.c (build_new_op): Only try prefix operator if -fpermissive,
	otherwise just error.
testsuite/
	* g++.dg/parse/pr16696.C: New.
	* g++.dg/parse/pr16696-permissive.C: New.

From-SVN: r150461
This commit is contained in:
Manuel López-Ibáñez 2009-08-04 15:51:12 +00:00
parent 1b2dc47dd6
commit 481817e4b9
5 changed files with 62 additions and 6 deletions

View File

@ -1,3 +1,9 @@
2009-08-04 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c++/16696
* call.c (build_new_op): Only try prefix operator if -fpermissive,
otherwise just error.
2009-08-04 Dodji Seketeli <dodji@redhat.com>
PR debug/39706

View File

@ -4255,13 +4255,23 @@ build_new_op (enum tree_code code, int flags, tree arg1, tree arg2, tree arg3,
if (!(complain & tf_error))
return error_mark_node;
/* Look for an `operator++ (int)'. If they didn't have
one, then we fall back to the old way of doing things. */
/* Look for an `operator++ (int)'. Pre-1985 C++ didn't
distinguish between prefix and postfix ++ and
operator++() was used for both, so we allow this with
-fpermissive. */
if (flags & LOOKUP_COMPLAIN)
permerror (input_location, "no %<%D(int)%> declared for postfix %qs, "
"trying prefix operator instead",
fnname,
{
const char *msg = (flag_permissive)
? G_("no %<%D(int)%> declared for postfix %qs,"
" trying prefix operator instead")
: G_("no %<%D(int)%> declared for postfix %qs");
permerror (input_location, msg, fnname,
operator_name_info[code].name);
}
if (!flag_permissive)
return error_mark_node;
if (code == POSTINCREMENT_EXPR)
code = PREINCREMENT_EXPR;
else

View File

@ -1,3 +1,9 @@
2009-08-04 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c++/16696
* g++.dg/parse/pr16696.C: New.
* g++.dg/parse/pr16696-permissive.C: New.
2009-08-04 Paul Thomas <pault@gcc.gnu.org>
PR fortran/40875

View File

@ -0,0 +1,17 @@
// PR 16696 Strange message when operator++ not found
// { dg-do compile }
// { dg-options "-fdiagnostics-show-option -fpermissive" }
struct X { void operator++(); };
struct Y { };
int main () {
X x;
Y y;
x++; // { dg-warning "trying prefix operator" }
y++; // { dg-warning "trying prefix operator" }
// { dg-error "no match" "" { target *-*-* } 14 }
}

View File

@ -0,0 +1,17 @@
// PR 16696 Strange message when operator++ not found
// { dg-do compile }
// { dg-options "-fdiagnostics-show-option" }
struct X { void operator++(); };
struct Y { };
int main () {
X x;
Y y;
x++; // { dg-bogus "trying prefix operator" }
// { dg-error "fpermissive" "" { target *-*-* } 12 }
y++; // { dg-bogus "trying prefix operator" }
// { dg-error "fpermissive" "" { target *-*-* } 14 }
}