Commit 36618428 by Marek Polacek Committed by Marek Polacek

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
parent 01e5af5a
2017-03-09 Marek Polacek <polacek@redhat.com>
PR sanitizer/79757
* c-parser.c (c_parser_declaration_or_fndef): Don't sanitize old-style
parameter declarations with initializers.
2017-03-09 Jakub Jelinek <jakub@redhat.com>
PR c/79969
......
......@@ -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)
......
2017-03-09 Marek Polacek <polacek@redhat.com>
PR sanitizer/79757
* 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.
2017-03-09 Jakub Jelinek <jakub@redhat.com>
PR c/79969
......
/* PR sanitizer/79757 */
/* { dg-do compile } */
/* { dg-require-effective-target int128 } */
/* { dg-options "-fsanitize=undefined" } */
unsigned __int128 x, y;
void
fn1 (void)
{
int a (z)
unsigned long long z = x / y; /* { dg-error "parameter 'z' is initialized" } */
{
}
}
void
fn2 (void)
{
int a (z)
unsigned long long z = x >> y; /* { dg-error "parameter 'z' is initialized" } */
{
}
}
/* PR sanitizer/79757 */
/* { dg-do compile } */
/* { dg-require-effective-target int128 } */
/* { dg-options "-fsanitize=undefined" } */
unsigned __int128 x, y;
void
fn1 (z)
unsigned long long z = x / y; /* { dg-error "parameter 'z' is initialized" } */
{
}
void
fn2 (z)
unsigned long long z = x >> y; /* { dg-error "parameter 'z' is initialized" } */
{
}
/* PR sanitizer/79757 */
/* { dg-do compile } */
/* { dg-require-effective-target int128 } */
/* { dg-options "-fsanitize=undefined" } */
unsigned __int128 x, y;
void
fn1 (z)
__auto_type z = x / y; /* { dg-error "parameter 'z' is initialized" } */
{
}
void
fn2 (z)
__auto_type z = x >> y; /* { dg-error "parameter 'z' is initialized" } */
{
}
/* PR sanitizer/79757 */
/* { dg-do run } */
/* { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } */
/* { dg-options "-fsanitize=undefined" } */
int
main (void)
{
int
div (int n)
{
int i = 5 / n;
return i;
}
int
shift (int n)
{
int i = 5 << n;
return i;
}
int j = shift (100);
int i = div (0);
return 0;
}
/* { dg-output "shift exponent 100 is too large for \[^\n\r]*-bit type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*division by zero" } */
/* PR sanitizer/79757 */
/* { dg-do run } */
/* { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } */
/* { dg-options "-fsanitize=undefined" } */
int
main (void)
{
int
div (int n)
{
__auto_type i = 5 / n;
return i;
}
int
shift (int n)
{
__auto_type i = 5 << n;
return i;
}
int j = shift (100);
int i = div (0);
return 0;
}
/* { dg-output "shift exponent 100 is too large for \[^\n\r]*-bit type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*division by zero" } */
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