This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] adding missing LTO to some warning options (PR 78606)


On 05/01/2017 08:05 PM, Martin Sebor wrote:
On 04/30/2017 02:02 PM, Tom de Vries wrote:
On 01/10/2017 11:16 PM, Martin Sebor wrote:
+  __builtin_sprintf (d, "%32s", "x");   /* { dg-warning "directive
writing 32 bytes into a region of size 12" "-Wformat-length" { xfail
*-*-* } } */

This xpasses for me on an older system:
...
XPASS: gcc.dg/pr78768.c -Wformat-overflow (test for warnings, line 11)
...

The mechanism is as follows:
- the system doesn't have linker plugin support, and sets
  HAVE_LTO_PLUGIN to 0
- consequently, opts.c:finish_options() sets x_flag_fat_lto_objects to 1
  in cc1
- cgraphunit.c:symbol_table::compile() does not return
  here:
  ...
     /* Do nothing else if any IPA pass found errors or if we are just
        streaming LTO.  */
     if (seen_error ()
        || (!in_lto_p && flag_lto && !flag_fat_lto_objects))
      {
        timevar_pop (TV_CGRAPHOPT);
        return;
      }
  ...
  and ends up calling expand_all_functions, which calls
  pass_sprintf_length
- the warning is generated by cc1

Maybe the test needs:
...
/* { dg-require-linker-plugin "" } */
...
?

That seems possible.  IIUC, without linker plugin support the
pass will run when the ordinary object file is created during
the first stage of compilation.  I don't have a system to confirm
it on but if pr78768.c xfails when you add the directive I'd say
go ahead and commit the fix as obvious.

Done.

Thanks,
- Tom
Require linker plugin for pr78768.c

The test-case has an xfail-ed line.  For linkers without plugin support, that
line happens to xpass.  Require linker with plugin support, such that the line
is no longer xpass-ing, but unsupported.

2017-05-01  Tom de Vries  <tom@codesourcery.com>

	* gcc.dg/pr78768.c: Require linker plugin.

---
 gcc/testsuite/ChangeLog        | 4 ++++
 gcc/testsuite/gcc.dg/pr78768.c | 1 +
 2 files changed, 5 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/pr78768.c b/gcc/testsuite/gcc.dg/pr78768.c
index 68d717a..b6cda47 100644
--- a/gcc/testsuite/gcc.dg/pr78768.c
+++ b/gcc/testsuite/gcc.dg/pr78768.c
@@ -2,6 +2,7 @@
    by -flto
   { dg-do link }
   { dg-require-effective-target lto }
+  { dg-require-linker-plugin "" }
   { dg-options "-O2 -Walloca-larger-than=10 -Wformat -Wformat-overflow -flto" } */
 
 int main (void)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]