2014-02-07 13:08:32 -06:00
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2013-07-01 05:11:29 -05:00
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
2014-02-07 13:08:32 -06:00
// ignore-tidy-linelength
// ignore-android: FIXME(#10381)
2013-12-13 17:45:08 -06:00
2014-02-06 21:57:09 -06:00
// compile-flags:-g
2014-07-09 07:46:09 -05:00
// === GDB TESTS ===================================================================================
2014-04-24 04:35:48 -05:00
// gdb-command:set print pretty off
// gdb-command:rbreak zzz
// gdb-command:run
// gdb-command:finish
2013-07-01 05:11:29 -05:00
2014-04-24 04:35:48 -05:00
// gdb-command:print packed
// gdb-check:$1 = {x = 123, y = 234, z = 345}
2013-07-01 05:11:29 -05:00
2014-04-24 04:35:48 -05:00
// gdb-command:print packedInPacked
// gdb-check:$2 = {a = 1111, b = {x = 2222, y = 3333, z = 4444}, c = 5555, d = {x = 6666, y = 7777, z = 8888}}
2013-07-01 05:11:29 -05:00
2014-04-24 04:35:48 -05:00
// gdb-command:print packedInUnpacked
// gdb-check:$3 = {a = -1111, b = {x = -2222, y = -3333, z = -4444}, c = -5555, d = {x = -6666, y = -7777, z = -8888}}
2013-07-01 05:11:29 -05:00
2014-04-24 04:35:48 -05:00
// gdb-command:print unpackedInPacked
// gdb-check:$4 = {a = 987, b = {x = 876, y = 765, z = 654}, c = {x = 543, y = 432, z = 321}, d = 210}
2013-07-01 05:11:29 -05:00
2014-04-24 04:35:48 -05:00
// gdb-command:print packedInPackedWithDrop
// gdb-check:$5 = {a = 11, b = {x = 22, y = 33, z = 44}, c = 55, d = {x = 66, y = 77, z = 88}}
2013-07-01 05:11:29 -05:00
2014-04-24 04:35:48 -05:00
// gdb-command:print packedInUnpackedWithDrop
// gdb-check:$6 = {a = -11, b = {x = -22, y = -33, z = -44}, c = -55, d = {x = -66, y = -77, z = -88}}
2013-07-01 05:11:29 -05:00
2014-04-24 04:35:48 -05:00
// gdb-command:print unpackedInPackedWithDrop
// gdb-check:$7 = {a = 98, b = {x = 87, y = 76, z = 65}, c = {x = 54, y = 43, z = 32}, d = 21}
2013-07-01 05:11:29 -05:00
2014-04-24 04:35:48 -05:00
// gdb-command:print deeplyNested
// gdb-check:$8 = {a = {a = 1, b = {x = 2, y = 3, z = 4}, c = 5, d = {x = 6, y = 7, z = 8}}, b = {a = 9, b = {x = 10, y = 11, z = 12}, c = {x = 13, y = 14, z = 15}, d = 16}, c = {a = 17, b = {x = 18, y = 19, z = 20}, c = 21, d = {x = 22, y = 23, z = 24}}, d = {a = 25, b = {x = 26, y = 27, z = 28}, c = 29, d = {x = 30, y = 31, z = 32}}, e = {a = 33, b = {x = 34, y = 35, z = 36}, c = {x = 37, y = 38, z = 39}, d = 40}, f = {a = 41, b = {x = 42, y = 43, z = 44}, c = 45, d = {x = 46, y = 47, z = 48}}}
2013-07-01 05:11:29 -05:00
2014-07-09 07:46:09 -05:00
// === LLDB TESTS ==================================================================================
// lldb-command:run
// lldb-command:print packed
// lldb-check:[...]$0 = Packed { x: 123, y: 234, z: 345 }
// lldb-command:print packedInPacked
// lldb-check:[...]$1 = PackedInPacked { a: 1111, b: Packed { x: 2222, y: 3333, z: 4444 }, c: 5555, d: Packed { x: 6666, y: 7777, z: 8888 } }
// lldb-command:print packedInUnpacked
// lldb-check:[...]$2 = PackedInUnpacked { a: -1111, b: Packed { x: -2222, y: -3333, z: -4444 }, c: -5555, d: Packed { x: -6666, y: -7777, z: -8888 } }
// lldb-command:print unpackedInPacked
// lldb-check:[...]$3 = UnpackedInPacked { a: 987, b: Unpacked { x: 876, y: 765, z: 654 }, c: Unpacked { x: 543, y: 432, z: 321 }, d: 210 }
// lldb-command:print packedInPackedWithDrop
// lldb-check:[...]$4 = PackedInPackedWithDrop { a: 11, b: Packed { x: 22, y: 33, z: 44 }, c: 55, d: Packed { x: 66, y: 77, z: 88 } }
// lldb-command:print packedInUnpackedWithDrop
// lldb-check:[...]$5 = PackedInUnpackedWithDrop { a: -11, b: Packed { x: -22, y: -33, z: -44 }, c: -55, d: Packed { x: -66, y: -77, z: -88 } }
// lldb-command:print unpackedInPackedWithDrop
// lldb-check:[...]$6 = UnpackedInPackedWithDrop { a: 98, b: Unpacked { x: 87, y: 76, z: 65 }, c: Unpacked { x: 54, y: 43, z: 32 }, d: 21 }
// lldb-command:print deeplyNested
// lldb-check:[...]$7 = DeeplyNested { a: PackedInPacked { a: 1, b: Packed { x: 2, y: 3, z: 4 }, c: 5, d: Packed { x: 6, y: 7, z: 8 } }, b: UnpackedInPackedWithDrop { a: 9, b: Unpacked { x: 10, y: 11, z: 12 }, c: Unpacked { x: 13, y: 14, z: 15 }, d: 16 }, c: PackedInUnpacked { a: 17, b: Packed { x: 18, y: 19, z: 20 }, c: 21, d: Packed { x: 22, y: 23, z: 24 } }, d: PackedInUnpackedWithDrop { a: 25, b: Packed { x: 26, y: 27, z: 28 }, c: 29, d: Packed { x: 30, y: 31, z: 32 } }, e: UnpackedInPacked { a: 33, b: Unpacked { x: 34, y: 35, z: 36 }, c: Unpacked { x: 37, y: 38, z: 39 }, d: 40 }, f: PackedInPackedWithDrop { a: 41, b: Packed { x: 42, y: 43, z: 44 }, c: 45, d: Packed { x: 46, y: 47, z: 48 } } }
2014-04-14 10:30:31 -05:00
#![ allow(unused_variable) ]
2013-08-17 10:37:42 -05:00
2014-05-27 01:56:52 -05:00
#[ repr(packed) ]
2013-07-01 05:11:29 -05:00
struct Packed {
x : i16 ,
y : i32 ,
z : i64
}
impl Drop for Packed {
2013-09-16 20:18:07 -05:00
fn drop ( & mut self ) { }
2013-07-01 05:11:29 -05:00
}
2014-05-27 01:56:52 -05:00
#[ repr(packed) ]
2013-07-01 05:11:29 -05:00
struct PackedInPacked {
a : i32 ,
b : Packed ,
c : i64 ,
d : Packed
}
struct PackedInUnpacked {
a : i32 ,
b : Packed ,
c : i64 ,
d : Packed
}
struct Unpacked {
x : i64 ,
y : i32 ,
z : i16
}
impl Drop for Unpacked {
2013-09-16 20:18:07 -05:00
fn drop ( & mut self ) { }
2013-07-01 05:11:29 -05:00
}
2014-05-27 01:56:52 -05:00
#[ repr(packed) ]
2013-07-01 05:11:29 -05:00
struct UnpackedInPacked {
a : i16 ,
b : Unpacked ,
c : Unpacked ,
d : i64
}
2014-05-27 01:56:52 -05:00
#[ repr(packed) ]
2013-07-01 05:11:29 -05:00
struct PackedInPackedWithDrop {
a : i32 ,
b : Packed ,
c : i64 ,
d : Packed
}
impl Drop for PackedInPackedWithDrop {
2013-09-16 20:18:07 -05:00
fn drop ( & mut self ) { }
2013-07-01 05:11:29 -05:00
}
struct PackedInUnpackedWithDrop {
a : i32 ,
b : Packed ,
c : i64 ,
d : Packed
}
impl Drop for PackedInUnpackedWithDrop {
2013-09-16 20:18:07 -05:00
fn drop ( & mut self ) { }
2013-07-01 05:11:29 -05:00
}
2014-05-27 01:56:52 -05:00
#[ repr(packed) ]
2013-07-01 05:11:29 -05:00
struct UnpackedInPackedWithDrop {
a : i16 ,
b : Unpacked ,
c : Unpacked ,
d : i64
}
impl Drop for UnpackedInPackedWithDrop {
2013-09-16 20:18:07 -05:00
fn drop ( & mut self ) { }
2013-07-01 05:11:29 -05:00
}
struct DeeplyNested {
a : PackedInPacked ,
b : UnpackedInPackedWithDrop ,
c : PackedInUnpacked ,
d : PackedInUnpackedWithDrop ,
e : UnpackedInPacked ,
f : PackedInPackedWithDrop
}
fn main ( ) {
let packed = Packed { x : 123 , y : 234 , z : 345 } ;
let packedInPacked = PackedInPacked {
a : 1111 ,
b : Packed { x : 2222 , y : 3333 , z : 4444 } ,
c : 5555 ,
d : Packed { x : 6666 , y : 7777 , z : 8888 }
} ;
let packedInUnpacked = PackedInUnpacked {
a : - 1111 ,
b : Packed { x : - 2222 , y : - 3333 , z : - 4444 } ,
c : - 5555 ,
d : Packed { x : - 6666 , y : - 7777 , z : - 8888 }
} ;
let unpackedInPacked = UnpackedInPacked {
a : 987 ,
b : Unpacked { x : 876 , y : 765 , z : 654 } ,
c : Unpacked { x : 543 , y : 432 , z : 321 } ,
d : 210
} ;
let packedInPackedWithDrop = PackedInPackedWithDrop {
a : 11 ,
b : Packed { x : 22 , y : 33 , z : 44 } ,
c : 55 ,
d : Packed { x : 66 , y : 77 , z : 88 }
} ;
let packedInUnpackedWithDrop = PackedInUnpackedWithDrop {
a : - 11 ,
b : Packed { x : - 22 , y : - 33 , z : - 44 } ,
c : - 55 ,
d : Packed { x : - 66 , y : - 77 , z : - 88 }
} ;
let unpackedInPackedWithDrop = UnpackedInPackedWithDrop {
a : 98 ,
b : Unpacked { x : 87 , y : 76 , z : 65 } ,
c : Unpacked { x : 54 , y : 43 , z : 32 } ,
d : 21
} ;
let deeplyNested = DeeplyNested {
a : PackedInPacked {
a : 1 ,
b : Packed { x : 2 , y : 3 , z : 4 } ,
c : 5 ,
d : Packed { x : 6 , y : 7 , z : 8 }
} ,
b : UnpackedInPackedWithDrop {
a : 9 ,
b : Unpacked { x : 10 , y : 11 , z : 12 } ,
c : Unpacked { x : 13 , y : 14 , z : 15 } ,
d : 16
} ,
c : PackedInUnpacked {
a : 17 ,
b : Packed { x : 18 , y : 19 , z : 20 } ,
c : 21 ,
d : Packed { x : 22 , y : 23 , z : 24 }
} ,
d : PackedInUnpackedWithDrop {
a : 25 ,
b : Packed { x : 26 , y : 27 , z : 28 } ,
c : 29 ,
d : Packed { x : 30 , y : 31 , z : 32 }
} ,
e : UnpackedInPacked {
a : 33 ,
b : Unpacked { x : 34 , y : 35 , z : 36 } ,
c : Unpacked { x : 37 , y : 38 , z : 39 } ,
d : 40
} ,
f : PackedInPackedWithDrop {
a : 41 ,
b : Packed { x : 42 , y : 43 , z : 44 } ,
c : 45 ,
d : Packed { x : 46 , y : 47 , z : 48 }
}
} ;
2014-07-09 07:46:09 -05:00
zzz ( ) ; // #break
2013-07-01 05:11:29 -05:00
}
2013-08-17 10:37:42 -05:00
fn zzz ( ) { ( ) }