Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: explain global variabl...
details: https://anonhg.NetBSD.org/src/rev/b5007abb772c
branches: trunk
changeset: 984661:b5007abb772c
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Jul 15 17:48:10 2021 +0000
description:
tests/lint: explain global variables in __attribute__
diffstat:
tests/usr.bin/xlint/lint1/expr_precedence.c | 12 ++++++++++--
tests/usr.bin/xlint/lint1/expr_precedence.exp | 4 ++--
2 files changed, 12 insertions(+), 4 deletions(-)
diffs (36 lines):
diff -r 37496c851284 -r b5007abb772c tests/usr.bin/xlint/lint1/expr_precedence.c
--- a/tests/usr.bin/xlint/lint1/expr_precedence.c Thu Jul 15 17:20:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/expr_precedence.c Thu Jul 15 17:48:10 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: expr_precedence.c,v 1.2 2021/07/15 17:20:58 rillig Exp $ */
+/* $NetBSD: expr_precedence.c,v 1.3 2021/07/15 17:48:10 rillig Exp $ */
# 3 "expr_precedence.c"
/*
@@ -22,7 +22,15 @@
* don't make sense at that point.
*/
void __attribute__((format(printf,
- /* expect+2: error: 'var' undefined [99] */ /* XXX: why? */
+ /*
+ * Inside of __attribute__((...)), symbol lookup works differently. For
+ * example, 'printf' is a keyword, and since all arguments to
+ * __attribute__ are constant expressions, looking up global variables
+ * would not make sense. Therefore, 'var' is undefined.
+ *
+ * See lex.c, function 'search', keyword 'attron'.
+ */
+ /* expect+2: error: 'var' undefined [99] */
/* expect+1: syntax error '=' [249] */
var = 1,
/* Syntactically ok, must be a constant expression though. */
diff -r 37496c851284 -r b5007abb772c tests/usr.bin/xlint/lint1/expr_precedence.exp
--- a/tests/usr.bin/xlint/lint1/expr_precedence.exp Thu Jul 15 17:20:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/expr_precedence.exp Thu Jul 15 17:48:10 2021 +0000
@@ -1,4 +1,4 @@
expr_precedence.c(15): error: syntax error '4' [249]
expr_precedence.c(18): error: non-constant initializer [177]
-expr_precedence.c(27): error: 'var' undefined [99]
-expr_precedence.c(27): error: syntax error '=' [249]
+expr_precedence.c(35): error: 'var' undefined [99]
+expr_precedence.c(35): error: syntax error '=' [249]
Home |
Main Index |
Thread Index |
Old Index