Module Name: src
Committed By: christos
Date: Tue Feb 18 22:01:37 UTC 2014
Modified Files:
src/usr.bin/xlint/lint1: cgram.y err.c scan.l tree.c
Log Message:
add __extension__ and typeof
To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.46 -r1.47 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.53 -r1.54 src/usr.bin/xlint/lint1/scan.l
cvs rdiff -u -r1.74 -r1.75 src/usr.bin/xlint/lint1/tree.c
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.57 src/usr.bin/xlint/lint1/cgram.y:1.58
--- src/usr.bin/xlint/lint1/cgram.y:1.57 Tue Feb 4 03:08:59 2014
+++ src/usr.bin/xlint/lint1/cgram.y Tue Feb 18 17:01:36 2014
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.57 2014/02/04 08:08:59 njoly Exp $ */
+/* $NetBSD: cgram.y,v 1.58 2014/02/18 22:01:36 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.57 2014/02/04 08:08:59 njoly Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.58 2014/02/18 22:01:36 christos Exp $");
#endif
#include <stdlib.h>
@@ -130,6 +130,8 @@ static inline void RESTORE(const char *f
%token <y_op> T_UNOP
%token <y_op> T_INCDEC
%token T_SIZEOF
+%token T_TYPEOF
+%token T_EXTENSION
%token T_ALIGNOF
%token <y_op> T_MULT
%token <y_op> T_DIVOP
@@ -553,6 +555,9 @@ notype_typespec:
T_TYPE {
$$ = gettyp($1);
}
+ | T_TYPEOF T_LPARN term T_RPARN {
+ $$ = $3->tn_type;
+ }
| struct_spec {
popdecl();
$$ = $1;
@@ -1732,6 +1737,9 @@ term:
| T_IMAG T_LPARN term T_RPARN {
$$ = build(IMAG, $3, NULL);
}
+ | T_EXTENSION T_LPARN term T_RPARN {
+ $$ = $3;
+ }
| T_SIZEOF term %prec T_SIZEOF {
if (($$ = $2 == NULL ? NULL : bldszof($2->tn_type)) != NULL)
chkmisc($2, 0, 0, 0, 0, 0, 1);
Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.46 src/usr.bin/xlint/lint1/err.c:1.47
--- src/usr.bin/xlint/lint1/err.c:1.46 Fri Apr 19 13:43:05 2013
+++ src/usr.bin/xlint/lint1/err.c Tue Feb 18 17:01:36 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: err.c,v 1.46 2013/04/19 17:43:05 christos Exp $ */
+/* $NetBSD: err.c,v 1.47 2014/02/18 22:01:36 christos 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.46 2013/04/19 17:43:05 christos Exp $");
+__RCSID("$NetBSD: err.c,v 1.47 2014/02/18 22:01:36 christos Exp $");
#endif
#include <sys/types.h>
@@ -208,7 +208,7 @@ const char *msgs[] = {
"cannot take size/alignment of void", /* 146 */
"invalid cast expression", /* 147 */
"improper cast of void expression", /* 148 */
- "illegal function", /* 149 */
+ "illegal function (type %s)", /* 149 */
"argument mismatch: %d arg%s passed, %d expected", /* 150 */
"void expressions may not be arguments, arg #%d", /* 151 */
"argument cannot have unknown size, arg #%d", /* 152 */
Index: src/usr.bin/xlint/lint1/scan.l
diff -u src/usr.bin/xlint/lint1/scan.l:1.53 src/usr.bin/xlint/lint1/scan.l:1.54
--- src/usr.bin/xlint/lint1/scan.l:1.53 Fri Oct 18 16:46:09 2013
+++ src/usr.bin/xlint/lint1/scan.l Tue Feb 18 17:01:36 2014
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: scan.l,v 1.53 2013/10/18 20:46:09 christos Exp $ */
+/* $NetBSD: scan.l,v 1.54 2014/02/18 22:01:36 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.53 2013/10/18 20:46:09 christos Exp $");
+__RCSID("$NetBSD: scan.l,v 1.54 2014/02/18 22:01:36 christos Exp $");
#endif
#include <stdlib.h>
@@ -230,6 +230,7 @@ static struct kwtab {
{ "double", T_TYPE, 0, DOUBLE, 0, 0, 0, 0 },
{ "else", T_ELSE, 0, 0, 0, 0, 0, 0 },
{ "enum", T_ENUM, 0, 0, 0, 0, 0, 0 },
+ { "__extension__", T_EXTENSION, 0, 0, 0, 0, 0, 1 },
{ "extern", T_SCLASS, EXTERN, 0, 0, 0, 0, 0 },
{ "float", T_TYPE, 0, FLOAT, 0, 0, 0, 0 },
{ "for", T_FOR, 0, 0, 0, 0, 0, 0 },
@@ -256,6 +257,9 @@ static struct kwtab {
{ "struct", T_SOU, 0, STRUCT, 0, 0, 0, 0 },
{ "switch", T_SWITCH, 0, 0, 0, 0, 0, 0 },
{ "typedef", T_SCLASS, TYPEDEF, 0, 0, 0, 0, 0 },
+ { "typeof", T_TYPEOF, 0, 0, 0, 0, 0, 1 },
+ { "__typeof", T_TYPEOF, 0, 0, 0, 0, 0, 1 },
+ { "__typeof__", T_TYPEOF, 0, 0, 0, 0, 0, 1 },
{ "union", T_SOU, 0, UNION, 0, 0, 0, 0 },
{ "unsigned", T_TYPE, 0, UNSIGN, 0, 0, 0, 0 },
{ "void", T_TYPE, 0, VOID, 0, 0, 0, 0 },
Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.74 src/usr.bin/xlint/lint1/tree.c:1.75
--- src/usr.bin/xlint/lint1/tree.c:1.74 Tue Feb 18 15:43:36 2014
+++ src/usr.bin/xlint/lint1/tree.c Tue Feb 18 17:01:36 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.74 2014/02/18 20:43:36 christos Exp $ */
+/* $NetBSD: tree.c,v 1.75 2014/02/18 22:01:36 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.74 2014/02/18 20:43:36 christos Exp $");
+__RCSID("$NetBSD: tree.c,v 1.75 2014/02/18 22:01:36 christos Exp $");
#endif
#include <stdlib.h>
@@ -3171,8 +3171,9 @@ funccall(tnode_t *func, tnode_t *args)
if (func->tn_type->t_tspec != PTR ||
func->tn_type->t_subt->t_tspec != FUNC) {
+ char buf[256];
/* illegal function */
- error(149);
+ error(149, tyname(buf, sizeof(buf), func->tn_type));
return (NULL);
}