summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-05-24 16:55:23 -0700
committerRuss Cox <rsc@golang.org>2010-05-24 16:55:23 -0700
commit1a9c46be99cf7d3c95a61bb78c83ebc92afc14a5 (patch)
treed500e2f571ff1af803b536795e5dd899c2ce694c /src
parent3574911597e5f2aec3e8efa653d361eb6d500fec (diff)
downloadgolang-1a9c46be99cf7d3c95a61bb78c83ebc92afc14a5.tar.gz
gc: fix shift/reduce conflict in go.y export syntax
Fixes issue 771. R=ken2 CC=golang-dev http://codereview.appspot.com/1267042
Diffstat (limited to 'src')
-rw-r--r--src/cmd/gc/go.y15
-rw-r--r--src/cmd/gc/subr.c8
2 files changed, 19 insertions, 4 deletions
diff --git a/src/cmd/gc/go.y b/src/cmd/gc/go.y
index 8128e8608..5aac463c8 100644
--- a/src/cmd/gc/go.y
+++ b/src/cmd/gc/go.y
@@ -74,6 +74,8 @@
%type <node> indcl interfacetype structtype ptrtype
%type <node> recvchantype non_recvchantype othertype fnret_type fntype
+%type <val> hidden_tag
+
%type <sym> hidden_importsym hidden_pkg_importsym
%type <node> hidden_constant hidden_literal hidden_dcl
@@ -1709,12 +1711,12 @@ hidden_dcl:
}
hidden_structdcl:
- sym hidden_type oliteral
+ sym hidden_type hidden_tag
{
$$ = nod(ODCLFIELD, newname($1), typenod($2));
$$->val = $3;
}
-| '?' hidden_type oliteral
+| '?' hidden_type hidden_tag
{
Sym *s;
@@ -1728,6 +1730,15 @@ hidden_structdcl:
$$->val = $3;
}
+hidden_tag:
+ {
+ $$.ctype = CTxxx;
+ }
+| ':' LLITERAL // extra colon avoids conflict with "" looking like beginning of "".typename
+ {
+ $$ = $2;
+ }
+
hidden_interfacedcl:
sym '(' ohidden_funarg_list ')' ohidden_funres
{
diff --git a/src/cmd/gc/subr.c b/src/cmd/gc/subr.c
index b0192adf3..cf7b1865c 100644
--- a/src/cmd/gc/subr.c
+++ b/src/cmd/gc/subr.c
@@ -1295,8 +1295,12 @@ Tpretty(Fmt *fp, Type *t)
fmtprint(fp, "... %T", t->type->type);
} else
fmtprint(fp, "%T", t->type);
- if(t->note)
- fmtprint(fp, " \"%Z\"", t->note);
+ if(t->note) {
+ fmtprint(fp, " ");
+ if(exporting)
+ fmtprint(fp, ":");
+ fmtprint(fp, "\"%Z\"", t->note);
+ }
return 0;
case TFORW: