diff mbox series

[committed] Fix dwarf-float.c test in testsuite

Message ID 0271af09-66ec-6312-7ba0-f657068c0db9@redhat.com
State New
Headers show
Series [committed] Fix dwarf-float.c test in testsuite | expand

Commit Message

Jeff Law Jan. 19, 2021, 3:37 p.m. UTC
The change to dwarf5 exposed multiple problems with
gcc.dg/debug/dwarf2/dwarf-float.c


AFAICT the test is supposed to check the dwarf2 records for float,
double and long double.  In particular it checks the sizes of those
types and ensures they are 4, 8 and 16 bytes long respectively.

Of course we have targets where that is not true.  Just to pick one,
visium-elf where a long double is just 8 bytes long.  But the test is
passing, why?

/* { dg-final { scan-assembler "0x10.*DW_AT_byte_size" } } */

The ".*" should be ringing alarm bells.  .* can match multiple lines. 
And I'm pretty sure that's precisely what's happening.  We're matching
0x10 from one line and DW_AT_byte_size from another later line.  So the
first thing this patch does is fix all the patterns to use [^\\r\\n]* to
ensure we don't match from multiple lines.  I went back and then
verified that the long double test fails with the old compiler on
visium-elf.  Good.


Next, the test makes assumptions about the sizes of float, double and
long double.  We have good target selectors for the size of double and
long double.  So we add the appropriate target selectors on those lines.

Finally with dwarf-5 by default the DW_AT_encoding test fails because of
changes in the default debug format, so we force the test to run with
dwarf-4.

With those three changes dwarf-float.c should be working again.  I've
tested it on a dozen or so targets that were previously failing in my
tester and x86-64 by hand which passes before/after this change.

Installing on the trunk,
Jeff
commit 8227106f5668c8fb1f0c5d2026e44cc0b84ee991
Author: Jeff Law <law@redhat.com>
Date:   Tue Jan 19 08:35:55 2021 -0700

    [committed] Fix dwarf-float.c test in testsuite
    
    gcc/testsuite
            * gcc.dg/debug/dwarf2/dwarf-float.c: Force dwarf-4 generation
            and update expected output.
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-float.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-float.c
index f4883842b84..51f5977db93 100644
--- a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-float.c
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-float.c
@@ -1,11 +1,11 @@ 
 /* Verify the DWARF encoding of C99 floating point types.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O0 -gdwarf -dA" } */
-/* { dg-final { scan-assembler "0x4.*DW_AT_encoding" } } */
-/* { dg-final { scan-assembler "0x4.*DW_AT_byte_size" } } */
-/* { dg-final { scan-assembler "0x8.*DW_AT_byte_size" } } */
-/* { dg-final { scan-assembler "0x10.*DW_AT_byte_size" } } */
+/* { dg-options "-O0 -gdwarf-4 -dA" } */
+/* { dg-final { scan-assembler "0x4\[^\\r\\n]*DW_AT_encoding" } } */
+/* { dg-final { scan-assembler "0x4\[^\\r\\n]*DW_AT_byte_size" } } */
+/* { dg-final { scan-assembler "0x8\[^\\r\\n]*DW_AT_byte_size" { target double64 } } } */
+/* { dg-final { scan-assembler "0x10\[^\\r\\n]*DW_AT_byte_size" { target longdouble128 }} } */
 
 void foo ()
 {