diff options
author | Jason Merrill <jason@redhat.com> | 2020-06-16 00:19:53 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2020-06-17 15:08:42 -0400 |
commit | 14c831f5ef614aabb6a8c85712fb166600e6cc05 (patch) | |
tree | 77518af0424598f7533f1eff7f30a44bae69c995 | |
parent | da2c9054f1596b71e3c81efd62b6cef348e445b4 (diff) | |
download | gcc-14c831f5ef614aabb6a8c85712fb166600e6cc05.zip gcc-14c831f5ef614aabb6a8c85712fb166600e6cc05.tar.gz gcc-14c831f5ef614aabb6a8c85712fb166600e6cc05.tar.bz2 |
c++: Fix consteval operator handling.
We were crashing trying to find the CALL_EXPR in the result of a call to a
consteval operator.
gcc/cp/ChangeLog:
* call.c (build_new_op_1): Don't look for a CALL_EXPR when
calling a consteval function.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/consteval17.C: New test.
-rw-r--r-- | gcc/cp/call.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp2a/consteval17.C | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 1d95bd2..5382b76 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -6341,7 +6341,7 @@ build_new_op_1 (const op_location_t &loc, enum tree_code code, int flags, result = build_over_call (cand, LOOKUP_NORMAL, ocomplain); } - if (trivial_fn_p (cand->fn)) + if (trivial_fn_p (cand->fn) || DECL_IMMEDIATE_FUNCTION_P (cand->fn)) /* There won't be a CALL_EXPR. */; else if (result && result != error_mark_node) { diff --git a/gcc/testsuite/g++.dg/cpp2a/consteval17.C b/gcc/testsuite/g++.dg/cpp2a/consteval17.C new file mode 100644 index 0000000..6af39aa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/consteval17.C @@ -0,0 +1,11 @@ +// { dg-do compile { target c++20 } } + +struct A +{ + consteval int operator+() { return 42; } +}; + +int main() +{ + +A(); +} |