re PR c++/57891 (No diagnostic of narrowing conversion in non-type template argument)
authorMarek Polacek <polacek@redhat.com>
Mon, 13 Aug 2018 23:12:11 +0000 (23:12 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 13 Aug 2018 23:12:11 +0000 (23:12 +0000)
commited4f2c001a883b2456fc607a33f1c59f9c4ee65d
treebb59b5967b87790c2db09cc3bea564380edad161
parentd66d6d15f1ab42c503025548d6ab9772a85ad791
re PR c++/57891 (No diagnostic of narrowing conversion in non-type template argument)

PR c++/57891
* call.c (struct conversion): Add check_narrowing_const_only.
(build_converted_constant_expr): Set check_narrowing and
check_narrowing_const_only.  Give error if expr is error node.
(convert_like_real): Pass it to check_narrowing.
* cp-tree.h (check_narrowing): Add a default parameter.
* decl.c (compute_array_index_type): Use input_location instead of
location_of.
* pt.c (convert_nontype_argument): Return NULL_TREE if tf_error.
* typeck2.c (check_narrowing): Don't warn for instantiation-dependent
expressions.  Call maybe_constant_value instead of
fold_non_dependent_expr.  Don't mention { } in diagnostic.  Only check
narrowing for constants if CONST_ONLY.

* g++.dg/cpp0x/Wnarrowing6.C: New test.
* g++.dg/cpp0x/Wnarrowing7.C: New test.
* g++.dg/cpp0x/Wnarrowing8.C: New test.
* g++.dg/cpp0x/Wnarrowing9.C: New test.
* g++.dg/cpp0x/Wnarrowing10.C: New test.
* g++.dg/cpp0x/constexpr-47969.C: Adjust dg-error.
* g++.dg/cpp0x/constexpr-ex2.C: Likewise.
* g++.dg/cpp0x/constexpr-targ.C: Likewise.
* g++.dg/cpp0x/scoped_enum2.C: Likewise.
* g++.dg/ext/stmtexpr15.C: Likewise.
* g++.dg/gomp/pr47963.C: Likewise.
* g++.dg/init/new37.C: Likewise.
* g++.dg/init/new43.C: Likewise.
* g++.dg/other/fold1.C: Likewise.
* g++.dg/parse/array-size2.C: Likewise.
* g++.dg/template/dependent-name3.C: Likewise.
* g++.dg/cpp0x/constexpr-data2.C: Add dg-error.
* g++.dg/other/vrp1.C: Likewise.
* g++.dg/template/char1.C: Likewise.

From-SVN: r263523
26 files changed:
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/pt.c
gcc/cp/typeck2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/Wnarrowing10.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/Wnarrowing6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/Wnarrowing7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/Wnarrowing8.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/Wnarrowing9.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/constexpr-47969.C
gcc/testsuite/g++.dg/cpp0x/constexpr-data2.C
gcc/testsuite/g++.dg/cpp0x/constexpr-ex2.C
gcc/testsuite/g++.dg/cpp0x/constexpr-targ.C
gcc/testsuite/g++.dg/cpp0x/scoped_enum2.C
gcc/testsuite/g++.dg/ext/stmtexpr15.C
gcc/testsuite/g++.dg/gomp/pr47963.C
gcc/testsuite/g++.dg/init/new37.C
gcc/testsuite/g++.dg/init/new43.C
gcc/testsuite/g++.dg/other/fold1.C
gcc/testsuite/g++.dg/other/vrp1.C
gcc/testsuite/g++.dg/parse/array-size2.C
gcc/testsuite/g++.dg/template/char1.C
gcc/testsuite/g++.dg/template/dependent-name3.C