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 Add _Generic C11 support.



details:   https://anonhg.NetBSD.org/src/rev/fdfe06688579
branches:  trunk
changeset: 348747:fdfe06688579
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Nov 05 01:09:30 2016 +0000

description:
Add _Generic C11 support.

diffstat:

 usr.bin/xlint/lint1/cgram.y |  25 +++++++++++++++++++++++--
 usr.bin/xlint/lint1/scan.l  |   5 +++--
 2 files changed, 26 insertions(+), 4 deletions(-)

diffs (95 lines):

diff -r 8ba257cb97ac -r fdfe06688579 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sat Nov 05 01:08:58 2016 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sat Nov 05 01:09:30 2016 +0000
@@ -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 @@
 %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 @@
 %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 @@
          }
        ;
 
+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 @@
        | term {
                $$ = $1;
          }
+       | generic_expr {
+               $$ = $1;
+         }
        ;
 
 term:
diff -r 8ba257cb97ac -r fdfe06688579 usr.bin/xlint/lint1/scan.l
--- a/usr.bin/xlint/lint1/scan.l        Sat Nov 05 01:08:58 2016 +0000
+++ b/usr.bin/xlint/lint1/scan.l        Sat Nov 05 01:09:30 2016 +0000
@@ -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 @@
        { "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 },



Home | Main Index | Thread Index | Old Index