Home | History | Annotate | Line # | Download | only in lint1
msg_351.c revision 1.4
      1 /*	$NetBSD: msg_351.c,v 1.4 2023/04/25 19:00:57 rillig Exp $	*/
      2 # 3 "msg_351.c"
      3 
      4 // Test for message 351: missing%s header declaration for '%s' [351]
      5 
      6 /*
      7  * Warn about variable definitions or function definitions that are visible
      8  * outside the current translation unit but do not have a previous
      9  * declaration in a header file.
     10  *
     11  * All symbols that are used across translation units should be declared in a
     12  * header file, to ensure consistent types.
     13  *
     14  * Since the storage class 'extern' is redundant for functions but not for
     15  * objects, omit it for functions.
     16  *
     17  * https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmissing-declarations
     18  */
     19 
     20 /* expect+1: warning: missing header declaration for 'implicitly_extern_function' [351] */
     21 void implicitly_extern_function(void);
     22 /* expect+1: warning: missing header declaration for 'explicitly_extern_function' [351] */
     23 extern void explicitly_extern_function(void);
     24 
     25 /* expect+1: warning: missing 'extern' header declaration for 'definition' [351] */
     26 int definition;
     27 /* expect+1: warning: missing 'extern' header declaration for 'reference' [351] */
     28 extern int reference;
     29 /* expect+1: warning: static variable 'file_scoped_definition' unused [226] */
     30 static int file_scoped_definition;
     31 
     32 
     33 # 18 "header.h" 1 3 4
     34 static int static_def;
     35 int external_def;
     36 extern int external_ref;
     37 
     38 static int static_func_def(void);
     39 int extern_func_decl(void);
     40 extern int extern_func_decl_verbose(void);
     41 
     42 # 29 "msg_351.c" 2
     43 /* expect+1: warning: static variable 'static_def' unused [226] */
     44 static int static_def;
     45 int external_def;
     46 extern int external_ref;
     47 
     48 /* expect+1: warning: static function 'static_func_def' declared but not defined [290] */
     49 static int static_func_def(void);
     50 int extern_func_decl(void);
     51 extern int extern_func_decl_verbose(void);
     52 
     53 /* expect+1: warning: missing 'extern' header declaration for 'dbl_ptr' [351] */
     54 double *dbl_ptr = &(double) { 0.0 };
     55