Skip to content
Snippets Groups Projects
Commit e6a29aab authored by Jason Merrill's avatar Jason Merrill
Browse files

c++: constexpr-evaluate more assumes

The initial [[assume]] support avoided evaluating assumes with
TREE_SIDE_EFFECTS set, such as calls, because we don't want any side-effects
that change the constexpr state.  This patch allows us to evaluate
expressions with that flag set by tracking which variables the evaluation is
allowed to modify, and giving up if it tries to touch any others.

I considered allowing changes to other variables and then rolling them back,
but that seems like a rare enough situation that it doesn't seem worth
working to handle nicely at this point.

gcc/cp/ChangeLog:

	* constexpr.cc (class constexpr_global_ctx): Add modifiable field,
	get_value, get_value_ptr, put_value, remove_value, flush_modifiable
	member functions.
	(class modifiable_tracker): New.
	(cxx_eval_internal_function): Use it.
	(diagnose_failing_condition): Strip CLEANUP_POINT_EXPR.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp23/attr-assume9.C: New test.
	* g++.dg/cpp23/attr-assume10.C: New test.
parent ac8f92c1
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment