Home | History | Annotate | Line # | Download | only in lint1
msg_247.c revision 1.5
      1  1.5  rillig /*	$NetBSD: msg_247.c,v 1.5 2021/03/14 22:24:24 rillig Exp $	*/
      2  1.1  rillig # 3 "msg_247.c"
      3  1.1  rillig 
      4  1.3  rillig // Test for message: pointer cast from '%s' to '%s' may be troublesome [247]
      5  1.1  rillig 
      6  1.4  rillig /* lint1-extra-flags: -c */
      7  1.4  rillig 
      8  1.4  rillig /* example taken from Xlib.h */
      9  1.4  rillig typedef struct {
     10  1.4  rillig 	int id;
     11  1.4  rillig } *PDisplay;
     12  1.4  rillig 
     13  1.4  rillig struct Other {
     14  1.4  rillig 	int id;
     15  1.4  rillig };
     16  1.4  rillig 
     17  1.4  rillig void
     18  1.4  rillig example(struct Other *arg)
     19  1.4  rillig {
     20  1.5  rillig 	PDisplay display;
     21  1.5  rillig 
     22  1.5  rillig 	/*
     23  1.5  rillig 	 * XXX: The target type is reported as 'struct <unnamed>'.  In cases
     24  1.5  rillig 	 *  like these, it would be helpful to print at least the type name
     25  1.5  rillig 	 *  of the pointer.  This type name though is discarded immediately
     26  1.5  rillig 	 *  when the parser reduces 'T_TYPENAME clrtyp' to 'clrtyp_typespec'.
     27  1.5  rillig 	 *  After that, the target type of the cast is just an unnamed struct,
     28  1.5  rillig 	 *  with no hint at all that there is a typedef for a pointer to the
     29  1.5  rillig 	 *  struct.
     30  1.5  rillig 	 */
     31  1.5  rillig 	display = (PDisplay)arg;	/* expect: 247 */
     32  1.4  rillig }
     33