[PATCH][RFC] Instrument function exit with __builtin_unreachable in C++.

Martin Liška mliska@suse.cz
Fri Nov 3 13:42:00 GMT 2017


On 10/24/2017 04:19 PM, Jason Merrill wrote:
> On 10/18/2017 09:07 AM, Martin Liška wrote:
>> @@ -1182,7 +1182,13 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, tree fun,
>>      {
>>        new_call = build_call_array_loc (EXPR_LOCATION (t), TREE_TYPE (t),
>>                         CALL_EXPR_FN (t), nargs, args);
>> -      error ("%q+E is not a constant expression", new_call);
>> +
>> +      /* Do not allow__builtin_unreachable in constexpr function.  */
>> +      if (DECL_FUNCTION_CODE (fun) == BUILT_IN_UNREACHABLE
>> +          && EXPR_LOCATION (t) == BUILTINS_LOCATION)
>> +        error ("constexpr call flows off the end of the function");
>> +      else
>> +        error ("%q+E is not a constant expression", new_call);
> 
> You don't need to build new_call in the new case, since you don't use it.
> 
> Also, please adjust the comment to say that a __builtin_unreachable call with BUILTINS_LOCATION comes from cp_maybe_instrument_return.
> 
> OK with those changes.
> 
> Jason

Hi.

Thank you for review, done that.
Can you please take a look at the single problematic test-case that blocks acceptance of the patch to trunk?

Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Instrument-function-exit-with-__builtin_unreachable-v2.patch
Type: text/x-patch
Size: 5453 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20171103/cedcea0d/attachment.bin>


More information about the Gcc-patches mailing list