From: Russ Cox Date: Fri, 26 Sep 2008 18:44:20 +0000 (-0700) Subject: handle negative numeric constants in import. X-Git-Tag: weekly.2009-11-06~3111 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c3d841f5d4d365f531e0a56a0fa2ad55925d2ddb;p=gostls13.git handle negative numeric constants in import. (fixes bugs/bug106) package bug0 export const A = -1 package bug1 import "bug0" R=ken DELTA=21 (19 added, 0 deleted, 2 changed) OCL=15901 CL=15968 --- diff --git a/src/cmd/gc/go.y b/src/cmd/gc/go.y index 049b977192..f84a57afe9 100644 --- a/src/cmd/gc/go.y +++ b/src/cmd/gc/go.y @@ -56,6 +56,8 @@ %type structtype interfacetype convtype %type Achantype Bchantype +%type hidden_constant + %left LOROR %left LANDAND %left LCOMM @@ -1555,11 +1557,11 @@ hidden_import: } /* constants */ -| LCONST hidden_importsym LLITERAL +| LCONST hidden_importsym hidden_constant { doimportc1($2, &$3); } -| LCONST hidden_importsym hidden_importsym LLITERAL +| LCONST hidden_importsym hidden_importsym hidden_constant { doimportc2($2, $3, &$4); } @@ -1616,6 +1618,23 @@ hidden_import: doimport9($2, $3); } +hidden_constant: + LLITERAL +| '-' LLITERAL + { + $$ = $2; + switch($$.ctype){ + case CTINT: + mpnegfix($$.u.xval); + break; + case CTFLT: + mpnegflt($$.u.fval); + break; + default: + yyerror("bad negated constant"); + } + } + isym: sym1 '.' sym2 {