瀏覽代碼

Userland: Locally suppress -Wc99-designator and re-enable globally

There's only two places where we're using the C99 feature of array
designated initalizers. This feature seemingly wasn't included with
C++20 designated initalizers for classes and structs. The only two
places we were using this feature are suitably old and isolated that
it makes sense to just suppress the warning at the usage sites while
discouraging future array designated intializers in new code.
Andrew Kaster 3 年之前
父節點
當前提交
a103a85ae6
共有 3 個文件被更改,包括 19 次插入1 次删除
  1. 0 1
      CMakeLists.txt
  2. 9 0
      Userland/Applications/KeyboardMapper/KeyPositions.h
  3. 10 0
      Userland/Libraries/LibC/sys/ttydefaults.h

+ 0 - 1
CMakeLists.txt

@@ -197,7 +197,6 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
 elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
 elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
     add_compile_options(-Wno-user-defined-literals)
     add_compile_options(-Wno-user-defined-literals)
     add_compile_options(-Wno-atomic-alignment)
     add_compile_options(-Wno-atomic-alignment)
-    add_compile_options(-Wno-c99-designator)
     add_compile_options(-Wno-implicit-const-int-float-conversion)
     add_compile_options(-Wno-implicit-const-int-float-conversion)
     add_compile_options(-Wno-null-pointer-subtraction)
     add_compile_options(-Wno-null-pointer-subtraction)
     add_compile_options(-Wno-tautological-constant-out-of-range-compare)
     add_compile_options(-Wno-tautological-constant-out-of-range-compare)

+ 9 - 0
Userland/Applications/KeyboardMapper/KeyPositions.h

@@ -21,6 +21,11 @@ struct KeyPosition {
 
 
 #define KEY_COUNT 63
 #define KEY_COUNT 63
 
 
+#ifdef __clang__
+#    pragma clang diagnostic push
+#    pragma clang diagnostic ignored "-Wc99-designator"
+#endif
+
 struct KeyPosition keys[KEY_COUNT] = {
 struct KeyPosition keys[KEY_COUNT] = {
     // clang-format off
     // clang-format off
     [ 0] = {     0,   0,  0,   0,   0, false,  0, ""},
     [ 0] = {     0,   0,  0,   0,   0, false,  0, ""},
@@ -93,3 +98,7 @@ struct KeyPosition keys[KEY_COUNT] = {
     [62] = {0xE01D, 689, 208,  74,  50, false,  0, "right ctrl"}
     [62] = {0xE01D, 689, 208,  74,  50, false,  0, "right ctrl"}
     // clang-format on
     // clang-format on
 };
 };
+
+#ifdef __clang__
+#    pragma clang diagnostic pop
+#endif

+ 10 - 0
Userland/Libraries/LibC/sys/ttydefaults.h

@@ -46,6 +46,11 @@
 #    endif
 #    endif
 #    include <sys/cdefs.h>
 #    include <sys/cdefs.h>
 
 
+#    ifdef __clang__
+#        pragma clang diagnostic push
+#        pragma clang diagnostic ignored "-Wc99-designator"
+#    endif
+
 __BEGIN_DECLS
 __BEGIN_DECLS
 static const cc_t ttydefchars[NCCS] = {
 static const cc_t ttydefchars[NCCS] = {
     [VINTR] = CINTR,
     [VINTR] = CINTR,
@@ -66,5 +71,10 @@ static const cc_t ttydefchars[NCCS] = {
     [VLNEXT] = CLNEXT,
     [VLNEXT] = CLNEXT,
     [VEOL2] = CEOL2
     [VEOL2] = CEOL2
 };
 };
+
+#    ifdef __clang__
+#        pragma clang diagnostic pop
+#    endif
+
 __END_DECLS
 __END_DECLS
 #endif
 #endif