Home | History | Annotate | Line # | Download | only in lint1
msg_155.c revision 1.10
      1 /*	$NetBSD: msg_155.c,v 1.10 2022/04/01 22:28:21 rillig Exp $	*/
      2 # 3 "msg_155.c"
      3 
      4 // Test for message: passing '%s' to incompatible '%s', arg #%d [155]
      5 
      6 
      7 void c99_6_7_6_example_a(int);
      8 void c99_6_7_6_example_b(int *);
      9 void c99_6_7_6_example_c(int *[3]);
     10 void c99_6_7_6_example_d(int (*)[3]);
     11 void c99_6_7_6_example_e(int (*)[*]);
     12 /* Wrong type before decl.c 1.256 from 2022-04-01. */
     13 void c99_6_7_6_example_f(int *());
     14 void c99_6_7_6_example_g(int (*)(void));
     15 void c99_6_7_6_example_h(int (*const[])(unsigned int, ...));
     16 
     17 struct incompatible {
     18 	int member;
     19 };
     20 
     21 void
     22 provoke_error_messages(struct incompatible arg)
     23 {
     24 	/* expect+1: 'int' */
     25 	c99_6_7_6_example_a(arg);
     26 
     27 	/* expect+1: 'pointer to int' */
     28 	c99_6_7_6_example_b(arg);
     29 
     30 	/* C99 says 'array[3] of pointer to int', which is close enough. */
     31 	/* expect+1: 'pointer to pointer to int' */
     32 	c99_6_7_6_example_c(arg);
     33 
     34 	/* expect+1: 'pointer to array[3] of int' */
     35 	c99_6_7_6_example_d(arg);
     36 
     37 	/* expect+1: 'pointer to array[unknown_size] of int' */
     38 	c99_6_7_6_example_e(arg);
     39 
     40 	/* Wrong type before decl.c 1.256 from 2022-04-01. */
     41 	/* expect+1: 'pointer to function() returning pointer to int' */
     42 	c99_6_7_6_example_f(arg);
     43 
     44 	/* expect+1: 'pointer to function(void) returning int' */
     45 	c99_6_7_6_example_g(arg);
     46 
     47 	/* expect+1: 'pointer to const pointer to function(unsigned int, ...) returning int' */
     48 	c99_6_7_6_example_h(arg);
     49 }
     50 
     51 extern void sink(struct incompatible);
     52 
     53 /*
     54  * The function type_name has a special case for an enum type that has been
     55  * implicitly converted to an int.  Such a type is still output as the enum
     56  * type.
     57  *
     58  * XXX: The expressions 'day + 0' and '0 + day' should result in the same
     59  *  type.
     60  */
     61 void
     62 type_name_of_enum(void)
     63 {
     64 	enum Day {
     65 		MONDAY
     66 	} day = MONDAY;
     67 
     68 	/* expect+1: passing 'enum Day' */
     69 	sink(day);
     70 
     71 	/* expect+1: passing 'enum Day' */
     72 	sink(day + 0);
     73 
     74 	/* expect+1: passing 'int' */
     75 	sink(0 + day);
     76 
     77 	/* expect+1: passing 'int' */
     78 	sink(0);
     79 }
     80