diff --git a/gcc/cp/call.c b/gcc/cp/call.c index bab0c89d6c72..e757e1893c77 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); diff --git a/gcc/testsuite/g++.dg/warn/Wconversion5.C b/gcc/testsuite/g++.dg/warn/Wconversion5.C new file mode 100644 index 000000000000..f5ae6312bc59 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wconversion5.C @@ -0,0 +1,19 @@ +// PR c++/99331 +// { dg-do compile { target c++11 } } +// { dg-options "-Wconversion" } +// Don't issue -Wconversion warnings for value-dependent expressions. + +template struct X {}; +template struct Y {}; +template X foo(); +template X foo2(); +template Y foo3(); +template Y<1024> foo4(); // { dg-error "narrowing conversion" } +template Y<1u> foo5(); +template X<__INT_MAX__ + 1U> foo6(); // { dg-error "narrowing conversion" } + +template +struct S { + using t = X; + using u = X; +};