LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File Wunprototyped-calls.diff of Package libffi46 (Project home:ftake:branches:devel:gcc)

Index: gcc/c-family/c.opt
===================================================================
*** gcc/c-family/c.opt.orig	2010-11-15 15:46:08.000000000 +0100
--- gcc/c-family/c.opt	2011-01-11 17:37:40.000000000 +0100
*************** Wunsuffixed-float-constants
*** 645,650 ****
--- 645,654 ----
  C ObjC Var(warn_unsuffixed_float_constants) Warning
  Warn about unsuffixed float constants
  
+ Wunprototyped-calls
+ C Var(warn_unprototyped_calls) Warning
+ Warn about calls to unprototyped functions with at least one argument
+ 
  Wunused-macros
  C ObjC C++ ObjC++ Warning
  Warn about macros defined in the main file that are not used
Index: gcc/testsuite/gcc.dg/cleanup-1.c
===================================================================
*** gcc/testsuite/gcc.dg/cleanup-1.c.orig	2010-02-23 12:43:21.000000000 +0100
--- gcc/testsuite/gcc.dg/cleanup-1.c	2011-01-11 17:37:40.000000000 +0100
***************
*** 6,12 ****
  #define C(x)	__attribute__((cleanup(x)))
  
  static int f1(void *x U) { return 0; }
! static void f2() { }
  static void f3(void) { } /* { dg-message "note: declared here" } */
  static void f4(void *x U) { }
  static void f5(int *x U) { }
--- 6,12 ----
  #define C(x)	__attribute__((cleanup(x)))
  
  static int f1(void *x U) { return 0; }
! 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) { }
*************** static void f9(int x U) { } /* { dg-mess
*** 18,24 ****
  void test(void)
  {
    int o1 C(f1);
!   int o2 C(f2);
    int o3 C(f3);		/* { dg-error "too many arguments" } */
    int o4 C(f4);
    int o5 C(f5);
--- 18,24 ----
  void test(void)
  {
    int o1 C(f1);
!   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);
Index: gcc/c-typeck.c
===================================================================
*** gcc/c-typeck.c.orig	2010-12-06 12:01:18.000000000 +0100
--- gcc/c-typeck.c	2011-01-11 17:37:58.000000000 +0100
*************** build_function_call_vec (location_t loc,
*** 2830,2835 ****
--- 2830,2848 ----
        && !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 (TYPE_ATTRIBUTES (fntype), nargs, argarray,
  			    TYPE_ARG_TYPES (fntype));
Index: gcc/c-family/c-opts.c
===================================================================
*** gcc/c-family/c-opts.c.orig	2010-12-06 12:00:44.000000000 +0100
--- gcc/c-family/c-opts.c	2011-01-11 17:37:40.000000000 +0100
*************** c_common_handle_option (size_t scode, co
*** 386,391 ****
--- 386,392 ----
  	     can turn it off only if it's not explicit.  */
  	  if (warn_main == -1)
  	    warn_main = (value ? 2 : 0);
+ 	  warn_unprototyped_calls = 1;
  
  	  /* In C, -Wall turns on -Wenum-compare, which we do here.
  	     In C++ it is on by default, which is done in