Commit 83f5f27d by Martin Jambor

Verify __builtin_unreachable and __builtin_trap are not called with arguments

2016-04-26  Martin Jambor  <mjambor@suse.cz>

	* tree-cfg.c (verify_gimple_call): Check that calls to
	__builtin_unreachable or __builtin_trap do not have actual arguments.

From-SVN: r235439
parent 5a0802ea
...@@ -3414,6 +3414,30 @@ verify_gimple_call (gcall *stmt) ...@@ -3414,6 +3414,30 @@ verify_gimple_call (gcall *stmt)
return true; return true;
} }
if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
{
switch (DECL_FUNCTION_CODE (fndecl))
{
case BUILT_IN_UNREACHABLE:
case BUILT_IN_TRAP:
if (gimple_call_num_args (stmt) > 0)
{
/* Built-in unreachable with parameters might not be caught by
undefined behavior sanitizer. Front-ends do check users do not
call them that way but we also produce calls to
__builtin_unreachable internally, for example when IPA figures
out a call cannot happen in a legal program. In such cases,
we must make sure arguments are stripped off. */
error ("__builtin_unreachable or __builtin_trap call with "
"arguments");
return true;
}
break;
default:
break;
}
}
/* ??? The C frontend passes unpromoted arguments in case it /* ??? The C frontend passes unpromoted arguments in case it
didn't see a function declaration before the call. So for now didn't see a function declaration before the call. So for now
leave the call arguments mostly unverified. Once we gimplify leave the call arguments mostly unverified. Once we gimplify
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment