summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorjanis <janis@138bc75d-0d04-0410-961f-82ee72b054a4>2002-03-29 21:56:12 +0000
committerjanis <janis@138bc75d-0d04-0410-961f-82ee72b054a4>2002-03-29 21:56:12 +0000
commit71f90aa459f1c45c383c2eb0d97053be642f5c90 (patch)
treea820c83a1ffc2e6ee7b35658e9e5f28d6d9bf6fc /gcc
parent771d21fab6794ddeb9c317b7e6fd7e47ef70985a (diff)
downloadgcc-71f90aa459f1c45c383c2eb0d97053be642f5c90.tar.gz
* g++.dg/dg.exp: Ignore tests in new directories bprob and gcov.
* g++.dg/bprob/bprob.exp: New driver for profile-directed branch ordering tests. * g++.dg/bprob/bprob-1.C: New test. * g++.dg/gcov/gcov.exp: New driver for gcov tests. * g++.dg/gcov/gcov-1.C: New test. * g++.dg/gcov/gcov-1.x: New file. * g++.dg/gcov/gcov-2.C: New test. * g++.dg/gcov/gcov-3.C: New test. * g++.dg/gcov/gcov-3.h: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@51572 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog13
-rw-r--r--gcc/testsuite/g++.dg/bprob/bprob-1.C234
-rw-r--r--gcc/testsuite/g++.dg/bprob/bprob.exp58
-rw-r--r--gcc/testsuite/g++.dg/dg.exp9
-rw-r--r--gcc/testsuite/g++.dg/gcov/gcov-1.C313
-rw-r--r--gcc/testsuite/g++.dg/gcov/gcov-1.x2
-rw-r--r--gcc/testsuite/g++.dg/gcov/gcov-2.C32
-rw-r--r--gcc/testsuite/g++.dg/gcov/gcov-3.C17
-rw-r--r--gcc/testsuite/g++.dg/gcov/gcov-3.h31
-rw-r--r--gcc/testsuite/g++.dg/gcov/gcov.exp44
10 files changed, 750 insertions, 3 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 606df339541..974ec990de5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,16 @@
+2002-03-29 Janis Johnson <janis187@us.ibm.com>
+
+ * g++.dg/dg.exp: Ignore tests in new directories bprob and gcov.
+ * g++.dg/bprob/bprob.exp: New driver for profile-directed branch
+ ordering tests.
+ * g++.dg/bprob/bprob-1.C: New test.
+ * g++.dg/gcov/gcov.exp: New driver for gcov tests.
+ * g++.dg/gcov/gcov-1.C: New test.
+ * g++.dg/gcov/gcov-1.x: New file.
+ * g++.dg/gcov/gcov-2.C: New test.
+ * g++.dg/gcov/gcov-3.C: New test.
+ * g++.dg/gcov/gcov-3.h: New file.
+
2002-03-28 Roger Sayle <roger@eyesopen.com>
* g++.old-deja/g++.other/builtins5.C: New test.
diff --git a/gcc/testsuite/g++.dg/bprob/bprob-1.C b/gcc/testsuite/g++.dg/bprob/bprob-1.C
new file mode 100644
index 00000000000..b1a1de77e98
--- /dev/null
+++ b/gcc/testsuite/g++.dg/bprob/bprob-1.C
@@ -0,0 +1,234 @@
+/* Check that various C constructs (in C++) don't cause problems for
+ * profile-directed block ordering.
+
+ Most of this test is the same as bprob-1.c and gcov-4.c in
+ gcc.misc-tests. The "count" comments are left in to make comparisons
+ easier; they are ignored for this test. */
+
+extern "C" void abort (void);
+
+/* Check for loops. */
+
+int for_val1;
+int for_val2;
+int for_temp;
+
+int
+test_for1 (int n)
+{
+ int i;
+ for_temp = 1; /* count(3) */
+ for (i = 0; i < n; i++)
+ for_temp++; /* count(9) */
+ return for_temp; /* count(3) */
+}
+
+int
+test_for2 (int m, int n, int o)
+{
+ int i, j, k;
+ for_temp = 1; /* count(6) */
+ for (i = 0; i < n; i++)
+ for (j = 0; j < m; j++)
+ for (k = 0; k < o; k++)
+ for_temp++; /* count(81) */
+ return for_temp; /* count(6) */
+}
+
+int
+call_for ()
+{
+ for_val1 += test_for1 (0);
+ for_val1 += test_for1 (2);
+ for_val1 += test_for1 (7);
+
+ for_val2 += test_for2 (0, 0, 0);
+ for_val2 += test_for2 (1, 0, 0);
+ for_val2 += test_for2 (1, 3, 0);
+ for_val2 += test_for2 (1, 3, 1);
+ for_val2 += test_for2 (3, 1, 5);
+ for_val2 += test_for2 (3, 7, 3);
+}
+
+/* Check the use of goto. */
+
+int goto_val;
+
+int
+test_goto1 (int f)
+{
+ if (f) /* count(2) */
+ goto lab1; /* count(1) */
+ return 1; /* count(1) */
+lab1:
+ return 2; /* count(1) */
+}
+
+int
+test_goto2 (int f)
+{
+ int i;
+ for (i = 0; i < 10; i++) /* count(15) */
+ if (i == f) goto lab2; /* count(14) */
+ return 4; /* count(1) */
+lab2:
+ return 8; /* count(1) */
+}
+
+void
+call_goto ()
+{
+ goto_val += test_goto1 (0);
+ goto_val += test_goto1 (1);
+ goto_val += test_goto2 (3);
+ goto_val += test_goto2 (30);
+}
+
+/* Check nested if-then-else statements. */
+
+int ifelse_val1;
+int ifelse_val2;
+int ifelse_val3;
+
+int
+test_ifelse1 (int i, int j)
+{
+ int result = 0;
+ if (i) /* count(5) */
+ if (j) /* count(3) */
+ result = 4; /* count(3) */
+ else
+ result = 1024;
+ else
+ if (j) /* count(2) */
+ result = 1; /* count(1) */
+ else
+ result = 2; /* count(1) */
+ if (i > j) /* count(5) */
+ result *= 2; /* count(1) */
+ if (i > 10) /* count(5) */
+ if (j > 10) /* count(1) */
+ result *= 4; /* count(1) */
+ return result; /* count(5) */
+}
+
+int
+test_ifelse2 (int i)
+{
+ int result = 0;
+ if (!i) /* count(6) */
+ result = 1; /* count(1) */
+ if (i == 1) /* count(6) */
+ result = 1024;
+ if (i == 2) /* count(6) */
+ result = 2; /* count(3) */
+ if (i == 3) /* count(6) */
+ return 8; /* count(2) */
+ if (i == 4) /* count(4) */
+ return 2048;
+ return result; /* count(4) */
+}
+
+int
+test_ifelse3 (int i, int j)
+{
+ int result = 1;
+ if (i > 10 && j > i && j < 20) /* count(11) */
+ result = 16; /* count(1) */
+ if (i > 20) /* count(11) */
+ if (j > i) /* count(5) */
+ if (j < 30) /* count(2) */
+ result = 32; /* count(1) */
+ if (i == 3 || j == 47 || i == j) /* count(11) */
+ result = 64; /* count(3) */
+ return result; /* count(11) */
+}
+
+void
+call_ifelse ()
+{
+ ifelse_val1 += test_ifelse1 (0, 2);
+ ifelse_val1 += test_ifelse1 (0, 0);
+ ifelse_val1 += test_ifelse1 (1, 2);
+ ifelse_val1 += test_ifelse1 (10, 2);
+ ifelse_val1 += test_ifelse1 (11, 11);
+
+ ifelse_val2 += test_ifelse2 (0);
+ ifelse_val2 += test_ifelse2 (2);
+ ifelse_val2 += test_ifelse2 (2);
+ ifelse_val2 += test_ifelse2 (2);
+ ifelse_val2 += test_ifelse2 (3);
+ ifelse_val2 += test_ifelse2 (3);
+
+ ifelse_val3 += test_ifelse3 (11, 19);
+ ifelse_val3 += test_ifelse3 (25, 27);
+ ifelse_val3 += test_ifelse3 (11, 22);
+ ifelse_val3 += test_ifelse3 (11, 10);
+ ifelse_val3 += test_ifelse3 (21, 32);
+ ifelse_val3 += test_ifelse3 (21, 20);
+ ifelse_val3 += test_ifelse3 (1, 2);
+ ifelse_val3 += test_ifelse3 (32, 31);
+ ifelse_val3 += test_ifelse3 (3, 0);
+ ifelse_val3 += test_ifelse3 (0, 47); /* count(1) */
+ ifelse_val3 += test_ifelse3 (65, 65); /* count(1) */
+}
+
+/* Check switch statements. */
+
+int switch_val, switch_m;
+
+int
+test_switch (int i, int j)
+{
+ int result = 0; /* count(5) */
+
+ switch (i) /* count(5) */
+ {
+ case 1:
+ result = 2; /* count(1) */
+ break;
+ case 2:
+ result = 1024;
+ break;
+ case 3:
+ case 4:
+ if (j == 2) /* count(3) */
+ return 4; /* count(1) */
+ result = 8; /* count(2) */
+ break;
+ default:
+ result = 32; /* count(1) */
+ switch_m++; /* count(1) */
+ break;
+ }
+ return result; /* count(4) */
+}
+
+void
+call_switch ()
+{
+ switch_val += test_switch (1, 0);
+ switch_val += test_switch (3, 0);
+ switch_val += test_switch (3, 2);
+ switch_val += test_switch (4, 0);
+ switch_val += test_switch (16, 0);
+ switch_val += switch_m;
+}
+
+int
+main()
+{
+ call_for ();
+ call_goto ();
+ call_ifelse ();
+ call_switch ();
+ if ((for_val1 != 12)
+ || (for_val2 != 87)
+ || (goto_val != 15)
+ || (ifelse_val1 != 31)
+ || (ifelse_val2 != 23)
+ || (ifelse_val3 != 246)
+ || (switch_val != 55))
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/bprob/bprob.exp b/gcc/testsuite/g++.dg/bprob/bprob.exp
new file mode 100644
index 00000000000..357ed295f00
--- /dev/null
+++ b/gcc/testsuite/g++.dg/bprob/bprob.exp
@@ -0,0 +1,58 @@
+# Copyright (C) 2001, 2002 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Test the functionality of programs compiled with profile-directed block
+# ordering using -fprofile-arcs followed by -fbranch-probabilities.
+
+# The procedures in profopt.exp need these parameters.
+set tool g++
+set profile_option -fprofile-arcs
+set feedback_option -fbranch-probabilities
+set prof_ext da
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+# Override the list defined in profopt.exp.
+set PROFOPT_OPTIONS [list \
+ { -g } \
+ { -O0 } \
+ { -O1 } \
+ { -O2 } \
+ { -O3 } \
+ { -O3 -g } \
+ { -Os } ]
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+# Load support procs.
+load_lib profopt.exp
+
+# Clean up existing .da files.
+profopt-cleanup da
+
+# Main loop.
+foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.C]] {
+ # If we're only testing specific files and this isn't one of them, skip it.
+ if ![runtest_file_p $runtests $src] then {
+ continue
+ }
+
+ profopt-execute $src
+}
diff --git a/gcc/testsuite/g++.dg/dg.exp b/gcc/testsuite/g++.dg/dg.exp
index 169d7225446..b59d302b3ae 100644
--- a/gcc/testsuite/g++.dg/dg.exp
+++ b/gcc/testsuite/g++.dg/dg.exp
@@ -28,10 +28,13 @@ if ![info exists DEFAULT_CXXFLAGS] then {
# Initialize `dg'.
dg-init
-# Gather a list of all tests, excluding those in special/; those are handled
-# well, specially.
+# Gather a list of all tests, with the exception of those in directories
+# that are handled specially.
set all [lsort [find $srcdir/$subdir *.C]]
-set tests [prune [prune $all $srcdir/$subdir/special/*] $srcdir/$subdir/debug/*]
+set tests [prune [prune [prune [prune $all $srcdir/$subdir/special/*] \
+ $srcdir/$subdir/debug/*] \
+ $srcdir/$subdir/gcov/*] \
+ $srcdir/$subdir/bprob/*]
# Main loop.
dg-runtest $tests "" $DEFAULT_CXXFLAGS
diff --git a/gcc/testsuite/g++.dg/gcov/gcov-1.C b/gcc/testsuite/g++.dg/gcov/gcov-1.C
new file mode 100644
index 00000000000..617994401f6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/gcov-1.C
@@ -0,0 +1,313 @@
+/* Check that execution counts and branch probabilities for various C
+ constructs are reported correctly by gcov. */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+extern "C" void abort (void);
+
+int do_something (int i)
+{
+ return i;
+}
+
+/* Check static inline functions. */
+
+int unref_val;
+
+static inline int
+unreferenced (int i, int j)
+{
+ return i - j;
+}
+
+static inline int
+uncalled (int i, int j)
+{
+ return i * j;
+}
+
+static inline int
+called (int i, int j)
+{
+ return i + j; /* count(1) */
+}
+
+void
+call_unref ()
+{
+ if (unref_val) /* count(1) */
+ unref_val = uncalled (1, 2);
+ unref_val = called (unref_val, 4); /* count(1) */
+}
+
+
+/* Check for loops. */
+
+int for_val1;
+int for_val2;
+int for_temp;
+
+int
+test_for1 (int n)
+{
+ int i;
+ for_temp = 1; /* count(3) */
+ for (i = 0; i < n; i++) /* branch(25) */
+ /* branch(end) */
+ for_temp++; /* count(9) */
+ return for_temp; /* count(3) */
+}
+
+int
+test_for2 (int m, int n, int o)
+{
+ int i, j, k;
+ for_temp = 1; /* count(6) */
+ for (i = 0; i < n; i++) /* branch(30) */
+ /* branch(end) */
+ for (j = 0; j < m; j++) /* branch(32) */
+ /* branch(end) */
+ for (k = 0; k < o; k++) /* branch(27) */
+ /* branch(end) */
+ for_temp++; /* count(81) */
+ return for_temp; /* count(6) */
+}
+
+int
+call_for ()
+{
+ for_val1 += test_for1 (0);
+ for_val1 += test_for1 (2);
+ for_val1 += test_for1 (7);
+
+ for_val2 += test_for2 (0, 0, 0);
+ for_val2 += test_for2 (1, 0, 0);
+ for_val2 += test_for2 (1, 3, 0);
+ for_val2 += test_for2 (1, 3, 1);
+ for_val2 += test_for2 (3, 1, 5);
+ for_val2 += test_for2 (3, 7, 3);
+}
+
+/* Check the use of goto. */
+
+int goto_val;
+
+int
+test_goto1 (int f)
+{
+ /* branch(50) */
+ if (f) /* count(2) */
+ /* branch(end) */
+ goto lab1; /* count(1) */
+ return 1; /* count(1) */
+lab1:
+ return 2; /* count(1) */
+}
+
+int
+test_goto2 (int f)
+{
+ int i;
+ /* branch(7) */
+ for (i = 0; i < 10; i++) /* count(15) */
+ /* branch(end) */
+ if (i == f) goto lab2; /* count(14) */
+ return 4; /* count(1) */
+lab2:
+ return 8; /* count(1) */
+}
+
+void
+call_goto ()
+{
+ goto_val += test_goto1 (0);
+ goto_val += test_goto1 (1);
+ goto_val += test_goto2 (3);
+ goto_val += test_goto2 (30);
+}
+
+/* Check nested if-then-else statements. */
+
+int ifelse_val1;
+int ifelse_val2;
+int ifelse_val3;
+
+int
+test_ifelse1 (int i, int j)
+{
+ int result = 0;
+ /* branch(40) */
+ if (i) /* count(5) */
+ /* branch(0) */
+ if (j) /* count(3) */
+ /* branch(end) */
+ result = do_something (4); /* count(3) */
+ else
+ result = do_something (1024);
+ else
+ /* branch(50) */
+ if (j) /* count(2) */
+ /* branch(end) */
+ result = do_something (1); /* count(1) */
+ else
+ result = do_something (2); /* count(1) */
+ /* branch(80) */
+ if (i > j) /* count(5) */
+ /* branch(end) */
+ result = do_something (result*2); /* count(1) */
+ /* branch(80) */
+ if (i > 10) /* count(5) */
+ /* branch(100) */
+ if (j > 10) /* count(1) */
+ /* branch(end) */
+ result = do_something (result*4); /* count(1) */
+ return result; /* count(5) */
+}
+
+int
+test_ifelse2 (int i)
+{
+ int result = 0;
+ /* branch(83) */
+ if (!i) /* count(6) */
+ /* branch(end) */
+ result = do_something (1); /* count(1) */
+ /* branch(100) */
+ if (i == 1) /* count(6) */
+ /* branch(end) */
+ result = do_something (1024);
+ /* branch(50) */
+ if (i == 2) /* count(6) */
+ /* branch(end) */
+ result = do_something (2); /* count(3) */
+ /* branch(67) */
+ if (i == 3) /* count(6) */
+ /* branch(end) */
+ return do_something (8); /* count(2) */
+ /* branch(100) */
+ if (i == 4) /* count(4) */
+ /* branch(end) */
+ return do_something (2048);
+ return result; /* count(4) */
+}
+
+int
+test_ifelse3 (int i, int j)
+{
+ int result = 1;
+ /* branch(27 50 75) */
+ if (i > 10 && j > i && j < 20) /* count(11) */
+ /* branch(end) */
+ result = do_something (16); /* count(1) */
+ /* branch(55) */
+ if (i > 20) /* count(11) */
+ /* branch(60) */
+ if (j > i) /* count(5) */
+ /* branch(50) */
+ if (j < 30) /* count(2) */
+ /* branch(end) */
+ result = do_something (32); /* count(1) */
+ /* branch(9 10 89) */
+ if (i == 3 || j == 47 || i == j) /* count(11) */
+ /* branch(end) */
+ result = do_something (64); /* count(3) */
+ return result; /* count(11) */
+}
+
+void
+call_ifelse ()
+{
+ ifelse_val1 += test_ifelse1 (0, 2);
+ ifelse_val1 += test_ifelse1 (0, 0);
+ ifelse_val1 += test_ifelse1 (1, 2);
+ ifelse_val1 += test_ifelse1 (10, 2);
+ ifelse_val1 += test_ifelse1 (11, 11);
+
+ ifelse_val2 += test_ifelse2 (0);
+ ifelse_val2 += test_ifelse2 (2);
+ ifelse_val2 += test_ifelse2 (2);
+ ifelse_val2 += test_ifelse2 (2);
+ ifelse_val2 += test_ifelse2 (3);
+ ifelse_val2 += test_ifelse2 (3);
+
+ ifelse_val3 += test_ifelse3 (11, 19);
+ ifelse_val3 += test_ifelse3 (25, 27);
+ ifelse_val3 += test_ifelse3 (11, 22);
+ ifelse_val3 += test_ifelse3 (11, 10);
+ ifelse_val3 += test_ifelse3 (21, 32);
+ ifelse_val3 += test_ifelse3 (21, 20);
+ ifelse_val3 += test_ifelse3 (1, 2);
+ ifelse_val3 += test_ifelse3 (32, 31);
+ ifelse_val3 += test_ifelse3 (3, 0);
+ ifelse_val3 += test_ifelse3 (0, 47);
+ ifelse_val3 += test_ifelse3 (65, 65);
+}
+
+/* Check switch statements. */
+
+int switch_val, switch_m;
+
+int
+test_switch (int i, int j)
+{
+ int result = 0; /* count(5) */
+
+ /* branch(80 25) */
+ switch (i) /* count(5) */
+ /* branch(end) */
+ {
+ case 1:
+ result = do_something (2); /* count(1) */
+ break;
+ case 2:
+ result = do_something (1024);
+ break;
+ case 3:
+ case 4:
+ /* branch(67) */
+ if (j == 2) /* count(3) */
+ /* branch(end) */
+ return do_something (4); /* count(1) */
+ result = do_something (8); /* count(2) */
+ break;
+ default:
+ result = do_something (32); /* count(1) */
+ switch_m++; /* count(1) */
+ break;
+ }
+ return result; /* count(4) */
+}
+
+void
+call_switch ()
+{
+ switch_val += test_switch (1, 0);
+ switch_val += test_switch (3, 0);
+ switch_val += test_switch (3, 2);
+ switch_val += test_switch (4, 0);
+ switch_val += test_switch (16, 0);
+ switch_val += switch_m;
+}
+
+int
+main()
+{
+ call_for ();
+ call_goto ();
+ call_ifelse ();
+ call_switch ();
+ call_unref ();
+ if ((for_val1 != 12)
+ || (for_val2 != 87)
+ || (goto_val != 15)
+ || (ifelse_val1 != 31)
+ || (ifelse_val2 != 23)
+ || (ifelse_val3 != 246)
+ || (switch_val != 55)
+ || (unref_val != 4))
+ abort ();
+ return 0;
+}
+
+/* { dg-final { run-gcov -b gcov-1.C } } */
diff --git a/gcc/testsuite/g++.dg/gcov/gcov-1.x b/gcc/testsuite/g++.dg/gcov/gcov-1.x
new file mode 100644
index 00000000000..b01ef42b9d7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/gcov-1.x
@@ -0,0 +1,2 @@
+set gcov_verify_branches 1
+return 0
diff --git a/gcc/testsuite/g++.dg/gcov/gcov-2.C b/gcc/testsuite/g++.dg/gcov/gcov-2.C
new file mode 100644
index 00000000000..66d8af39bce
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/gcov-2.C
@@ -0,0 +1,32 @@
+/* Verify line coverage counts for simple member functions. */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+class C {
+public:
+ C()
+ {
+ i = 0; /* count(1) */
+ }
+ ~C() {}
+ void seti (int j)
+ {
+ i = j; /* count(1) */
+ }
+private:
+ int i;
+};
+
+void foo()
+{
+ C c; /* count(1) */
+ c.seti (1); /* count(1) */
+}
+
+int main()
+{
+ foo(); /* count(1) */
+}
+
+/* { dg-final { run-gcov gcov-2.C } } */
diff --git a/gcc/testsuite/g++.dg/gcov/gcov-3.C b/gcc/testsuite/g++.dg/gcov/gcov-3.C
new file mode 100644
index 00000000000..aff063a4b90
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/gcov-3.C
@@ -0,0 +1,17 @@
+/* Check that gcov doesn't abort when a static object is defined
+ within a header file. */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+#include "gcov-3.h"
+
+extern int foo();
+
+int
+main ()
+{
+ return foo(); /* count(1) */
+}
+
+/* { dg-final { run-gcov gcov-3.C } } */
diff --git a/gcc/testsuite/g++.dg/gcov/gcov-3.h b/gcc/testsuite/g++.dg/gcov/gcov-3.h
new file mode 100644
index 00000000000..1c7ca00dd61
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/gcov-3.h
@@ -0,0 +1,31 @@
+/* Leave unused lines for at least the length of the including source file. */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+struct T {
+ int i;
+ T() { i = 0; }
+};
+
+T t;
+
+int foo()
+{
+ return t.i; /* count(1) */
+}
diff --git a/gcc/testsuite/g++.dg/gcov/gcov.exp b/gcc/testsuite/g++.dg/gcov/gcov.exp
new file mode 100644
index 00000000000..9c06d26434a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/gcov.exp
@@ -0,0 +1,44 @@
+# Copyright (C) 1997, 2001, 2002 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Gcov test driver.
+
+# Load support procs.
+load_lib g++-dg.exp
+load_lib gcov.exp
+
+global GXX_UNDER_TEST
+
+# Find gcov in the same directory as $GXX_UNDER_TEST.
+if { ![is_remote host] && [string match "*/*" [lindex $GXX_UNDER_TEST 0]] } {
+ set GCOV [file dirname [lindex $GXX_UNDER_TEST 0]]/gcov
+} else {
+ set GCOV gcov
+}
+
+# Initialize harness.
+dg-init
+
+# Delete old .da files.
+set files [glob -nocomplain gcov-*.da];
+if { $files != "" } {
+ eval "remote_file build delete $files";
+}
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] "" ""
+
+dg-finish