File Wunprototyped-calls.diff of Package cross-aarch64-gcc48-icecream-backend

Index: gcc/c-family/c.opt
===================================================================
--- gcc/c-family/c.opt.orig	2013-03-18 09:43:30.187894777 +0100
+++ gcc/c-family/c.opt	2014-03-04 10:11:11.466977906 +0100
@@ -757,6 +757,10 @@ Wunused-local-typedefs
 C ObjC C++ ObjC++ Var(warn_unused_local_typedefs) Warning EnabledBy(Wunused)
 Warn when typedefs locally defined in a function are not used
 
+Wunprototyped-calls
+C Var(warn_unprototyped_calls) Warning LangEnabledBy(C,Wall)
+Warn about calls to unprototyped functions with at least one argument
+
 Wunused-macros
 C ObjC C++ ObjC++ Var(cpp_warn_unused_macros) Warning
 Warn about macros defined in the main file that are not used
Index: gcc/c/c-typeck.c
===================================================================
--- gcc/c/c-typeck.c.orig	2014-02-03 10:38:52.670371071 +0100
+++ gcc/c/c-typeck.c	2014-03-04 10:09:29.501984926 +0100
@@ -2833,6 +2833,19 @@ build_function_call_vec (location_t loc,
       && !check_builtin_function_arguments (fundecl, nargs, argarray))
     return error_mark_node;
 
+  /* If we cannot check function arguments because a prototype is
+     missing for the callee, warn here.  */
+  if (warn_unprototyped_calls
+      && nargs > 0 && !TYPE_ARG_TYPES (fntype)
+      && fundecl && !DECL_BUILT_IN (fundecl) && !C_DECL_IMPLICIT (fundecl)
+      && !DECL_ARGUMENTS (fundecl))
+    {
+      if (warning (OPT_Wunprototyped_calls,
+		   "call to function %qD without a real prototype", fundecl))
+	inform (DECL_SOURCE_LOCATION (fundecl), "%qD was declared here",
+		fundecl);
+    }
+
   /* Check that the arguments to the function are valid.  */
   check_function_arguments (fntype, nargs, argarray);
 
Index: gcc/testsuite/gcc.dg/cleanup-1.c
===================================================================
--- gcc/testsuite/gcc.dg/cleanup-1.c.orig	2013-03-18 09:45:44.668349955 +0100
+++ gcc/testsuite/gcc.dg/cleanup-1.c	2014-03-04 10:09:29.501984926 +0100
@@ -6,7 +6,7 @@
 #define C(x)	__attribute__((cleanup(x)))
 
 static int f1(void *x U) { return 0; }
-static void f2() { }
+static void f2() { } /* { dg-message "declared here" "" } */
 static void f3(void) { } /* { dg-message "note: declared here" } */
 static void f4(void *x U) { }
 static void f5(int *x U) { }
@@ -18,7 +18,7 @@ static void f9(int x U) { } /* { dg-mess
 void test(void)
 {
   int o1 C(f1);
-  int o2 C(f2);
+  int o2 C(f2);		/* { dg-warning "without a real prototype" } */
   int o3 C(f3);		/* { dg-error "too many arguments" } */
   int o4 C(f4);
   int o5 C(f5);
openSUSE Build Service is sponsored by