Module Name:    src
Committed By:   rillig
Date:           Sun Jun 27 19:10:29 UTC 2021

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/tests/usr.bin/xlint/lint1: Makefile t_integration.sh
        src/usr.bin/xlint/lint1: cgram.y err.c
Added Files:
        src/tests/usr.bin/xlint/lint1: msg_345.c msg_345.exp

Log Message:
lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


To generate a diff of this commit:
cvs rdiff -u -r1.1066 -r1.1067 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.67 -r1.68 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/msg_345.c \
    src/tests/usr.bin/xlint/lint1/msg_345.exp
cvs rdiff -u -r1.60 -r1.61 src/tests/usr.bin/xlint/lint1/t_integration.sh
cvs rdiff -u -r1.235 -r1.236 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.119 -r1.120 src/usr.bin/xlint/lint1/err.c

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1066 src/distrib/sets/lists/tests/mi:1.1067
--- src/distrib/sets/lists/tests/mi:1.1066	Sun Jun 27 18:48:45 2021
+++ src/distrib/sets/lists/tests/mi	Sun Jun 27 19:10:29 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1066 2021/06/27 18:48:45 rillig Exp $
+# $NetBSD: mi,v 1.1067 2021/06/27 19:10:29 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6924,6 +6924,8 @@
 ./usr/tests/usr.bin/xlint/lint1/msg_343.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_344.c			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_344.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_345.c			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_345.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/op_colon.c			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/op_colon.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/stmt_for.c			tests-usr.bin-tests	compattestfile,atf

Index: src/tests/usr.bin/xlint/lint1/Makefile
diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.67 src/tests/usr.bin/xlint/lint1/Makefile:1.68
--- src/tests/usr.bin/xlint/lint1/Makefile:1.67	Sun Jun 27 18:48:45 2021
+++ src/tests/usr.bin/xlint/lint1/Makefile	Sun Jun 27 19:10:29 2021
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.67 2021/06/27 18:48:45 rillig Exp $
+# $NetBSD: Makefile,v 1.68 2021/06/27 19:10:29 rillig Exp $
 
 NOMAN=		# defined
-MAX_MESSAGE=	344		# see lint1/err.c
+MAX_MESSAGE=	345		# see lint1/err.c
 
 .include <bsd.own.mk>
 

Index: src/tests/usr.bin/xlint/lint1/t_integration.sh
diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.60 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.61
--- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.60	Sun Jun 27 18:48:45 2021
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh	Sun Jun 27 19:10:29 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.60 2021/06/27 18:48:45 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.61 2021/06/27 19:10:29 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -211,7 +211,7 @@ all_messages_body()
 
 	failed=""
 
-	for msg in $(seq 0 344); do
+	for msg in $(seq 0 345); do
 		name="$(printf 'msg_%03d.c' "$msg")"
 		check_lint1 "$name" \
 		|| failed="$failed${failed:+ }$name"

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.235 src/usr.bin/xlint/lint1/cgram.y:1.236
--- src/usr.bin/xlint/lint1/cgram.y:1.235	Sun Jun 27 18:54:14 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Sun Jun 27 19:10:29 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.235 2021/06/27 18:54:14 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.236 2021/06/27 19:10:29 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.235 2021/06/27 18:54:14 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.236 2021/06/27 19:10:29 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -1683,6 +1683,8 @@ switch_expr:
 /* TODO: c11ism */
 generic_selection:		/* C11 6.5.1.1 */
 	  T_GENERIC T_LPAREN expr T_COMMA generic_assoc_list T_RPAREN {
+	  	/* generic selection requires C11 or later */
+	  	c11ism(345);
 		$$ = $3;
 	  }
 	;

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.119 src/usr.bin/xlint/lint1/err.c:1.120
--- src/usr.bin/xlint/lint1/err.c:1.119	Sun May 16 11:11:36 2021
+++ src/usr.bin/xlint/lint1/err.c	Sun Jun 27 19:10:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.119 2021/05/16 11:11:36 rillig Exp $	*/
+/*	$NetBSD: err.c,v 1.120 2021/06/27 19:10:29 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.119 2021/05/16 11:11:36 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.120 2021/06/27 19:10:29 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -399,6 +399,7 @@ const char *const msgs[] = {
 	"argument to '%s' must be cast to 'unsigned char', not to '%s'", /* 342 */
 	"static array size is a C11 extension",			      /* 343 */
 	"bit-field of type plain 'int' has implementation-defined signedness", /* 344 */
+	"generic selection requires C11 or later",		      /* 345 */
 };
 
 static struct include_level {

Added files:

Index: src/tests/usr.bin/xlint/lint1/msg_345.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_345.c:1.1
--- /dev/null	Sun Jun 27 19:10:29 2021
+++ src/tests/usr.bin/xlint/lint1/msg_345.c	Sun Jun 27 19:10:29 2021
@@ -0,0 +1,14 @@
+/*	$NetBSD: msg_345.c,v 1.1 2021/06/27 19:10:29 rillig Exp $	*/
+# 3 "msg_345.c"
+
+// Test for message: generic selection requires C11 or later [345]
+
+/* Omit flag -g since it silences c11ism. */
+/* lint1-flags: -Sw */
+
+int
+test(int x)
+{
+	/* expect+1: generic selection requires C11 or later [345] */
+	return _Generic(x, default: 3);
+}
Index: src/tests/usr.bin/xlint/lint1/msg_345.exp
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_345.exp:1.1
--- /dev/null	Sun Jun 27 19:10:29 2021
+++ src/tests/usr.bin/xlint/lint1/msg_345.exp	Sun Jun 27 19:10:29 2021
@@ -0,0 +1 @@
+msg_345.c(13): error: generic selection requires C11 or later [345]

Reply via email to