diff options
author | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-07-11 08:13:58 +0000 |
---|---|---|
committer | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-07-11 08:13:58 +0000 |
commit | 37c009d60da396a6d065075a91d5f9ff9066669f (patch) | |
tree | 8c68f34ae44ade5ba50e168f32771fb7274dea13 /gcc | |
parent | a03ae2b7b70906e775143c18dc24e82ca543221d (diff) | |
download | ppe42-gcc-37c009d60da396a6d065075a91d5f9ff9066669f.tar.gz ppe42-gcc-37c009d60da396a6d065075a91d5f9ff9066669f.zip |
* typeck.c (build_binary_op): Do not warn about signed
vs. unsigned comparisons in the bodies of templates.
* g++.dg/warn/Wsign-compare-1.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@69222 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wsign-compare-1.C | 6 |
4 files changed, 17 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1d64a22e497..5722e9f3d53 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2003-07-10 Mark Mitchell <mark@codesourcery.com> + * typeck.c (build_binary_op): Do not warn about signed + vs. unsigned comparisons in the bodies of templates. + PR c++/9411 * parser.c (cp_parser_postfix_expression): Check dependency of functions. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 58055eca08b..8e1e0df8b78 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3443,7 +3443,10 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, } if ((short_compare || code == MIN_EXPR || code == MAX_EXPR) - && warn_sign_compare) + && warn_sign_compare + /* Do not warn until the template is instantiated; we cannot + bound the ranges of the arguments until that point. */ + && !processing_template_decl) { int op0_signed = ! TREE_UNSIGNED (TREE_TYPE (orig_op0)); int op1_signed = ! TREE_UNSIGNED (TREE_TYPE (orig_op1)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f7b1551cca2..968a056df17 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2003-07-11 Mark Mitchell <mark@codesourcery.com> + + * g++.dg/warn/Wsign-compare-1.C: New test. + 2003-07-10 Kazu Hirata <kazu@cs.umass.edu> * gcc.dg/20021018-1.c: Disable if the sizeof (int) < 4. diff --git a/gcc/testsuite/g++.dg/warn/Wsign-compare-1.C b/gcc/testsuite/g++.dg/warn/Wsign-compare-1.C new file mode 100644 index 00000000000..495bb992cdd --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wsign-compare-1.C @@ -0,0 +1,6 @@ +// { dg-options "-Wsign-compare" } + +extern unsigned u; + +template<class F> +int f() { return u > 1; } |