diff --git a/gcc/opts.cc b/gcc/opts.cc index 1378ef781d089092adc5fcd7488027c582e43383..2ffbf429b7b8f4234f69e34c7ad9f15cd2cfafa9 100644 --- a/gcc/opts.cc +++ b/gcc/opts.cc @@ -1329,8 +1329,7 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set, /* Note -fvar-tracking is enabled automatically with OPT_LEVELS_1_PLUS and so we need to drop it if we are called from optimize attribute. */ - if (debug_info_level == DINFO_LEVEL_NONE - && !opts_set->x_flag_var_tracking) + if (debug_info_level < DINFO_LEVEL_NORMAL) flag_var_tracking = false; /* One could use EnabledBy, but it would lead to a circular dependency. */ diff --git a/gcc/testsuite/gcc.dg/pr105461.c b/gcc/testsuite/gcc.dg/pr105461.c new file mode 100644 index 0000000000000000000000000000000000000000..1e6743ccac27d8311d389f13fe3fb963d988cad2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr105461.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fassociative-math -fsignaling-nans -fvar-tracking -w" } */ + +int +bar (float *x, int y) +{ + *x = y; + + return *x; +} + +__attribute__ ((optimize ("O2"))) void +foo (float *x, int y) +{ + int a = bar (x, y); +}