]> Cypherpunks repositories - gostls13.git/commitdiff
bug085 bug129
authorRuss Cox <rsc@golang.org>
Thu, 5 Mar 2009 23:57:03 +0000 (15:57 -0800)
committerRuss Cox <rsc@golang.org>
Thu, 5 Mar 2009 23:57:03 +0000 (15:57 -0800)
R=ken
OCL=25787
CL=25791

src/cmd/gc/go.y
src/cmd/gc/lex.c
test/fixedbugs/bug085.go [moved from test/bugs/bug085.go with 100% similarity]
test/fixedbugs/bug129.go [moved from test/bugs/bug129.go with 100% similarity]
test/golden.out

index fb905292d311be09b0dc5b95abd593fba358366b..e5a8faf22e8998729487cdbc9fa592b80e390f14 100644 (file)
@@ -55,7 +55,7 @@
 %type  <node>          simple_stmt osimple_stmt range_stmt semi_stmt
 %type  <node>          expr uexpr pexpr expr_list oexpr oexpr_list expr_list_r
 %type  <node>          exprsym3_list_r exprsym3
-%type  <node>          name onew_name new_name new_name_list_r new_field
+%type  <node>          name labelname onew_name new_name new_name_list_r new_field
 %type  <node>          vardcl_list_r vardcl Avardcl Bvardcl
 %type  <node>          interfacedcl_list_r interfacedcl interfacedcl1
 %type  <node>          structdcl_list_r structdcl embed
 %left                  '{'
 %left                  Condition
 
+/*
+ * resolve LPACKAGE vs not in favor of LPACKAGE
+ */
+%left                  NotPackage
+%left                  LPACKAGE
+
+/*
+ * resolve '.' vs not in favor of '.'
+ */
+%left                  NotDot
+%left                  '.'
+
+/*
+ * resolve '(' vs not in favor of '('
+ */
+%left                  NotParen
+%left                  '('
 
 %%
 file:
@@ -107,6 +124,7 @@ file:
        }
 
 package:
+       %prec NotPackage
        {
                yyerror("package statement must be first");
                mkpackage("main");
@@ -776,6 +794,8 @@ pexpr:
        {
                $$ = nod(OLITERAL, N, N);
                $$->val = $1;
+               if($1.ctype == CTSTR)
+                       $$->type = types[TSTRING];
        }
 |      laconst
        {
@@ -999,6 +1019,25 @@ name:
        {
                $$ = oldname($1);
        }
+       /*
+        * this rule introduces 1 reduce/reduce conflict
+        * with the rule lpack: LPACK above.
+        * the reduce/reduce conflict is only with
+        * lookahead '.', in which case the correct
+        * resolution is the lpack rule.  (and it wins
+        * because it is above.)
+        */
+|      LPACK   %prec NotDot
+       {
+               $$ = oldname($1);
+       }
+
+labelname:
+       name
+|      keyword
+       {
+               $$ = oldname($1);
+       }
 
 convtype:
        latype
@@ -1311,6 +1350,7 @@ Afnres:
        }
 
 Bfnres:
+       %prec NotParen
        {
                $$ = N;
        }
@@ -1515,7 +1555,7 @@ Astmt:
        {
                $$ = N;
        }
-|      new_name ':'
+|      labelname ':'
        {
                $$ = nod(OLABEL, $1, N);
        }
@@ -1961,15 +2001,7 @@ lpack:
        }
 
 laconst:
-       LPACK
-       {
-               // for LALR(1) reasons, using laconst works here
-               // but lname does not.  even so, the messages make
-               // more sense saying "var" instead of "const".
-               yyerror("%s is package, not var", $1->name);
-               YYERROR;
-       }
-|      LATYPE
+       LATYPE
        {
                yyerror("%s is type, not var", $1->name);
                YYERROR;
index a0fb124f3f7079031e19dee422a690444d277771..3f7f2638be1f0def5869893dfebdf515c488254f 100644 (file)
@@ -1341,6 +1341,9 @@ mkpackage(char* pkg)
                        s->opackage = package;
                }
 
+       // declare this name as a package
+       lookup(package)->lexical = LPACK;
+
        if(outfile == nil) {
                // BOTCH need to get .6 from backend
                p = strrchr(infile, '/');
similarity index 100%
rename from test/bugs/bug085.go
rename to test/fixedbugs/bug085.go
similarity index 100%
rename from test/bugs/bug129.go
rename to test/fixedbugs/bug129.go
index 6e2ca9a726cbb33866b630bd7fe41c48320fe0bd..bb1e2cb44b44ff72e0c82a0bc616ccf62254b7db 100644 (file)
@@ -42,9 +42,7 @@ errchk: ./convlit.go: unmatched error messages:
 ./convlit.go:11: overflow converting constant to int
 ./convlit.go:12: overflow converting constant to float
 ./convlit.go:8: cannot convert non-integer constant to int
-./convlit.go:9: cannot convert non-integer constant to int
-./convlit.go:11: overflow converting constant to int
-./convlit.go:11: fatal error: too many errors
+./convlit.go:8: fatal error: too many errors
 ==================================================
 
 =========== ./helloworld.go
@@ -117,10 +115,6 @@ abcxyz-abcxyz-abcxyz-abcxyz-abcxyz-abcxyz-abcxyz
 =========== chan/nonblock.go
 PASS
 
-=========== bugs/bug085.go
-bugs/bug085.go:8: P: undefined
-BUG: fails incorrectly
-
 =========== bugs/bug087.go
 bugs/bug087.go:8: illegal combination of literals LEN 9
 bugs/bug087.go:8: illegal combination of literals LEN 9
@@ -146,10 +140,6 @@ BUG: compilation succeeds incorrectly
 =========== bugs/bug125.go
 BUG: errchk: command succeeded unexpectedly:  6g bugs/bug125.go
 
-=========== bugs/bug129.go
-bugs/bug129.go:6: syscall is package, not var
-BUG129
-
 =========== bugs/bug131.go
 BUG: should not compile