]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c-opts.c (c_common_post_options): Set warn_implicit_int.
authorMarek Polacek <polacek@redhat.com>
Fri, 17 Oct 2014 18:37:25 +0000 (18:37 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 17 Oct 2014 18:37:25 +0000 (18:37 +0000)
c-family/
* c-opts.c (c_common_post_options): Set warn_implicit_int.
* c.opt (Wimplicit-int): Initialize to -1.
c/
* c-decl.c (grokdeclarator): Use OPT_Wimplicit_int unconditionally.
(start_function): Use OPT_Wimplicit_int instead of 0.
(store_parm_decls_oldstyle): Likewise.
testsuite/
* gcc.dg/Wimplicit-int-1.c: New test.
* gcc.dg/Wimplicit-int-2.c: New test.
* gcc.dg/Wimplicit-int-3.c: New test.
* gcc.dg/Wimplicit-int-4.c: New test.

From-SVN: r216412

gcc/c-family/ChangeLog
gcc/c-family/c-opts.c
gcc/c-family/c.opt
gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wimplicit-int-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wimplicit-int-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wimplicit-int-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wimplicit-int-4.c [new file with mode: 0644]

index 0a47f434d007ed1128f3b688232ab8f63ffd24a1..6d43fb77328edf1715ea1c2b322de6f9ec05a25c 100644 (file)
@@ -1,3 +1,8 @@
+2014-10-17  Marek Polacek  <polacek@redhat.com>
+
+       * c-opts.c (c_common_post_options): Set warn_implicit_int.
+       * c.opt (Wimplicit-int): Initialize to -1.
+
 2014-10-16  Andrew MacLeod  <amacleod@redhat.com>
 
        * c-pragma.c: Adjust include files.
index eb078e3f5cdf76adf4489d7dee579d73f241150a..448eb3e8b747a1d0391e754e2b93e73323aed8c6 100644 (file)
@@ -864,6 +864,10 @@ c_common_post_options (const char **pfilename)
   if (warn_implicit_function_declaration == -1)
     warn_implicit_function_declaration = flag_isoc99;
 
+  /* -Wimplicit-int is enabled by default for C99.  */
+  if (warn_implicit_int == -1)
+    warn_implicit_int = flag_isoc99;
+
   /* Declone C++ 'structors if -Os.  */
   if (flag_declone_ctor_dtor == -1)
     flag_declone_ctor_dtor = optimize_size;
index 72ac2eddd89707e031cfb95496126c894a00927b..4f96cf83d8454b708076ce2734cf89d9a6789818 100644 (file)
@@ -488,7 +488,7 @@ C ObjC Var(warn_implicit_function_declaration) Init(-1) Warning LangEnabledBy(C
 Warn about implicit function declarations
 
 Wimplicit-int
-C ObjC Var(warn_implicit_int) Warning LangEnabledBy(C ObjC,Wimplicit)
+C ObjC Var(warn_implicit_int) Init(-1) Warning LangEnabledBy(C ObjC,Wimplicit)
 Warn when a declaration does not specify a type
 
 Wimport
index ac28472bbad2d13d7f1071c6f89589f2981e1bd7..d6a58a86e60aac96615ee2e0a49f9a2706af2fe2 100644 (file)
@@ -1,3 +1,9 @@
+2014-10-17  Marek Polacek  <polacek@redhat.com>
+
+       * c-decl.c (grokdeclarator): Use OPT_Wimplicit_int unconditionally.
+       (start_function): Use OPT_Wimplicit_int instead of 0.
+       (store_parm_decls_oldstyle): Likewise.
+
 2014-10-17  Alan Modra  <amodra@gmail.com>
 
        PR middle-end/61848
index 839c67bf7e9147ac8d8397055197b2c56344b13a..b18da483feaee69909d7ccf17e4dec89d929beae 100644 (file)
@@ -5330,11 +5330,11 @@ grokdeclarator (const struct c_declarator *declarator,
       else
        {
          if (name)
-           warn_defaults_to (loc, flag_isoc99 ? 0 : OPT_Wimplicit_int,
+           warn_defaults_to (loc, OPT_Wimplicit_int,
                              "type defaults to %<int%> in declaration "
                              "of %qE", name);
          else
-           warn_defaults_to (loc, flag_isoc99 ? 0 : OPT_Wimplicit_int,
+           warn_defaults_to (loc, OPT_Wimplicit_int,
                              "type defaults to %<int%> in type name");
        }
     }
@@ -8120,7 +8120,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
     }
 
   if (warn_about_return_type)
-    warn_defaults_to (loc, flag_isoc99 ? 0
+    warn_defaults_to (loc, flag_isoc99 ? OPT_Wimplicit_int
                           : (warn_return_type ? OPT_Wreturn_type
                              : OPT_Wimplicit_int),
                      "return type defaults to %<int%>");
@@ -8429,7 +8429,8 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
 
          if (flag_isoc99)
            pedwarn (DECL_SOURCE_LOCATION (decl),
-                    0, "type of %qD defaults to %<int%>", decl);
+                    OPT_Wimplicit_int, "type of %qD defaults to %<int%>",
+                    decl);
          else
            warning_at (DECL_SOURCE_LOCATION (decl),
                        OPT_Wmissing_parameter_type,
index b355cb0c6b45064834d30f43a6837ab6e5b049b8..a73dad957c653ebf6e370a30dda99711367dcaf4 100644 (file)
@@ -1,3 +1,10 @@
+2014-10-17  Marek Polacek  <polacek@redhat.com>
+
+       * gcc.dg/Wimplicit-int-1.c: New test.
+       * gcc.dg/Wimplicit-int-2.c: New test.
+       * gcc.dg/Wimplicit-int-3.c: New test.
+       * gcc.dg/Wimplicit-int-4.c: New test.
+
 2014-10-17  Andrew MacLeod  <amacleod@redhat.com>
 
        * g++.dg/plugin/pragma_plugin.c: Revert flattening to test plugin header
diff --git a/gcc/testsuite/gcc.dg/Wimplicit-int-1.c b/gcc/testsuite/gcc.dg/Wimplicit-int-1.c
new file mode 100644 (file)
index 0000000..0c89caf
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+static l; /* { dg-warning "type defaults to" } */
+
+foo (a) /* { dg-warning "return type defaults to" } */
+/* { dg-warning "type of .a. defaults to .int." "type" { target *-*-* } 6 } */
+{
+  auto p; /* { dg-warning "type defaults to" } */
+  typedef bar; /* { dg-warning "type defaults to" } */
+}
diff --git a/gcc/testsuite/gcc.dg/Wimplicit-int-2.c b/gcc/testsuite/gcc.dg/Wimplicit-int-2.c
new file mode 100644 (file)
index 0000000..158b61c
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-pedantic-errors" } */
+
+static l; /* { dg-error "type defaults to" } */
+
+foo (a) /* { dg-error "return type defaults to" } */
+/* { dg-error "type of .a. defaults to .int." "type" { target *-*-* } 6 } */
+{
+  auto p; /* { dg-error "type defaults to" } */
+  typedef bar; /* { dg-error "type defaults to" } */
+}
diff --git a/gcc/testsuite/gcc.dg/Wimplicit-int-3.c b/gcc/testsuite/gcc.dg/Wimplicit-int-3.c
new file mode 100644 (file)
index 0000000..654ce73
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-pedantic-errors -Wno-implicit-int" } */
+
+static l;
+
+foo (a)
+{
+  auto p;
+  typedef bar;
+}
diff --git a/gcc/testsuite/gcc.dg/Wimplicit-int-4.c b/gcc/testsuite/gcc.dg/Wimplicit-int-4.c
new file mode 100644 (file)
index 0000000..b252835
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-Wno-implicit -Wimplicit-int" } */
+
+static l; /* { dg-warning "type defaults to" } */
+
+foo (a) /* { dg-warning "return type defaults to" } */
+/* { dg-warning "type of .a. defaults to .int." "type" { target *-*-* } 6 } */
+{
+  auto p; /* { dg-warning "type defaults to" } */
+  typedef bar; /* { dg-warning "type defaults to" } */
+}