Fix evaluation of reflection functions and improve error reporting.
Correctly handle non-constant expressions in reflection functions and refine error messages.
This commit addresses issues in C++ reflection’s evaluation functions, specifically eval_reflect_*. Previously, these functions could return error markers without properly setting a flag indicating a non-constant expression, leading to crashes later in the compilation process. The fix ensures this flag is set and guards against redundant error emissions. Additionally, it improves the clarity of error messages by printing the correct type information.
In Details
The eval_reflect_constant, eval_reflect_object, and eval_reflect_function functions in gcc/cp/reflect.cc were not consistently setting the *non_constant_p flag when encountering errors. This led to error_mark_node being present in initializers, causing subsequent display_string_of calls to crash. The fix guards the error reporting with cxx_constexpr_quiet_p to prevent duplicate messages and corrects type printing in error diagnostics.