diff options
author | Marek Polacek <mpolacek@gcc.gnu.org> | 2013-08-30 16:12:58 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2013-08-30 16:12:58 +0000 |
commit | de5a5fa1395db2cb5da4d0593fef40ec22378576 (patch) | |
tree | 23d42aa647cb7a2de96792b724ecaaddee3423fa /gcc/opts.c | |
parent | f07f30cfb5efe0806dedaea03b56c574da1b372c (diff) | |
download | gcc-de5a5fa1395db2cb5da4d0593fef40ec22378576.zip gcc-de5a5fa1395db2cb5da4d0593fef40ec22378576.tar.gz gcc-de5a5fa1395db2cb5da4d0593fef40ec22378576.tar.bz2 |
Merge ubsan into trunk.
From-SVN: r202113
Diffstat (limited to 'gcc/opts.c')
-rw-r--r-- | gcc/opts.c | 64 |
1 files changed, 64 insertions, 0 deletions
@@ -1405,6 +1405,70 @@ common_handle_option (struct gcc_options *opts, opts->x_exit_after_options = true; break; + case OPT_fsanitize_: + { + const char *p = arg; + while (*p != 0) + { + static const struct + { + const char *const name; + unsigned int flag; + size_t len; + } spec[] = + { + { "address", SANITIZE_ADDRESS, sizeof "address" - 1 }, + { "thread", SANITIZE_THREAD, sizeof "thread" - 1 }, + { "shift", SANITIZE_SHIFT, sizeof "shift" - 1 }, + { "integer-divide-by-zero", SANITIZE_DIVIDE, + sizeof "integer-divide-by-zero" - 1 }, + { "undefined", SANITIZE_UNDEFINED, sizeof "undefined" - 1 }, + { "unreachable", SANITIZE_UNREACHABLE, + sizeof "unreachable" - 1 }, + { NULL, 0, 0 } + }; + const char *comma; + size_t len, i; + bool found = false; + + comma = strchr (p, ','); + if (comma == NULL) + len = strlen (p); + else + len = comma - p; + if (len == 0) + { + p = comma + 1; + continue; + } + + /* Check to see if the string matches an option class name. */ + for (i = 0; spec[i].name != NULL; ++i) + if (len == spec[i].len + && memcmp (p, spec[i].name, len) == 0) + { + /* Handle both -fsanitize and -fno-sanitize cases. */ + if (value) + flag_sanitize |= spec[i].flag; + else + flag_sanitize &= ~spec[i].flag; + found = true; + break; + } + + if (! found) + warning_at (loc, 0, + "unrecognized argument to -fsanitize= option: %q.*s", + (int) len, p); + + if (comma == NULL) + break; + p = comma + 1; + } + + break; + } + case OPT_O: case OPT_Os: case OPT_Ofast: |