Module Name:    src
Committed By:   rillig
Date:           Tue Oct 29 20:44:22 UTC 2024

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_129.c
        src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: fix warning about null effect in GCC statement expressions


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/msg_129.c
cvs rdiff -u -r1.512 -r1.513 src/usr.bin/xlint/lint1/cgram.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_129.c
diff -u src/tests/usr.bin/xlint/lint1/msg_129.c:1.9 src/tests/usr.bin/xlint/lint1/msg_129.c:1.10
--- src/tests/usr.bin/xlint/lint1/msg_129.c:1.9	Tue Oct 29 20:39:52 2024
+++ src/tests/usr.bin/xlint/lint1/msg_129.c	Tue Oct 29 20:44:22 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_129.c,v 1.9 2024/10/29 20:39:52 rillig Exp $	*/
+/*	$NetBSD: msg_129.c,v 1.10 2024/10/29 20:44:22 rillig Exp $	*/
 # 3 "msg_129.c"
 
 // Test for message: expression has null effect [129]
@@ -101,8 +101,6 @@ return_statement_expression(int arg)
 {
 	({
 		int local = arg;
-		/* XXX: redundant warning, also occurs outside the braces. */
-		/* expect+1: warning: expression has null effect [129] */
 		local + 4;
 	/* expect+1: warning: expression has null effect [129] */
 	});
@@ -110,16 +108,18 @@ return_statement_expression(int arg)
 	if (arg == 1)
 		return ({
 			int local = arg;
-			/* FIXME: The expression _does_ have an effect. */
-			/* expect+1: warning: expression has null effect [129] */
+			// Before cgram.y 1.513 from 2024-10-29, lint wrongly
+			// warned that this expression would have a null effect.
 			local;
 		});
+
 	if (arg == 2)
 		return ({
 			int local = arg;
-			/* FIXME: The expression _does_ have an effect. */
-			/* expect+1: warning: expression has null effect [129] */
+			// Before cgram.y 1.513 from 2024-10-29, lint wrongly
+			// warned that this expression would have a null effect.
 			local + 4;
 		});
+
 	return 0;
 }

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.512 src/usr.bin/xlint/lint1/cgram.y:1.513
--- src/usr.bin/xlint/lint1/cgram.y:1.512	Fri Oct  4 11:38:03 2024
+++ src/usr.bin/xlint/lint1/cgram.y	Tue Oct 29 20:44:22 2024
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.512 2024/10/04 11:38:03 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.513 2024/10/29 20:44:22 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: cgram.y,v 1.512 2024/10/04 11:38:03 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.513 2024/10/29 20:44:22 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -712,7 +712,7 @@ gcc_statement_expr_item:
 			/* XXX: do that only on the last name */
 			if ($1->tn_op == NAME)
 				$1->u.sym->s_used = true;
-			expr($1, false, false, false, false);
+			expr($1, true, false, false, false);
 			suppress_fallthrough = false;
 			$$ = $1;
 		}

Reply via email to