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 handle gcc __FUNCTION__ and C9X __func__



details:   https://anonhg.NetBSD.org/src/rev/50e23638ba6e
branches:  trunk
changeset: 538546:50e23638ba6e
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Oct 22 13:31:34 2002 +0000

description:
handle gcc __FUNCTION__ and C9X __func__

diffstat:

 usr.bin/xlint/lint1/err.c  |   6 ++++--
 usr.bin/xlint/lint1/tree.c |  27 +++++++++++++++++++++++----
 2 files changed, 27 insertions(+), 6 deletions(-)

diffs (75 lines):

diff -r 3e461de718cf -r 50e23638ba6e usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Tue Oct 22 13:30:23 2002 +0000
+++ b/usr.bin/xlint/lint1/err.c Tue Oct 22 13:31:34 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: err.c,v 1.20 2002/10/21 21:14:51 christos Exp $        */
+/*     $NetBSD: err.c,v 1.21 2002/10/22 13:31:34 christos Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.20 2002/10/21 21:14:51 christos Exp $");
+__RCSID("$NetBSD: err.c,v 1.21 2002/10/22 13:31:34 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -371,6 +371,8 @@
        "struct or union member name in initializer is a C9X feature",/* 313 */
        "%s is not a structure or a union",                           /* 314 */
        "GCC style struct or union member name in initializer",       /* 315 */
+       "__FUNCTION__ is a GCC extension",                            /* 316 */
+       "__func__ is a C9X feature",                                  /* 317 */
 };
 
 /*
diff -r 3e461de718cf -r 50e23638ba6e usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Tue Oct 22 13:30:23 2002 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Tue Oct 22 13:31:34 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.29 2002/10/22 00:25:29 christos Exp $       */
+/*     $NetBSD: tree.c,v 1.30 2002/10/22 13:31:34 christos Exp $       */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.29 2002/10/22 00:25:29 christos Exp $");
+__RCSID("$NetBSD: tree.c,v 1.30 2002/10/22 13:31:34 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -301,8 +301,27 @@
                         */
                        sym->s_type = incref(sym->s_type, FUNC);
                } else {
-                       /* %s undefined */
-                       error(99, sym->s_name);
+                       if (!blklev) {
+                               /* %s undefined */
+                               error(99, sym->s_name);
+                       } else {
+                               int fixtype;
+                               if (strcmp(sym->s_name, "__FUNCTION__") == 0) {
+                                       gnuism(316);
+                                       fixtype = 1;
+                               } else if (strcmp(sym->s_name, "__func__") == 0) {
+                                       if (!Sflag)
+                                               warning(317);
+                                       fixtype = 1;
+                               } else {
+                                       error(99, sym->s_name);
+                                       fixtype = 0;
+                               }
+                               if (fixtype) {
+                                       sym->s_type = incref(gettyp(CHAR), PTR);
+                                       sym->s_type->t_const = 1;
+                               }
+                       }
                }
        }
 



Home | Main Index | Thread Index | Old Index