Module Name: src
Committed By: christos
Date: Sat Nov 5 01:09:30 UTC 2016
Modified Files:
src/usr.bin/xlint/lint1: cgram.y scan.l
Log Message:
Add _Generic C11 support.
To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.66 -r1.67 src/usr.bin/xlint/lint1/scan.l
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.80 src/usr.bin/xlint/lint1/cgram.y:1.81
--- src/usr.bin/xlint/lint1/cgram.y:1.80 Fri Aug 19 06:58:15 2016
+++ src/usr.bin/xlint/lint1/cgram.y Fri Nov 4 21:09:30 2016
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.80 2016/08/19 10:58:15 christos Exp $ */
+/* $NetBSD: cgram.y,v 1.81 2016/11/05 01:09:30 christos 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.80 2016/08/19 10:58:15 christos Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.81 2016/11/05 01:09:30 christos Exp $");
#endif
#include <stdlib.h>
@@ -163,6 +163,7 @@ anonymize(sym_t *s)
%token T_ELLIPSE
%token T_REAL
%token T_IMAG
+%token T_GENERIC
/* storage classes (extern, static, auto, register and typedef) */
%token <y_scl> T_SCLASS
@@ -289,6 +290,7 @@ anonymize(sym_t *s)
%type <y_tnode> expr_stmnt_val
%type <y_tnode> expr_stmnt_list
%type <y_tnode> term
+%type <y_tnode> generic_expr
%type <y_tnode> func_arg_list
%type <y_op> point_or_arrow
%type <y_type> type_name
@@ -1539,6 +1541,22 @@ switch_expr:
}
;
+association:
+ type_name T_COLON expr
+ | T_DEFAULT T_COLON expr
+ ;
+
+association_list:
+ association
+ | association_list T_COMMA association
+ ;
+
+generic_expr:
+ T_GENERIC T_LPARN expr T_COMMA association_list T_RPARN {
+ $$ = $3;
+ }
+ ;
+
do_stmnt:
do stmnt {
CLRWFLGS(__FILE__, __LINE__);
@@ -1730,6 +1748,9 @@ expr:
| term {
$$ = $1;
}
+ | generic_expr {
+ $$ = $1;
+ }
;
term:
Index: src/usr.bin/xlint/lint1/scan.l
diff -u src/usr.bin/xlint/lint1/scan.l:1.66 src/usr.bin/xlint/lint1/scan.l:1.67
--- src/usr.bin/xlint/lint1/scan.l:1.66 Wed Jul 20 13:42:14 2016
+++ src/usr.bin/xlint/lint1/scan.l Fri Nov 4 21:09:30 2016
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: scan.l,v 1.66 2016/07/20 17:42:14 christos Exp $ */
+/* $NetBSD: scan.l,v 1.67 2016/11/05 01:09:30 christos 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: scan.l,v 1.66 2016/07/20 17:42:14 christos Exp $");
+__RCSID("$NetBSD: scan.l,v 1.67 2016/11/05 01:09:30 christos Exp $");
#endif
#include <stdlib.h>
@@ -263,6 +263,7 @@ static struct kwtab {
{ "extern", T_SCLASS, EXTERN, 0, 0, 0, 0, 0, 0 },
{ "float", T_TYPE, 0, FLOAT, 0, 0, 0, 0, 0 },
{ "for", T_FOR, 0, 0, 0, 0, 0, 0, 0 },
+ { "_Generic", T_GENERIC, 0, 0, 0, 0, 1, 0, 0 },
{ "goto", T_GOTO, 0, 0, 0, 0, 0, 0, 0 },
{ "if", T_IF, 0, 0, 0, 0, 0, 0, 0 },
{ "__imag__", T_IMAG, 0, 0, 0, 0, 1, 0, 0 },