]> Cypherpunks repositories - gostls13.git/commitdiff
fix handling of floating point zero constant 0p+0
authorRuss Cox <rsc@golang.org>
Thu, 4 Jun 2009 18:06:37 +0000 (11:06 -0700)
committerRuss Cox <rsc@golang.org>
Thu, 4 Jun 2009 18:06:37 +0000 (11:06 -0700)
R=r
DELTA=25  (25 added, 0 deleted, 0 changed)
OCL=29875
CL=29875

src/cmd/gc/lex.c
test/fixedbugs/bug160.dir/x.go [new file with mode: 0644]
test/fixedbugs/bug160.dir/y.go [new file with mode: 0644]
test/fixedbugs/bug160.go [new file with mode: 0644]

index e67f8f572b0587c73c4ce8aea0a8ba32deb9f0ad..51e6534e122e209d8e87c882f39ca5f99c28cbf1 100644 (file)
@@ -807,6 +807,9 @@ tnum:
                }
        }
 
+       if(c == 'p')    // 0p begins floating point zero
+               goto casep;
+
        c1 = 0;
        for(;;) {
                if(!isdigit(c))
diff --git a/test/fixedbugs/bug160.dir/x.go b/test/fixedbugs/bug160.dir/x.go
new file mode 100644 (file)
index 0000000..bd52c6c
--- /dev/null
@@ -0,0 +1,8 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package x
+
+const Zero = 0.0
+const Ten = 10.0
diff --git a/test/fixedbugs/bug160.dir/y.go b/test/fixedbugs/bug160.dir/y.go
new file mode 100644 (file)
index 0000000..1c8d353
--- /dev/null
@@ -0,0 +1,19 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import "os"
+import "x"
+
+func main() {
+       if x.Zero != 0 {
+               println("x.Zero = ", x.Zero);
+               os.Exit(1);
+       }
+       if x.Ten != 10 {
+               println("x.Ten = ", x.Ten);
+               os.Exit(1);
+       }
+}
diff --git a/test/fixedbugs/bug160.go b/test/fixedbugs/bug160.go
new file mode 100644 (file)
index 0000000..0ae9d4e
--- /dev/null
@@ -0,0 +1,7 @@
+// $G $D/bug160.dir/x.go && $G $D/bug160.dir/y.go && $L y.$A x.$A && ./$A.out
+
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+nothing to see here