Module Name:    src
Committed By:   rillig
Date:           Mon Jun 17 04:14:02 UTC 2024

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

Log Message:
lint: accept C23 attributes at the beginning of a type declaration

The switch to GCC 12 brings support for C23, and localtime.c uses it to
mark [[maybe_unused]] parameters.

For now, accept C23 attributes independently from the language level. In
the end, the whole tree with the exception of the tools should be
switched to C23 mode instead of the current C99 mode.

For now, don't actually mark the argument as possibly unused, as lint
currently ignores __attribute__((__unused__)) as well.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/tests/usr.bin/xlint/lint1/c23.c
cvs rdiff -u -r1.503 -r1.504 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/c23.c
diff -u src/tests/usr.bin/xlint/lint1/c23.c:1.13 src/tests/usr.bin/xlint/lint1/c23.c:1.14
--- src/tests/usr.bin/xlint/lint1/c23.c:1.13	Sat May 11 16:12:28 2024
+++ src/tests/usr.bin/xlint/lint1/c23.c	Mon Jun 17 04:14:02 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: c23.c,v 1.13 2024/05/11 16:12:28 rillig Exp $	*/
+/*	$NetBSD: c23.c,v 1.14 2024/06/17 04:14:02 rillig Exp $	*/
 # 3 "c23.c"
 
 // Tests for the option -Ac23, which allows features from C23 and all earlier
@@ -163,3 +163,18 @@ attributes(int i)
 
 	return i;
 }
+
+typedef int number;
+
+void
+attributes_in_parameter_declaration(
+    /* expect+1: warning: parameter 'int_param' unused in function 'attributes_in_parameter_declaration' [231] */
+    [[maybe_unused]] int int_param,
+    /* expect+1: warning: parameter 'const_int_param' unused in function 'attributes_in_parameter_declaration' [231] */
+    [[maybe_unused]] const int const_int_param,
+    /* expect+1: warning: parameter 'typedef_param' unused in function 'attributes_in_parameter_declaration' [231] */
+    [[maybe_unused]] number typedef_param,
+    /* expect+1: warning: parameter 'const_typedef_param' unused in function 'attributes_in_parameter_declaration' [231] */
+    [[maybe_unused]] const number const_typedef_param)
+{
+}

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.503 src/usr.bin/xlint/lint1/cgram.y:1.504
--- src/usr.bin/xlint/lint1/cgram.y:1.503	Sun May 12 09:07:41 2024
+++ src/usr.bin/xlint/lint1/cgram.y	Mon Jun 17 04:14:02 2024
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.503 2024/05/12 09:07:41 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.504 2024/06/17 04:14:02 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.503 2024/05/12 09:07:41 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.504 2024/06/17 04:14:02 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -154,7 +154,7 @@ new_attribute(const sbuf_t *prefix, cons
 
 %}
 
-%expect 103
+%expect 110
 
 %union {
 	val_t	*y_val;
@@ -1055,6 +1055,9 @@ begin_type:
 	/* empty */ {
 		dcs_begin_type();
 	}
+|	attribute_specifier_sequence {
+		dcs_begin_type();
+	}
 ;
 
 end_type:

Reply via email to