diff options
author | Marek Polacek <polacek@redhat.com> | 2017-03-09 16:58:17 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2017-03-09 16:58:17 +0000 |
commit | 3661842863344b18d736c0f9fd02983ebceaed52 (patch) | |
tree | 3e36b6d392adffb0a06df6a6ae4f007457281828 /gcc/c/c-parser.c | |
parent | 01e5af5a2f5fa4813e359bc03d42e98d091c7a2d (diff) | |
download | gcc-3661842863344b18d736c0f9fd02983ebceaed52.zip gcc-3661842863344b18d736c0f9fd02983ebceaed52.tar.gz gcc-3661842863344b18d736c0f9fd02983ebceaed52.tar.bz2 |
re PR sanitizer/79757 (ICE in declare_vars, at gimplify.c:634)
PR sanitizer/79757
* c-parser.c (c_parser_declaration_or_fndef): Don't sanitize old-style
parameter declarations with initializers.
* gcc.dg/ubsan/pr79757-1.c: New test.
* gcc.dg/ubsan/pr79757-2.c: New test.
* gcc.dg/ubsan/pr79757-3.c: New test.
* gcc.dg/ubsan/pr79757-4.c: New test.
* gcc.dg/ubsan/pr79757-5.c: New test.
From-SVN: r246010
Diffstat (limited to 'gcc/c/c-parser.c')
-rw-r--r-- | gcc/c/c-parser.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 8330e65..1394f18 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -1859,7 +1859,13 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, init_loc = c_parser_peek_token (parser)->location; rich_location richloc (line_table, init_loc); start_init (NULL_TREE, asm_name, global_bindings_p (), &richloc); + /* A parameter is initialized, which is invalid. Don't + attempt to instrument the initializer. */ + int flag_sanitize_save = flag_sanitize; + if (nested && !empty_ok) + flag_sanitize = 0; init = c_parser_expr_no_commas (parser, NULL); + flag_sanitize = flag_sanitize_save; if (TREE_CODE (init.value) == COMPONENT_REF && DECL_C_BIT_FIELD (TREE_OPERAND (init.value, 1))) error_at (here, @@ -1917,7 +1923,13 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, init_loc = c_parser_peek_token (parser)->location; rich_location richloc (line_table, init_loc); start_init (d, asm_name, global_bindings_p (), &richloc); + /* A parameter is initialized, which is invalid. Don't + attempt to instrument the initializer. */ + int flag_sanitize_save = flag_sanitize; + if (TREE_CODE (d) == PARM_DECL) + flag_sanitize = 0; init = c_parser_initializer (parser); + flag_sanitize = flag_sanitize_save; finish_init (); } if (oacc_routine_data) |