Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: make _Generic a primary-expression
details: https://anonhg.NetBSD.org/src/rev/4aee450bf954
branches: trunk
changeset: 1022301:4aee450bf954
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jul 11 20:37:21 2021 +0000
description:
lint: make _Generic a primary-expression
C11 says so, and unless the _Generic expression was wrapped in
parentheses, it was not possible before to use it as a function call
expression.
diffstat:
tests/usr.bin/xlint/lint1/c11_generic_expression.c | 4 +---
tests/usr.bin/xlint/lint1/c11_generic_expression.exp | 2 --
usr.bin/xlint/lint1/cgram.y | 6 +++---
3 files changed, 4 insertions(+), 8 deletions(-)
diffs (61 lines):
diff -r 3df0c46eee91 -r 4aee450bf954 tests/usr.bin/xlint/lint1/c11_generic_expression.c
--- a/tests/usr.bin/xlint/lint1/c11_generic_expression.c Sun Jul 11 20:34:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/c11_generic_expression.c Sun Jul 11 20:37:21 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: c11_generic_expression.c,v 1.7 2021/07/11 20:34:05 rillig Exp $ */
+/* $NetBSD: c11_generic_expression.c,v 1.8 2021/07/11 20:37:21 rillig Exp $ */
# 3 "c11_generic_expression.c"
/*
@@ -92,7 +92,5 @@
int
primary_expression(void)
{
- /*FIXME*//* expect+1: syntax error '(' [249] */
return _Generic(0, int: assignment_expression)(0, 0);
}
-/* expect-1: falls off */
diff -r 3df0c46eee91 -r 4aee450bf954 tests/usr.bin/xlint/lint1/c11_generic_expression.exp
--- a/tests/usr.bin/xlint/lint1/c11_generic_expression.exp Sun Jul 11 20:34:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/c11_generic_expression.exp Sun Jul 11 20:37:21 2021 +0000
@@ -4,5 +4,3 @@
c11_generic_expression.c(53): warning: argument 'c' unused in function 'classify_char' [231]
c11_generic_expression.c(72): error: syntax error 'second' [249]
c11_generic_expression.c(77): warning: function comma_expression falls off bottom without returning value [217]
-c11_generic_expression.c(96): error: syntax error '(' [249]
-c11_generic_expression.c(97): warning: function primary_expression falls off bottom without returning value [217]
diff -r 3df0c46eee91 -r 4aee450bf954 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Sun Jul 11 20:34:05 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Sun Jul 11 20:37:21 2021 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.316 2021/07/11 20:25:54 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.317 2021/07/11 20:37:21 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.316 2021/07/11 20:25:54 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.317 2021/07/11 20:37:21 rillig Exp $");
#endif
#include <limits.h>
@@ -1722,7 +1722,6 @@
$$ = build(COMMA, $1, $3);
}
| cast_expression
- | generic_selection /* TODO: move to primary_expression */
;
assignment_expression: /* C99 6.5.16 */
@@ -1747,6 +1746,7 @@
$2->tn_parenthesized = true;
$$ = $2;
}
+ | generic_selection
/* GCC primary-expression, see c_parser_postfix_expression */
| T_BUILTIN_OFFSETOF T_LPAREN type_name T_COMMA identifier T_RPAREN {
symtyp = FMEMBER;
Home |
Main Index |
Thread Index |
Old Index