From d179d1790729f3be184bab0cf5c4d9e5380f0814 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 9 Dec 2011 15:18:22 -0500 Subject: re PR c++/51151 (Invalid -Woverflow warning in C++ frontend) PR c++/51151 * call.c (perform_implicit_conversion_flags): Remove earlier kludge. * parser.c (cp_parser_omp_for_loop): Use cp_parser_omp_for_incr in templates even if decl isn't type-dependent. From-SVN: r182175 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/call.c | 5 +---- gcc/cp/parser.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/warn/Woverflow-4.C | 13 +++++++++++++ 5 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/warn/Woverflow-4.C (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3698349..8090030 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2011-12-09 Jason Merrill + + PR c++/51151 + * call.c (perform_implicit_conversion_flags): Remove earlier kludge. + * parser.c (cp_parser_omp_for_loop): Use cp_parser_omp_for_incr + in templates even if decl isn't type-dependent. + 2011-12-09 Dodji Seketeli PR c++/51289 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index d8fc4f1..6528368 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -8437,10 +8437,7 @@ perform_implicit_conversion_flags (tree type, tree expr, tsubst_flags_t complain } expr = error_mark_node; } - else if (processing_template_decl - /* As a kludge, we always perform conversions between scalar - types, as IMPLICIT_CONV_EXPR confuses c_finish_omp_for. */ - && !(SCALAR_TYPE_P (type) && SCALAR_TYPE_P (TREE_TYPE (expr)))) + else if (processing_template_decl && conv->kind != ck_identity) { /* In a template, we are only concerned about determining the type of non-dependent expressions, so we do not have to diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 5952a0f..2985d76 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -26305,7 +26305,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses) /* If decl is an iterator, preserve the operator on decl until finish_omp_for. */ if (decl - && ((type_dependent_expression_p (decl) + && ((processing_template_decl && !POINTER_TYPE_P (TREE_TYPE (decl))) || CLASS_TYPE_P (TREE_TYPE (decl)))) incr = cp_parser_omp_for_incr (parser, decl); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2430c7f..5c3e51b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-12-09 Jason Merrill + + PR c++/51151 + * g++.dg/warn/Woverflow-4.C: New. + 2011-12-09 Dodji Seketeli PR c++/51289 diff --git a/gcc/testsuite/g++.dg/warn/Woverflow-4.C b/gcc/testsuite/g++.dg/warn/Woverflow-4.C new file mode 100644 index 0000000..1595bca --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Woverflow-4.C @@ -0,0 +1,13 @@ +// PR c++/51151 +// { dg-options "-Wshadow" } + +template class C { +public: + void f() { + m = c2 + 1; + } + static const long unsigned int c1 = 7; + static const int c2 = c1 - 1; + int m; +}; +template class C; -- cgit v1.1