[cfe-dev] Next batch of -Wgnu flags

Peter N Lewis peter at stairways.com.au
Thu Aug 22 23:15:33 PDT 2013


I'm currently waiting for approval or feedback on adding the following GNU flags in the -Wgnu group:

gnu-binary-literal
gnu-imaginary-constant
gnu-line-zero-directive
gnu-token-pasting-comma
gnu-zero-variadic-macro-arguments

And then the next batch of names (which I've done already) is:

gnu-anonymous-struct
gnu-compound-literal-initializer
gnu-empty-struct
gnu-flexible-array-initializer
gnu-flexible-array-union-member
gnu-folding-initializer-constant
gnu-folding-integer-constant
gnu-only-flexible-array-member
gnu-redeclared-class-member
gnu-redeclaration-enum
gnu-struct-without-named-member
gnu-union-cast
gnu-variable-sized-type-not-at-end

Personally, I very much want to be able to use the style -Weverything -Wno-specific-things, which is why I'm doing this, so I'd not have strong opinions on what the flags are called, I've done my best to name them appropriately, but my goal is to ensure there is one flag for each feature so I don't have to enable more features than I have justified using.

If you're wondering about the kinds of things that generate the various warnings, I've included snippets of the test cases below that show the options.

Thanks for any feedback that might help speed up the process,
   Peter.

#if ALL || ZEROARGS
// expected-warning at +11 {{must specify at least one argument for '...' parameter of variadic macro}}
// expected-note at +6 {{macro 'efoo' defined here}}
#endif
#if ALL || TOKENPASTING
// expected-warning at +3 {{token pasting of ',' and __VA_ARGS__ is a GNU extension}}
#endif

#define efoo(format, args...) foo(format , ##args)

void foo( const char* c )
{
  efoo("6");
}


#if ALL || IMAGINARYCONST
// expected-warning at +3 {{imaginary constants are a GNU extension}}
#endif

float _Complex c = 1.if;


#if ALL || BINARYLITERAL
// expected-warning at +3 {{binary integer literals are a GNU extension}}
#endif

int b = 0b0101;


// This case is handled differently because lit has a bug whereby #line 0 is reported to be on line 4294967295
// http://llvm.org/bugs/show_bug.cgi?id=16952
#if ALL || LINE0
#line 0 // expected-warning {{#line directive with zero argument is a GNU extension}}
#else
#line 0
#endif



#if ALL || ANONYMOUSSTRUCT
// expected-warning at +5 {{anonymous structs are a GNU extension}}
#endif

struct as {
  int x;
  struct {
    int a;
    float b;
  };
};


#if ALL || REDECLAREDCLASSMEMBER
// expected-note at +6 {{previous declaration is here}}
// expected-warning at +6 {{class member cannot be redeclared}}
#endif

namespace rcm {
  class A {
    class X;
    class X;
    class X {};
  };
}


#if ALL || FLEXIBLEARRAYUNIONMEMBER
// expected-warning at +6 {{flexible array member 'c1' in a union is a GNU extension}}
#endif

struct faum {
   int l;
   union {
       int c1[];
   };
};


#if ALL || FOLDINGINITIALIZERCONSTANT
// expected-warning at +4 {{in-class initializer for static data member is not a constant expression; folding it to a constant is a GNU extension}}
#endif

struct fic {
  static const int B = int(0.75 * 1000 * 1000);
};



#if ALL || COMPOUNDLITERALINITIALIZER
// expected-warning at +4 {{initialization of an array of type 'int [5]' from a compound literal of type 'int [5]' is a GNU extension}}
#endif

typedef int int5[5];
int cli[5] = (int[]){1, 2, 3, 4, 5};



#if ALL || EMPTYSTRUCT
// expected-warning at +4 {{empty struct is a GNU extension}}
#endif

const struct {} es;


#if ALL || FLEXIBLEARRAYINITIALIZER
// expected-note at +6 {{initialized flexible array member 'y' is here}}
// expected-warning at +6 {{flexible array initialization is a GNU extension}}
#endif

struct fai {
  int x;
  int y[];
} fai = { 1, { 2, 3, 4 } };


#if ALL || FOLDINGINTEGERCONSTANT
// expected-warning at +4 {{expression is not an integer constant expression; folding it to a constant is a GNU extension}}
#endif

enum {
	fic = (int)(0.75 * 1000 * 1000)
};


#if ALL || ONLYFLEXIBLEARRAYMEMBER
// expected-warning at +5 {{flexible array member 'a' in otherwise empty struct is a GNU extension}}
#endif

struct ofam
{
   int a[];
};


#if ALL || REDECLARATIONENUM
// expected-note at +6 {{previous definition is here}}
// expected-warning at +5 {{redeclaration of already-defined enum 'RE' is a GNU extension}}
#endif

enum RE {
  Val1,
  Val2
};

enum RE;


#if ALL || STRUCTWITHOUTNAMEDMEMBER
// expected-warning at +3 {{struct without named members is a GNU extension}}
#endif

struct {int:5;} swnm;


#if ALL || UNIONCAST
// expected-warning at +4 {{cast to union type is a GNU extension}}
#endif

union uc { int i; unsigned : 3; };
union uc w = (union uc)2;


#if ALL || VARIABLESIZEDTYPENOTATEND
// expected-warning at +4 {{field 'hdr' with variable sized type 'struct vst' not at the end of a struct or class is a GNU extension}}
#endif

struct vst {
 short tag_type;
 char tag_data[];
};
struct vstnae {
  struct vst hdr;
  char data;
};


-- 
Keyboard Maestro 6.2 now out - control Mail, reveal a file, format AppleScripts 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