Module Name:    src
Committed By:   rillig
Date:           Sat Sep 28 16:09:23 UTC 2024

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

Log Message:
lint: treat __attribute__((__constructor__)) functions as used

Seen in jemalloc.c.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_236.c
cvs rdiff -u -r1.510 -r1.511 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_236.c
diff -u src/tests/usr.bin/xlint/lint1/msg_236.c:1.6 src/tests/usr.bin/xlint/lint1/msg_236.c:1.7
--- src/tests/usr.bin/xlint/lint1/msg_236.c:1.6	Thu Sep 26 20:08:02 2024
+++ src/tests/usr.bin/xlint/lint1/msg_236.c	Sat Sep 28 16:09:23 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_236.c,v 1.6 2024/09/26 20:08:02 rillig Exp $	*/
+/*	$NetBSD: msg_236.c,v 1.7 2024/09/28 16:09:23 rillig Exp $	*/
 # 3 "msg_236.c"
 
 // Test for message: static function '%s' unused [236]
@@ -23,7 +23,6 @@ inline_function(void)
 
 __attribute__((__constructor__))
 static void
-/* expect+1: warning: static function 'constructor_function' unused [236] */
 constructor_function(void)
 {
 }

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.510 src/usr.bin/xlint/lint1/cgram.y:1.511
--- src/usr.bin/xlint/lint1/cgram.y:1.510	Sat Sep 28 15:51:40 2024
+++ src/usr.bin/xlint/lint1/cgram.y	Sat Sep 28 16:09:23 2024
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.510 2024/09/28 15:51:40 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.511 2024/09/28 16:09:23 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.510 2024/09/28 15:51:40 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.511 2024/09/28 16:09:23 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -2506,6 +2506,7 @@ gcc_attribute:
 		if (is_either(name, "packed", "__packed__"))
 			dcs_add_packed();
 		else if (is_either(name, "used", "__used__") ||
+		    is_either(name, "constructor", "__constructor__") ||
 		    is_either(name, "unused", "__unused__"))
 			$$.used = true;
 		else if (is_either(name, "fallthrough", "__fallthrough__"))

Reply via email to