[master] 0fc4e8c More symbol simplification

Poul-Henning Kamp phk at FreeBSD.org
Mon Jan 29 23:21:10 UTC 2018


commit 0fc4e8c7021cf7169ca80db43657da12aec4f0cf
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Jan 29 21:53:10 2018 +0000

    More symbol simplification

diff --git a/bin/varnishtest/tests/m00001.vtc b/bin/varnishtest/tests/m00001.vtc
index 5f7979f..a32a7de 100644
--- a/bin/varnishtest/tests/m00001.vtc
+++ b/bin/varnishtest/tests/m00001.vtc
@@ -52,7 +52,7 @@ varnish v1 -errvcl {Module std already imported.} {
 	import std;
 }
 
-varnish v1 -errvcl {Symbol not found: 'std' (expected type BOOL):} {
+varnish v1 -errvcl {Symbol type (vmod) can not be used in expression.} {
 	import std;
 
 	sub vcl_recv {
diff --git a/bin/varnishtest/tests/r00916.vtc b/bin/varnishtest/tests/r00916.vtc
index ac268ca..6c951fb 100644
--- a/bin/varnishtest/tests/r00916.vtc
+++ b/bin/varnishtest/tests/r00916.vtc
@@ -5,7 +5,7 @@ server s1 {
 	txresp -body "FOO"
 } -start
 
-varnish v1 -errvcl {Symbol not found: 's-1' (expected type BACKEND):} {
+varnish v1 -errvcl {Symbol not found: 's-1'} {
 	backend b { .host = "127.0.0.1"; }
 	sub s1 {
 	}
diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc
index 29d96bd..937fa83 100644
--- a/bin/varnishtest/tests/v00016.vtc
+++ b/bin/varnishtest/tests/v00016.vtc
@@ -41,7 +41,7 @@ varnish v1 -errvcl {Operator > not possible on BACKEND} {
 	sub vcl_recv { if (a > b) { } }
 }
 
-varnish v1 -errvcl {Symbol not found: 'req.foo' (expected type BOOL):} {
+varnish v1 -errvcl {Symbol not found: 'req.foo'} {
 	backend b { .host = "127.0.0.1"; }
 	sub vcl_hash { if (req.foo != "bar") { } }
 }
@@ -66,7 +66,7 @@ varnish v1 -errvcl {Cannot be set in method 'vcl_pipe'.} {
 	}
 }
 
-varnish v1 -errvcl {Symbol not found: 'c' (expected type BACKEND):} {
+varnish v1 -errvcl {Symbol not found: 'c'} {
 	backend b { .host = "127.0.0.1"; }
 	sub vcl_backend_response {
 		if (beresp.backend == c) {
diff --git a/bin/varnishtest/tests/v00018.vtc b/bin/varnishtest/tests/v00018.vtc
index c9b6b6a..653c0a0 100644
--- a/bin/varnishtest/tests/v00018.vtc
+++ b/bin/varnishtest/tests/v00018.vtc
@@ -38,7 +38,7 @@ varnish v1 -errvcl {Expected ';' got 'if'} {
 	sub vcl_recv { set req.url = "foo" if "bar"; }
 }
 
-varnish v1 -errvcl {Symbol not found: 'req.foo' (expected type STRING):} {
+varnish v1 -errvcl {Symbol not found: 'req.foo'} {
 	backend b { .host = "127.0.0.1"; }
 	sub vcl_hash { hash_data(req.foo); }
 }
@@ -63,7 +63,7 @@ varnish v1 -vcl {
 	sub vcl_backend_response { set beresp.do_gzip = false; }
 }
 
-varnish v1 -errvcl {Symbol not found: 'mu' (expected type BOOL):} {
+varnish v1 -errvcl {Symbol not found: 'mu'} {
 	backend b { .host = "127.0.0.1"; }
 	sub vcl_backend_response { set beresp.do_gzip = mu; }
 }
diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc
index 05f7c24..dbfa07a 100644
--- a/bin/varnishtest/tests/v00020.vtc
+++ b/bin/varnishtest/tests/v00020.vtc
@@ -31,7 +31,7 @@ varnish v1 -errvcl {Comparison of different types: INT '!=' STRING} {
 	}
 }
 
-varnish v1 -errvcl {Symbol not found: 'vcl_recv' (expected type STRING)} {
+varnish v1 -errvcl {Symbol type (sub) can not be used in expression.} {
 	sub vcl_recv {
 		set req.http.foo = vcl_recv;
 	}
@@ -262,7 +262,7 @@ varnish v1 -errvcl {INT * BLOB not possible.} {
 }
 
 # XXX: should spot nonexistent storage
-varnish v1 -errvcl {Symbol not found: 'storage.foo' (expected type STEVEDORE):} {
+varnish v1 -errvcl {Symbol not found: 'storage.foo'} {
 	sub vcl_backend_response {
 		set beresp.storage = storage.foo;
 	}
diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h
index ec9026c..be01f2c 100644
--- a/lib/libvcc/vcc_compile.h
+++ b/lib/libvcc/vcc_compile.h
@@ -281,7 +281,6 @@ sym_expr_t vcc_Eval_Handle;
 sym_expr_t vcc_Eval_SymFunc;
 void vcc_Eval_Func(struct vcc *tl, const char *spec,
     const char *extra, const struct symbol *sym);
-enum symkind VCC_HandleKind(vcc_type_t fmt);
 void VCC_GlobalSymbol(struct symbol *, vcc_type_t fmt, const char *pfx);
 struct symbol *VCC_HandleSymbol(struct vcc *, vcc_type_t , const char *);
 
diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index 68c2bc7..4bf3b72 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -630,7 +630,6 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt)
 	struct expr *e1, *e2;
 	const char *ip, *sign;
 	struct symbol *sym;
-	enum symkind kind;
 	double d;
 	int i;
 
@@ -649,24 +648,9 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt)
 	}
 	switch (tl->t->tok) {
 	case ID:
-		/*
-		 * XXX: what if var and func/proc had same name ?
-		 * XXX: look for SYM_VAR first for consistency ?
-		 */
-		sym = NULL;
-		kind = VCC_HandleKind(fmt);
-		if (kind != SYM_NONE)
-			sym = VCC_SymbolTok(tl, kind, 0);
-		if (sym == NULL)
-			sym = VCC_SymbolTok(tl, SYM_NONE, 0);
-		if (sym == NULL || sym->eval == NULL) {
-			VSB_printf(tl->sb, "Symbol not found: ");
-			vcc_ErrToken(tl, tl->t);
-			VSB_printf(tl->sb, " (expected type %s):\n",
-			    vcc_utype(fmt));
-			vcc_ErrWhere(tl, tl->t);
-			return;
-		}
+		sym = VCC_SymbolGet(tl, SYM_NONE, "Symbol not found",
+		    XREF_NONE);
+		ERRCHK(tl);
 		AN(sym);
 		if (sym->kind == SYM_FUNC && sym->fmt == VOID) {
 			VSB_printf(tl->sb, "Function returns VOID:\n");
diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c
index 376e925..042268d 100644
--- a/lib/libvcc/vcc_symb.c
+++ b/lib/libvcc/vcc_symb.c
@@ -39,7 +39,7 @@
 
 /*--------------------------------------------------------------------*/
 
-enum symkind
+static enum symkind
 VCC_HandleKind(vcc_type_t fmt)
 {
 	if (fmt == ACL)		return(SYM_ACL);
@@ -111,7 +111,7 @@ VCC_SymbolGet(struct vcc *tl, enum symkind kind, const char *err,
 	struct symbol *sym;
 
 	sym = VCC_Symbol(tl, NULL, tl->t->b, tl->t->e, kind, err == NULL);
-	if (sym == NULL || sym->kind != kind) {
+	if (sym == NULL || (kind != SYM_NONE && sym->kind != kind)) {
 		VSB_printf(tl->sb, "%s: ", err);
 		vcc_ErrToken(tl, tl->t);
 		VSB_cat(tl->sb, "\nAt: ");
diff --git a/lib/libvcc/vcc_xref.c b/lib/libvcc/vcc_xref.c
index 1d6b0d7..e6fc15b 100644
--- a/lib/libvcc/vcc_xref.c
+++ b/lib/libvcc/vcc_xref.c
@@ -67,6 +67,7 @@ void
 vcc_AddRef(struct vcc *tl, struct symbol *sym)
 {
 
+	(void)tl;
 	if (sym->ref_b == NULL)
 		sym->ref_b = tl->t;
 	sym->nref++;


More information about the varnish-commit mailing list