From 47ab3d4a42e9ab51c465c4322d2ec233f6324e6b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 15:16:40 +0200 Subject: Adding upstream version 1.18.10. Signed-off-by: Daniel Baumann --- test/ken/ptrvar.go | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 test/ken/ptrvar.go (limited to 'test/ken/ptrvar.go') diff --git a/test/ken/ptrvar.go b/test/ken/ptrvar.go new file mode 100644 index 0000000..d78170c --- /dev/null +++ b/test/ken/ptrvar.go @@ -0,0 +1,54 @@ +// run + +// 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. + +// Test pointers and the . (selector) operator on structs. + +package main + +type x2 struct { a,b,c int; d int; }; +var g1 x2; +var g2 struct { a,b,c int; d x2; }; + +func +main() { + var x int; + var s1 *x2; + var s2 *struct { a,b,c int; d x2; }; + + s1 = &g1; + s2 = &g2; + + s1.a = 1; + s1.b = 2; + s1.c = 3; + s1.d = 5; + + s2.a = 7; + s2.b = 11; + s2.c = 13; + s2.d.a = 17; + s2.d.b = 19; + s2.d.c = 23; + s2.d.d = 20; + + if(s2.d.c != 23) { panic(1); } + if(g2.d.c != 23) { panic(2); } + + x = s1.a + + s1.b + + s1.c + + s1.d + + + s2.a + + s2.b + + s2.c + + s2.d.a + + s2.d.b + + s2.d.c + + s2.d.d; + + if(x != 121) { panic(x); } +} -- cgit v1.2.3