summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-06-04 11:06:37 -0700
committerRuss Cox <rsc@golang.org>2009-06-04 11:06:37 -0700
commitc6fc865604c37da9e711c3b918d060d43c9e65cb (patch)
treeb025b211ca08d2c780ca9807f1975b610b2d5f59
parentb374812d21f15890c82a6b7c535e151cd9f59d79 (diff)
downloadgolang-c6fc865604c37da9e711c3b918d060d43c9e65cb.tar.gz
fix handling of floating point zero constant 0p+0
R=r DELTA=25 (25 added, 0 deleted, 0 changed) OCL=29875 CL=29875
-rw-r--r--src/cmd/gc/lex.c3
-rw-r--r--test/fixedbugs/bug160.dir/x.go8
-rw-r--r--test/fixedbugs/bug160.dir/y.go19
-rw-r--r--test/fixedbugs/bug160.go7
4 files changed, 37 insertions, 0 deletions
diff --git a/src/cmd/gc/lex.c b/src/cmd/gc/lex.c
index e67f8f572..51e6534e1 100644
--- a/src/cmd/gc/lex.c
+++ b/src/cmd/gc/lex.c
@@ -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
index 000000000..bd52c6cc3
--- /dev/null
+++ b/test/fixedbugs/bug160.dir/x.go
@@ -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
index 000000000..1c8d353d7
--- /dev/null
+++ b/test/fixedbugs/bug160.dir/y.go
@@ -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
index 000000000..0ae9d4ec1
--- /dev/null
+++ b/test/fixedbugs/bug160.go
@@ -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