[master] 3655bf6 vcc fix keeping track of the first reference

Nils Goroll nils.goroll at uplex.de
Mon Jun 13 21:15:09 CEST 2016


commit 3655bf6cfaa214327f6205ed063647b75f73be77
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Jun 13 21:07:17 2016 +0200

    vcc fix keeping track of the first reference
    
    Fixes #1979

diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h
index 8a2b20e..22b30f2 100644
--- a/lib/libvcc/vcc_compile.h
+++ b/lib/libvcc/vcc_compile.h
@@ -128,7 +128,7 @@ struct symbol {
 	const void			*wildcard_priv;
 	enum symkind			kind;
 
-	const struct token		*def_b, *def_e;
+	const struct token		*def_b, *def_e, *ref_b;
 
 	vcc_type_t			fmt;
 
diff --git a/lib/libvcc/vcc_xref.c b/lib/libvcc/vcc_xref.c
index e8feac2..8a75c25 100644
--- a/lib/libvcc/vcc_xref.c
+++ b/lib/libvcc/vcc_xref.c
@@ -79,6 +79,8 @@ vcc_AddRef(struct vcc *tl, const struct token *t, enum symkind kind)
 	struct symbol *sym;
 
 	sym = VCC_SymbolTok(tl, NULL, t, kind, 1);
+	if (sym->ref_b == NULL)
+		sym->ref_b = t;
 	AN(sym);
 	sym->nref++;
 }
@@ -103,10 +105,12 @@ vcc_checkref(struct vcc *tl, const struct symbol *sym)
 {
 
 	if (sym->ndef == 0 && sym->nref != 0) {
+		AN(sym->ref_b);
 		VSB_printf(tl->sb, "Undefined %s %.*s, first reference:\n",
-		    VCC_SymKind(tl, sym), PF(sym->def_b));
-		vcc_ErrWhere(tl, sym->def_b);
+		    VCC_SymKind(tl, sym), PF(sym->ref_b));
+		vcc_ErrWhere(tl, sym->ref_b);
 	} else if (sym->ndef != 0 && sym->nref == 0) {
+		AN(sym->def_b);
 		VSB_printf(tl->sb, "Unused %s %.*s, defined:\n",
 		    VCC_SymKind(tl, sym), PF(sym->def_b));
 		vcc_ErrWhere(tl, sym->def_b);



More information about the varnish-commit mailing list