aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2002-04-29 08:47:31 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2002-04-29 08:47:31 +0000
commit4bd7c27025afa9f79d44b053a84ca96f110787b7 (patch)
tree0aab6258047fd6e01573703d7638d8a5955f1161 /gcc
parent53e72ddf6b54cd6a92e28450a837b5579cc93704 (diff)
downloadgcc-4bd7c27025afa9f79d44b053a84ca96f110787b7.zip
gcc-4bd7c27025afa9f79d44b053a84ca96f110787b7.tar.gz
gcc-4bd7c27025afa9f79d44b053a84ca96f110787b7.tar.bz2
re PR c++/5719 (Suspect gcc-3 to report wrong waring for 'T& T::operator+=( const T& )')
cp: PR c++/5719 * decl.c (grok_op_properties): Assignment ops don't have to return by value. operator% should. testsuite: * g++.dg/warn/effc1.C: New test. From-SVN: r52888
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c4
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/warn/effc1.C16
4 files changed, 29 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6167381..e076a34 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2002-04-29 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/5719
+ * decl.c (grok_op_properties): Assignment ops don't have to return
+ by value. operator% should.
+
2002-04-28 Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
PR c/6343
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 642fcf0..450bc39 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -12677,10 +12677,12 @@ grok_op_properties (decl, friendp)
/* Effective C++ rule 23. */
if (warn_ecpp
&& arity == 2
+ && !DECL_ASSIGNMENT_OPERATOR_P (decl)
&& (operator_code == PLUS_EXPR
|| operator_code == MINUS_EXPR
|| operator_code == TRUNC_DIV_EXPR
- || operator_code == MULT_EXPR)
+ || operator_code == MULT_EXPR
+ || operator_code == TRUNC_MOD_EXPR)
&& TREE_CODE (TREE_TYPE (TREE_TYPE (decl))) == REFERENCE_TYPE)
warning ("`%D' should return by value", decl);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f806315..0024a92 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2002-04-29 Nathan Sidwell <nathan@codesourcery.com>
+
+ * g++.dg/warn/effc1.C: New test.
+
2002-04-29 Neil Booth <neil@daikokuya.demon.co.uk>
* gcc.dg/cpp/if-cexp.c: Add a test.
diff --git a/gcc/testsuite/g++.dg/warn/effc1.C b/gcc/testsuite/g++.dg/warn/effc1.C
new file mode 100644
index 0000000..e90c5f7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/effc1.C
@@ -0,0 +1,16 @@
+// { dg-options -Weffc++ }
+// { dg-do compile }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 26 Apr 2002 <nathan@codesourcery.com>
+
+// Bug 5719
+
+class A
+{
+ public:
+ A & operator+=( int );
+ A & operator+( int ); // { dg-warning "`A& A::operator+(int)' should return by value" "" }
+ A operator+=( float );
+ A operator+( float );
+};