From patchwork Tue Aug 31 17:11:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 63297 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 0945BB714B for ; Wed, 1 Sep 2010 03:11:43 +1000 (EST) Received: (qmail 25145 invoked by alias); 31 Aug 2010 17:11:40 -0000 Received: (qmail 25129 invoked by uid 22791); 31 Aug 2010 17:11:37 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, TW_CC, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 31 Aug 2010 17:11:30 +0000 Received: from wpaz29.hot.corp.google.com (wpaz29.hot.corp.google.com [172.24.198.93]) by smtp-out.google.com with ESMTP id o7VHBSi5025809 for ; Tue, 31 Aug 2010 10:11:28 -0700 Received: from pzk33 (pzk33.prod.google.com [10.243.19.161]) by wpaz29.hot.corp.google.com with ESMTP id o7VHBQVn021389 for ; Tue, 31 Aug 2010 10:11:27 -0700 Received: by pzk33 with SMTP id 33so5201232pzk.0 for ; Tue, 31 Aug 2010 10:11:26 -0700 (PDT) Received: by 10.142.204.17 with SMTP id b17mr6234717wfg.4.1283274686634; Tue, 31 Aug 2010 10:11:26 -0700 (PDT) Received: from coign.google.com (dhcp-172-22-124-178.mtv.corp.google.com [172.22.124.178]) by mx.google.com with ESMTPS id r3sm8991840ibk.19.2010.08.31.10.11.24 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 31 Aug 2010 10:11:25 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: [gccgo] Testsuite changes for new type rules Date: Tue, 31 Aug 2010 10:11:23 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org The new type rules require some changes to the testsuite. This patch implements them. Committed to gccgo branch. Ian Index: gcc/testsuite/go.test/test/convert3.go =================================================================== --- gcc/testsuite/go.test/test/convert3.go (revision 162368) +++ gcc/testsuite/go.test/test/convert3.go (working copy) @@ -13,13 +13,14 @@ var d1 chan<- int = c var d2 = (chan<- int)(c) var e *[4]int -var f1 []int = e -var f2 = []int(e) +var f1 []int = e[0:] +var f2 = []int(e[0:]) var g = []int(nil) -type H *[4]int +type H []int type J []int + var h H -var j1 J = h // ERROR "compat|illegal|cannot|cannot" +var j1 J = h // ERROR "compat|illegal|cannot" var j2 = J(h) Index: gcc/testsuite/go.test/test/ken/array.go =================================================================== --- gcc/testsuite/go.test/test/ken/array.go (revision 162368) +++ gcc/testsuite/go.test/test/ken/array.go (working copy) @@ -81,8 +81,8 @@ func testpfpf() { // call ptr dynamic with ptr fixed from new func testpdpf1() { a := new([40]int) - setpd(a) - res(sumpd(a), 0, 40) + setpd(a[0:]) + res(sumpd(a[0:]), 0, 40) b := (*a)[5:30] res(sumpd(b), 5, 30) @@ -92,8 +92,8 @@ func testpdpf1() { func testpdpf2() { var a [80]int - setpd(&a) - res(sumpd(&a), 0, 80) + setpd(a[0:]) + res(sumpd(a[0:]), 0, 80) } // generate bounds error with ptr dynamic Index: gcc/testsuite/go.test/test/ken/slicearray.go =================================================================== --- gcc/testsuite/go.test/test/ken/slicearray.go (revision 162368) +++ gcc/testsuite/go.test/test/ken/slicearray.go (working copy) @@ -16,12 +16,12 @@ var t int func main() { lb = 0 hb = 10 - by = &bx + by = bx[0:] tstb() lb = 0 hb = 10 - fy = &fx + fy = fx[0:] tstf() // width 1 (byte) Index: gcc/testsuite/go.test/test/ken/string.go =================================================================== --- gcc/testsuite/go.test/test/ken/string.go (revision 162368) +++ gcc/testsuite/go.test/test/ken/string.go (working copy) @@ -88,7 +88,7 @@ func main() { z1[0] = 'a' z1[1] = 'b' z1[2] = 'c' - c = string(&z1) + c = string(z1[0:]) if c != "abc" { print("create byte array ", c) panic("fail") @@ -99,7 +99,7 @@ func main() { z2[0] = 'a' z2[1] = '\u1234' z2[2] = 'c' - c = string(&z2) + c = string(z2[0:]) if c != "a\u1234c" { print("create int array ", c) panic("fail") @@ -110,7 +110,7 @@ func main() { z3[0] = 'a' z3[1] = 'b' z3[2] = 'c' - c = string(z3) + c = string(z3[0:]) if c != "abc" { print("create array pointer ", c) panic("fail") Index: gcc/testsuite/go.test/test/fixedbugs/bug102.go =================================================================== --- gcc/testsuite/go.test/test/fixedbugs/bug102.go (revision 162368) +++ gcc/testsuite/go.test/test/fixedbugs/bug102.go (working copy) @@ -7,19 +7,20 @@ package main func main() { - var b [0]byte; - s := string(&b); // out of bounds trap + var b [0]byte + s := string(b[0:]) // out of bounds trap if s != "" { panic("bad convert") } - var b1 = [5]byte{'h', 'e', 'l', 'l', 'o'}; - if string(&b1) != "hello" { + var b1 = [5]byte{'h', 'e', 'l', 'l', 'o'} + if string(b1[0:]) != "hello" { panic("bad convert 1") } - var b2 = make([]byte, 5); - for i := 0; i < 5; i++ { b2[i] = b1[i] } + var b2 = make([]byte, 5) + for i := 0; i < 5; i++ { + b2[i] = b1[i] + } if string(b2) != "hello" { panic("bad convert 2") } } - Index: gcc/testsuite/go.test/test/fixedbugs/bug045.go =================================================================== --- gcc/testsuite/go.test/test/fixedbugs/bug045.go (revision 162368) +++ gcc/testsuite/go.test/test/fixedbugs/bug045.go (working copy) @@ -13,7 +13,7 @@ type T struct { func main() { var ta []*T; - ta = new([1]*T); + ta = new([1]*T)[0:]; ta[0] = nil; } /* Index: gcc/testsuite/go.test/test/fixedbugs/bug146.go =================================================================== --- gcc/testsuite/go.test/test/fixedbugs/bug146.go (revision 162368) +++ gcc/testsuite/go.test/test/fixedbugs/bug146.go (working copy) @@ -9,7 +9,7 @@ package main func main() { type Slice []byte; a := [...]byte{ 0 }; - b := Slice(&a); // This should be OK. + b := Slice(a[0:]); // This should be OK. c := Slice(a); // ERROR "invalid|illegal|cannot" _, _ = b, c; } Index: gcc/testsuite/go.test/test/fixedbugs/bug059.go =================================================================== --- gcc/testsuite/go.test/test/fixedbugs/bug059.go (revision 162368) +++ gcc/testsuite/go.test/test/fixedbugs/bug059.go (working copy) @@ -25,7 +25,7 @@ func main() { as := new([2]string); as[0] = "0"; as[1] = "1"; - m["0"] = as; + m["0"] = as[0:]; a := m["0"]; a[0] = "x"; Index: gcc/testsuite/go.test/test/nilptr/arraytoslice.go =================================================================== --- gcc/testsuite/go.test/test/nilptr/arraytoslice.go (revision 162368) +++ gcc/testsuite/go.test/test/nilptr/arraytoslice.go (working copy) @@ -32,5 +32,5 @@ func main() { // usual len and cap, we require the *array -> slice // conversion to do the check. var p *[1<<30]byte = nil; - f(p); // should crash + f(p[0:]); // should crash } Index: gcc/testsuite/go.test/test/nilptr/arraytoslice1.go =================================================================== --- gcc/testsuite/go.test/test/nilptr/arraytoslice1.go (revision 162368) +++ gcc/testsuite/go.test/test/nilptr/arraytoslice1.go (working copy) @@ -28,6 +28,6 @@ func main() { // usual len and cap, we require the *array -> slice // conversion to do the check. var p *[1<<30]byte = nil; - var x []byte = p; // should crash + var x []byte = p[0:]; // should crash _ = x; } Index: gcc/testsuite/go.test/test/nilptr/arraytoslice2.go =================================================================== --- gcc/testsuite/go.test/test/nilptr/arraytoslice2.go (revision 162368) +++ gcc/testsuite/go.test/test/nilptr/arraytoslice2.go (working copy) @@ -30,5 +30,5 @@ func main() { // conversion to do the check. var x []byte; var y = &x; - *y = q; // should crash (uses arraytoslice runtime routine) + *y = q[0:]; // should crash (uses arraytoslice runtime routine) } Index: gcc/testsuite/go.go-torture/execute/array-2.go =================================================================== --- gcc/testsuite/go.go-torture/execute/array-2.go (revision 162076) +++ gcc/testsuite/go.go-torture/execute/array-2.go (working copy) @@ -10,7 +10,7 @@ func fn(a []int) int { func main() { var a [2]int; - if fn(&a) != 2 { + if fn(a[0:]) != 2 { panic(0); } if a[0] != 0 || a[1] != 1 {