[master] 3a3aa94 Allow symbols to be defined after use, provided their use gives them a clear type.

Poul-Henning Kamp phk at FreeBSD.org
Wed Dec 7 11:02:05 CET 2016


commit 3a3aa94239a9b9df5b843167fa5e83e653826754
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Dec 7 10:00:27 2016 +0000

    Allow symbols to be defined after use, provided their use gives
    them a clear type.
    
    Fixes #2016

diff --git a/bin/varnishtest/tests/c00005.vtc b/bin/varnishtest/tests/c00005.vtc
index 99a7e5d..b3b1e95 100644
--- a/bin/varnishtest/tests/c00005.vtc
+++ b/bin/varnishtest/tests/c00005.vtc
@@ -10,15 +10,16 @@ server s1 {
 } -start
 
 varnish v1 -arg "-p vsl_mask=+VCL_trace" -vcl+backend {
-	acl acl1 {
-		"${localhost}";
-	}
-
 	sub vcl_recv {
 		if (client.ip ~ acl1) {
 			set req.url = "/";
 		}
 	}
+
+	acl acl1 {
+		"${localhost}";
+	}
+
 	sub vcl_deliver {
 		set resp.http.acl = acl1;
 	}
diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c
index c1aa72f..03b5272 100644
--- a/lib/libvcc/vcc_symb.c
+++ b/lib/libvcc/vcc_symb.c
@@ -235,13 +235,14 @@ VCC_HandleSymbol(struct vcc *tl, const struct token *tk, vcc_type_t fmt,
 		AN(sym->def_b);
 		vcc_ErrWhere(tl, sym->def_b);
 		return (sym);
-	} else if (sym != NULL) {
+	} else if (sym != NULL && sym->kind != kind) {
 		VSB_printf(tl->sb,
 		    "Name %.*s is a reserved name.\n", PF(tk));
 		vcc_ErrWhere(tl, tk);
 		return (sym);
 	}
-	sym = VCC_SymbolTok(tl, NULL, tk, kind, 1);
+	if (sym == NULL)
+		sym = VCC_SymbolTok(tl, NULL, tk, kind, 1);
 	AN(sym);
 	AZ(sym->ndef);
 	va_start(ap, str);



More information about the varnish-commit mailing list