dwarf2read: Silence -Wenum-compare-switch warning
authorSimon Marchi <simon.marchi@ericsson.com>
Sun, 31 Dec 2017 02:24:29 +0000 (21:24 -0500)
committerSimon Marchi <simon.marchi@ericsson.com>
Sun, 31 Dec 2017 02:24:42 +0000 (21:24 -0500)
Compiling with Clang 6 gives:

/home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:24385:14: error: comparison of two values with different enumeration types in switch statement ('enum dwarf_macro_record_type' and 'dwarf_macinfo_record_type') [-Werror,-Wenum-compare-switch]
        case DW_MACINFO_vendor_ext:
             ^~~~~~~~~~~~~~~~~~~~~
/home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:24561:7: error: comparison of two values with different enumeration types in switch statement ('enum dwarf_macro_record_type' and 'dwarf_macinfo_record_type') [-Werror,-Wenum-compare-switch]
        case DW_MACINFO_vendor_ext:
             ^~~~~~~~~~~~~~~~~~~~~

This code uses the two enum types on purpose, because it handles both
.debug_macro and .debug_macinfo sections.  Add some pragmas to disable
the warning in these specific cases.

gdb/ChangeLog:

* dwarf2read.c (dwarf_decode_macro_bytes): Ignore
-Wenum-compare-switch warning.
(dwarf_decode_macros): Likewise.

gdb/ChangeLog
gdb/dwarf2read.c

index 54b704134e4f1405b9595fcea1b99a5927cad1b4..7689e0e1ab48594fdf14610dacb95869704b1b60 100644 (file)
@@ -1,3 +1,9 @@
+2017-12-30  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * dwarf2read.c (dwarf_decode_macro_bytes): Ignore
+       -Wenum-compare-switch warning.
+       (dwarf_decode_macros): Likewise.
+
 2017-12-30  Tom Tromey  <tom@tromey.com>
            Simon Marchi  <simon.marchi@ericsson.com>
 
index 85e33f0f9dd86db0c5e998772058f1f73a0da1b2..fcd5e995366235cf31a6e3cb6888b339da00fb7c 100644 (file)
@@ -24179,6 +24179,8 @@ dwarf_decode_macro_bytes (bfd *abfd,
 
       /* Note that we rely on the fact that the corresponding GNU and
         DWARF constants are the same.  */
+      DIAGNOSTIC_PUSH
+      DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES
       switch (macinfo_type)
        {
          /* A zero macinfo type indicates the end of the macro
@@ -24403,6 +24405,7 @@ dwarf_decode_macro_bytes (bfd *abfd,
            return;
          break;
         }
+      DIAGNOSTIC_POP
     } while (macinfo_type != 0);
 }
 
@@ -24495,6 +24498,8 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
 
       /* Note that we rely on the fact that the corresponding GNU and
         DWARF constants are the same.  */
+      DIAGNOSTIC_PUSH
+      DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES
       switch (macinfo_type)
         {
           /* A zero macinfo type indicates the end of the macro
@@ -24575,6 +24580,7 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
            return;
          break;
        }
+      DIAGNOSTIC_POP
     } while (macinfo_type != 0 && current_file == NULL);
 
   /* Second pass: Process all entries.
This page took 0.051914 seconds and 4 git commands to generate.