* gdb.cp/class2.cc (empty): New class.
authorJoel Brobecker <brobecker@gnat.com>
Thu, 26 Feb 2004 20:22:44 +0000 (20:22 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Thu, 26 Feb 2004 20:22:44 +0000 (20:22 +0000)
        (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
gdb/testsuite/gdb.cp/class2.cc
gdb/testsuite/gdb.cp/class2.exp

index 2e16c4ad871c40e7d0e5fcbc85fb5b6f1cea579e..49822c6baaedcca42bb12734d253a2418691218c 100644 (file)
@@ -1,3 +1,10 @@
+2004-02-26  J. Brobecker  <brobecker@gnat.com>
+
+       * 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  <jjohnstn@redhat.com>
 
        * gdb.base/langs.exp: Update query string to match the
index 34263c8843e06091d7d149f94586aa0374a42729..b4aa20a0df134974dd85933da1c7fb7b3bd76722 100644 (file)
@@ -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 = &alpha; refer (aap);
   abp = &beta;  refer (abp);
   bbp = &beta;  refer (bbp);
+  refer (&e);
 
   return 0;  // marker return 0
 } // marker close brace
index 9d5534566d2876bb9fef3538d20711d12e0dae1d..e3f63b08eaefdf0162fdf75fed44e7110809cd5c 100644 (file)
@@ -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" "= \{<No data fields>\}" "print object with no data fields"
This page took 0.03047 seconds and 4 git commands to generate.