Tue Feb 18 22:01:37 2014 UTC ()
add __extension__ and typeof


(christos)
diff -r1.57 -r1.58 src/usr.bin/xlint/lint1/cgram.y
diff -r1.46 -r1.47 src/usr.bin/xlint/lint1/err.c
diff -r1.53 -r1.54 src/usr.bin/xlint/lint1/scan.l
diff -r1.74 -r1.75 src/usr.bin/xlint/lint1/tree.c

cvs diff -r1.57 -r1.58 src/usr.bin/xlint/lint1/cgram.y (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/cgram.y 2014/02/04 08:08:59 1.57
+++ src/usr.bin/xlint/lint1/cgram.y 2014/02/18 22:01:36 1.58
@@ -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 @@
 %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 @@
 	  T_TYPE {
 		$$ = gettyp($1);
 	  }
+	| T_TYPEOF T_LPARN term T_RPARN {
+		$$ = $3->tn_type;
+	  }
 	| struct_spec {
 		popdecl();
 		$$ = $1;
@@ -1731,6 +1736,9 @@
 	  }
 	| 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)

cvs diff -r1.46 -r1.47 src/usr.bin/xlint/lint1/err.c (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/err.c 2013/04/19 17:43:05 1.46
+++ src/usr.bin/xlint/lint1/err.c 2014/02/18 22:01:36 1.47
@@ -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 @@
 	"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 */

cvs diff -r1.53 -r1.54 src/usr.bin/xlint/lint1/scan.l (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/scan.l 2013/10/18 20:46:09 1.53
+++ src/usr.bin/xlint/lint1/scan.l 2014/02/18 22:01:36 1.54
@@ -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 @@
 	{ "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 @@
 	{ "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 },

cvs diff -r1.74 -r1.75 src/usr.bin/xlint/lint1/tree.c (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/tree.c 2014/02/18 20:43:36 1.74
+++ src/usr.bin/xlint/lint1/tree.c 2014/02/18 22:01:36 1.75
@@ -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 @@
 
 	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);
 	}