From 98f9cd2d31788e025ca3e07f4fce5c09c68f2801 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Thu, 26 Feb 2004 20:22:44 +0000 Subject: [PATCH] * gdb.cp/class2.cc (empty): New class. (refer): New function. (main): Declare an object of type empty and use it. * gdb.cp/class2.exp: Print the value of an object of type empty. --- gdb/testsuite/ChangeLog | 7 +++++++ gdb/testsuite/gdb.cp/class2.cc | 10 ++++++++++ gdb/testsuite/gdb.cp/class2.exp | 6 +++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 2e16c4ad871..49822c6baae 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2004-02-26 J. Brobecker + + * gdb.cp/class2.cc (empty): New class. + (refer): New function. + (main): Declare an object of type empty and use it. + * gdb.cp/class2.exp: Print the value of an object of type empty. + 2004-02-26 Jeff Johnston * gdb.base/langs.exp: Update query string to match the diff --git a/gdb/testsuite/gdb.cp/class2.cc b/gdb/testsuite/gdb.cp/class2.cc index 34263c8843e..b4aa20a0df1 100644 --- a/gdb/testsuite/gdb.cp/class2.cc +++ b/gdb/testsuite/gdb.cp/class2.cc @@ -48,10 +48,19 @@ void refer (A *) ; } +struct empty {}; + +// Stop the compiler from optimizing away data. +void refer (empty *) +{ + ; +} + int main (void) { A alpha, *aap, *abp; B beta, *bbp; + empty e; alpha.a1 = 100; beta.a1 = 200; beta.b1 = 201; beta.b2 = 202; @@ -59,6 +68,7 @@ int main (void) aap = α refer (aap); abp = β refer (abp); bbp = β refer (bbp); + refer (&e); return 0; // marker return 0 } // marker close brace diff --git a/gdb/testsuite/gdb.cp/class2.exp b/gdb/testsuite/gdb.cp/class2.exp index 9d5534566d2..e3f63b08eae 100644 --- a/gdb/testsuite/gdb.cp/class2.exp +++ b/gdb/testsuite/gdb.cp/class2.exp @@ -1,4 +1,4 @@ -# Copyright 2003 Free Software Foundation, Inc. +# Copyright 2003, 2004 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -113,3 +113,7 @@ gdb_test_multiple "print * abp" "print * abp at marker return 0, s-p-o off" { gdb_test "print * (B *) abp" \ "= {.*a1 = 200.*b1 = 201.*b2 = 202}" \ "print * (B *) abp at marker return 0" + +# Printing the value of an object containing no data fields: + +gdb_test "p e" "= \{\}" "print object with no data fields" -- 2.30.2