- implemented -Wold-style-definition
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Sat, 13 Sep 2008 00:03:47 +0000 (00:03 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Sat, 13 Sep 2008 00:03:47 +0000 (00:03 +0000)
[r21920]

parser.c
warning.c
warning.h

index 204032d..9ff8b96 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -5282,6 +5282,10 @@ static void parse_external_declaration(void)
                warningf(HERE, "traditional C rejects ISO C style function definition of function '%Y'",
                        ndeclaration->symbol);
        }
+       if (warning.old_style_definition && type->function.unspecified_parameters) {
+               warningf(HERE, "old-style function definition '%Y'",
+                       ndeclaration->symbol);
+       }
 
        /* ยง 6.7.5.3 (14) a function definition with () means no
         * parameters (and not unspecified parameters) */
index 5684886..e695a89 100644 (file)
--- a/warning.c
+++ b/warning.c
@@ -46,6 +46,7 @@ warning_t warning = {
        .multichar                     = true,
        .nested_externs                = false,
        .nonnull                       = true,
+       .old_style_definition          = false,
        .pointer_arith                 = true,
        .redundant_decls               = true,
        .return_type                   = true,
@@ -151,6 +152,7 @@ void set_warning_opt(const char *const opt)
        OPT("multichar",                     multichar);
        OPT("nested-externs",                nested_externs);
        OPT("nonnull",                       nonnull);
+       OPT("old-style-definition",          old_style_definition);
        OPT("pointer_arith",                 pointer_arith);
        OPT("redundant-decls",               redundant_decls);
        OPT("return-type",                   return_type);
index 48352e5..5ce30b9 100644 (file)
--- a/warning.h
+++ b/warning.h
@@ -70,8 +70,8 @@ typedef struct warning_t {
        bool multichar:1;                     /**< Warn if a multicharacter constant ('FOOF') is used. */
        bool nested_externs:1;                /**< Warn if an 'extern' declaration is encountered within a function. */
        bool nonnull:1;                       /**< Warn about passing a null pointer for arguments marked nonnull. */
-#if 0 // TODO
        bool old_style_definition:1;          /**< Warn if an old-style function definition is used. */
+#if 0 // TODO
        bool packed:1;                        /**< Warn if a structure is given the packed attribute, but the packed attribute has no effect on the layout or size of the structure */
        bool padded:1;                        /**< Warn if padding is included in a structure, either to align an element of the structure or to align the whole structure */
        bool parentheses:1;                   /**< Warn if parentheses are omitted in certain contexts (assignment where truth value is expected, if-else-braces) */