1// errorcheck
2
3// Copyright 2017 The Go Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
7// Issue 11674: cmd/compile: does not diagnose constant division by
8// zero
9
10package p
11
12const x complex64 = 0
13const y complex128 = 0
14
15var _ = x / 1e-20
16var _ = x / 1e-50   // GC_ERROR "division by zero"
17var _ = x / 1e-1000 // GC_ERROR "division by zero"
18var _ = x / 1e-20i
19var _ = x / 1e-50i   // GC_ERROR "division by zero"
20var _ = x / 1e-1000i // GC_ERROR "division by zero"
21
22var _ = x / 1e-45 // smallest positive float32
23
24var _ = x / (1e-20 + 1e-20i)
25var _ = x / (1e-50 + 1e-20i)
26var _ = x / (1e-20 + 1e-50i)
27var _ = x / (1e-50 + 1e-50i)     // GC_ERROR "division by zero"
28var _ = x / (1e-1000 + 1e-1000i) // GC_ERROR "division by zero"
29
30var _ = y / 1e-50
31var _ = y / 1e-1000 // GC_ERROR "division by zero"
32var _ = y / 1e-50i
33var _ = y / 1e-1000i // GC_ERROR "division by zero"
34
35var _ = y / 5e-324 // smallest positive float64
36
37var _ = y / (1e-50 + 1e-50)
38var _ = y / (1e-1000 + 1e-50i)
39var _ = y / (1e-50 + 1e-1000i)
40var _ = y / (1e-1000 + 1e-1000i) // GC_ERROR "division by zero"
41