Home | History | Annotate | Line # | Download | only in lint1
msg_139.c revision 1.3
      1 /*	$NetBSD: msg_139.c,v 1.3 2021/03/16 23:18:49 rillig Exp $	*/
      2 # 3 "msg_139.c"
      3 
      4 // Test for message: division by 0 [139]
      5 
      6 void sink_int(int);
      7 void sink_double(double);
      8 
      9 void
     10 example(int i)
     11 {
     12 	enum {
     13 		zero = 0
     14 	};
     15 
     16 	sink_int(i / 0);	/* only triggers in constant expressions */
     17 	sink_int(i / zero);	/* only triggers in constant expressions */
     18 	sink_double(i / 0.0);
     19 
     20 	sink_int(13 / 0);	/* expect: 139 */
     21 	sink_int(13 / zero);	/* expect: 139 */
     22 	sink_double(13 / 0.0);	/* expect: 139 *//* XXX: Clang doesn't warn */
     23 	sink_double(13 / -0.0);	/* expect: 139 *//* XXX: Clang doesn't warn */
     24 }
     25