aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2021-03-04 20:20:40 -0500
committerMarek Polacek <polacek@redhat.com>2021-03-25 14:46:29 -0400
commit9efd72d28956eb79c7fca38e3c959733a3bb25bb (patch)
tree9b0f68d043434302324aec5adc59913ada762393 /gcc/cp/call.c
parent15d649f79d6b6dc336f6a32eec242b652a262a82 (diff)
downloadgcc-9efd72d28956eb79c7fca38e3c959733a3bb25bb.zip
gcc-9efd72d28956eb79c7fca38e3c959733a3bb25bb.tar.gz
gcc-9efd72d28956eb79c7fca38e3c959733a3bb25bb.tar.bz2
c++: -Wconversion vs value-dependent expressions [PR99331]
This PR complains that we issue a -Wconversion warning in template <int N> struct X {}; template <class T> X<sizeof(T)> foo(); saying "conversion from 'long unsigned int' to 'int' may change value". While it's not technically wrong, I suspect -Wconversion warnings aren't all that useful for value-dependent expressions. So this patch disables them. This is a regression that started with r241425: @@ -7278,7 +7306,7 @@ convert_template_argument (tree parm, val = error_mark_node; } } - else if (!dependent_template_arg_p (orig_arg) + else if (!type_dependent_expression_p (orig_arg) && !uses_template_parms (t)) /* We used to call digest_init here. However, digest_init will report errors, which we don't want when complain Here orig_arg is SIZEOF_EXPR<T>; dependent_template_arg_p (orig_arg) was true, but type_dependent_expression_p (orig_arg) is false so we warn in convert_nontype_argument. gcc/cp/ChangeLog: PR c++/99331 * call.c (build_converted_constant_expr_internal): Don't emit -Wconversion warnings. gcc/testsuite/ChangeLog: PR c++/99331 * g++.dg/warn/Wconversion5.C: New test.
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index bab0c89..e757e18 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -4484,6 +4484,9 @@ build_converted_constant_expr_internal (tree type, tree expr,
&& processing_template_decl)
conv = next_conversion (conv);
+ /* Issuing conversion warnings for value-dependent expressions is
+ likely too noisy. */
+ warning_sentinel w (warn_conversion);
conv->check_narrowing = true;
conv->check_narrowing_const_only = true;
expr = convert_like (conv, expr, complain);