c++: ICE with -Wall and constexpr if [PR94937]
authorMarek Polacek <polacek@redhat.com>
Wed, 6 May 2020 23:24:58 +0000 (19:24 -0400)
committerMarek Polacek <polacek@redhat.com>
Mon, 18 May 2020 22:53:38 +0000 (18:53 -0400)
commitbf732686c0b9c42a2fe119db774c5a65e5a97174
treedf923e1c6f96adfba733524631c290db6c89620f
parent8edf0adb6616bd717312d9b305c7d7c9a6b7a171
c++: ICE with -Wall and constexpr if [PR94937]

An ICE arises here because we call cp_get_callee_fndecl_nofold in a
template, and we've got a CALL_EXPR whose CALL_EXPR_FN is a BASELINK.
This tickles the INDIRECT_TYPE_P assert in cp_get_fndecl_from_callee.

Fixed by turning the assert into a condition and returning NULL_TREE
in that case.

PR c++/94937
* cvt.c (cp_get_fndecl_from_callee): Return NULL_TREE if the function
type is not INDIRECT_TYPE_P.
* decl.c (omp_declare_variant_finalize_one): Call
cp_get_callee_fndecl_nofold instead of looking for the function decl
manually.

* g++.dg/cpp1z/constexpr-if34.C: New test.
* g++.dg/cpp2a/is-constant-evaluated10.C: New test.
gcc/cp/ChangeLog
gcc/cp/cvt.c
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1z/constexpr-if34.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/is-constant-evaluated10.C [new file with mode: 0644]