diff options
author | Martin Jambor <jamborm@gcc.gnu.org> | 2016-04-26 13:51:23 +0200 |
---|---|---|
committer | Martin Jambor <jamborm@gcc.gnu.org> | 2016-04-26 13:51:23 +0200 |
commit | 83f5f27d01889e03b6c56d5b418f8a1b6d33df59 (patch) | |
tree | 94d6d8dafd1139bcde15dd0c068416493073bb9f /gcc | |
parent | 5a0802ea0811cf7fbcd34cd96564e7e9338ba5f5 (diff) | |
download | gcc-83f5f27d01889e03b6c56d5b418f8a1b6d33df59.zip gcc-83f5f27d01889e03b6c56d5b418f8a1b6d33df59.tar.gz gcc-83f5f27d01889e03b6c56d5b418f8a1b6d33df59.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/tree-cfg.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 04e46fd..e1fdc9e 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -3414,6 +3414,30 @@ verify_gimple_call (gcall *stmt) 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 didn't see a function declaration before the call. So for now leave the call arguments mostly unverified. Once we gimplify |