@@ -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;
@@ -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
@@ -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,
@@ -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" } */
+}
@@ -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" } */
+}
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-pedantic-errors -Wno-implicit-int" } */
+
+static l;
+
+foo (a)
+{
+ auto p;
+ typedef bar;
+}
@@ -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" } */
+}