[cfe-dev] Explicit warning diagnostic flags for groups

Peter N Lewis peter at stairways.com.au
Mon Aug 12 22:30:15 PDT 2013


Hi,

I'm new to this group, so forgive me if this is the wrong place.

I use clang with Xcode and like to run with all warnings (-Weverything -Werror) and then disable whatever warnings/enable whatever features I feel I can justify.  Unfortunately, sometimes there are features like GNU's ?: expression extension, eliding middle term which do not have their own flags, so then the choice is either enable all the GNU extensions or do without the extension.

I've hit this in the past with clang, for things like vararg macros and such.  So I'd be interested in seeing this remedied.  I checked out the clang source and it appears that all that is needed to resolve this (for the eliding middle term case) is a simple patch like this:

Index: include/clang/Basic/DiagnosticGroups.td
===================================================================
--- include/clang/Basic/DiagnosticGroups.td	(revision 188139)
+++ include/clang/Basic/DiagnosticGroups.td	(working copy)
@@ -52,6 +52,7 @@
 def ConfigMacros : DiagGroup<"config-macros">;
 def : DiagGroup<"ctor-dtor-privacy">;
 def GNUDesignator : DiagGroup<"gnu-designator">;
+def GNUTernaryElidingExpression : DiagGroup<"gnu-ternary-eliding-expression">;
 
 def DeleteNonVirtualDtor : DiagGroup<"delete-non-virtual-dtor">;
 def AbstractFinalClass : DiagGroup<"abstract-final-class">;
@@ -524,7 +525,8 @@
 
 // A warning group for warnings about GCC extensions.
 def GNU : DiagGroup<"gnu", [GNUDesignator, VLAExtension,
-                            ZeroLengthArray, GNUStaticFloatInit]>;
+                            ZeroLengthArray, GNUStaticFloatInit,
+                            GNUTernaryElidingExpression]>;
 // A warning group for warnings about code that clang accepts but gcc doesn't.
 def GccCompat : DiagGroup<"gcc-compat">;
 
Index: include/clang/Basic/DiagnosticParseKinds.td
===================================================================
--- include/clang/Basic/DiagnosticParseKinds.td	(revision 188139)
+++ include/clang/Basic/DiagnosticParseKinds.td	(working copy)
@@ -127,7 +127,7 @@
 def ext_gnu_statement_expr : Extension<
   "use of GNU statement expression extension">, InGroup<GNU>;
 def ext_gnu_conditional_expr : Extension<
-  "use of GNU ?: expression extension, eliding middle term">, InGroup<GNU>;
+  "use of GNU ?: expression extension, eliding middle term">, InGroup<GNUTernaryElidingExpression>;
 def ext_gnu_empty_initializer : Extension<
   "use of GNU empty initializer extension">, InGroup<GNU>;
 def ext_gnu_array_range : Extension<"use of GNU array range extension">, 

But I'm not familiar with clang's code, and so there may be more, or there may be tests that need doing, or documentation, or whatever else that goes along with this sort of thing.

I'm happy to put some effort in to the grunge work of doing this if someone more familiar with clang can set me on the right path as to what else needs to be done and what process is needed for submitting the patches, and presuming this is something that will be accepted into clang, and thus eventually work its way into Xcode.

Any help on making this happen would be appreciated.

Thanks,
   Peter.

-- 
Keyboard Maestro 6.1 now out - set web checkboxes & radio buttons, exit from loops, and more.

Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
<http://www.stairways.com/>           <http://download.keyboardmaestro.com/>





More information about the cfe-dev mailing list