msg_347.c revision 1.6
1/* $NetBSD: msg_347.c,v 1.6 2023/08/02 18:51:25 rillig Exp $ */ 2# 3 "msg_347.c" 3 4// Test for message: redeclaration of '%s' with type '%s', expected '%s' [347] 5 6/* lint1-extra-flags: -r -X 351 */ 7 8/* 9 * Message 27 already covers redeclarations, but it doesn't include enough 10 * details to make any sense of it. 11 */ 12 13/* 14 * As of 2021-09-12, lint complains about mismatched types. 15 * GCC and Clang accept this. 16 * 17 * Above: 18 * function(pointer to void, int) returning void 19 * 20 * Below: function( 21 * pointer to void, 22 * pointer to function(pointer to void, int) returning pointer to double 23 * ) returning void 24 */ 25/* FIXME: the type of the second parameter is not 'int' */ 26/* expect+1: previous declaration of 'function_parameter' [260] */ 27void function_parameter(void *, double *(void *, int)); 28/* expect+1: error: redeclaration of 'function_parameter' with type 'function(pointer to void, pointer to function(pointer to void, int) returning pointer to double) returning void', expected 'function(pointer to void, int) returning void' [347] */ 29void function_parameter(void *fs, double *func(void *, int)); 30 31 32/* expect+1: warning: struct 'last_arg' never defined [233] */ 33struct last_arg; 34/* 35 * FIXME: The following error is completely wrong. 36 * There is no parameter that has 'struct last_arg', there are only pointers 37 * to it. 38 */ 39/* expect+2: error: '<unnamed>' has incomplete type 'incomplete struct last_arg' [31] */ 40/* expect+1: previous declaration of 'last_arg_struct' [260] */ 41void last_arg_struct(double, double *(struct last_arg *)); 42/* expect+1: error: redeclaration of 'last_arg_struct' with type 'function(double, pointer to function(pointer to incomplete struct last_arg) returning pointer to double) returning void', expected 'function(double, incomplete struct last_arg) returning void' [347] */ 43void last_arg_struct(double d, double *fn(struct last_arg *)); 44 45 46struct last_param { 47 int member; 48}; 49 50/* expect+1: previous declaration of 'last_param' [260] */ 51void last_param(double, double *(struct last_param)); 52 53/* 54 * FIXME: The type of last_param is completely wrong. The second parameter 55 * must be a function, not a struct. 56 */ 57/* expect+1: error: cannot initialize 'double' from 'pointer to function(double, struct last_param) returning void' [185] */ 58double reveal_type_of_last_param_abstract = last_param; 59 60/* expect+1: error: redeclaration of 'last_param' with type 'function(double, pointer to function(struct last_param) returning pointer to double) returning void', expected 'function(double, struct last_param) returning void' [347] */ 61void last_param(double d, double *fn(struct last_param)); 62 63/* expect+1: error: cannot initialize 'double' from 'pointer to function(double, pointer to function(struct last_param) returning pointer to double) returning void' [185] */ 64double reveal_type_of_last_param_named = last_param; 65