This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
improve c++ instantiation tests
- From: Richard Henderson <rth at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 27 Mar 2002 17:55:44 -0800
- Subject: improve c++ instantiation tests
These tests were always failing in various places because we'd not
get quite messages we were looking for from the linker. Instead,
I've changed things to scan the assembly for definitions (or lack
thereof) of the appropriate symbols.
r~
* g++.dg/ext/instantiate1.C: Use scan-assembler, not link errors.
* g++.dg/ext/instantiate2.C, g++.dg/ext/instantiate3.C: Likewise;
move from g++.old-deja/g++.ext/.
Index: g++.dg/ext/instantiate1.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/ext/instantiate1.C,v
retrieving revision 1.1
diff -c -p -d -r1.1 instantiate1.C
*** instantiate1.C 2001/07/24 15:08:37 1.1
--- instantiate1.C 2002/03/28 01:48:17
***************
*** 1,5 ****
// Test that 'extern template' suppresses instantiations.
! // { dg-do link }
// { dg-options "" }
template <class T> void f (T) { }
--- 1,5 ----
// Test that 'extern template' suppresses instantiations.
! // { dg-do compile }
// { dg-options "" }
template <class T> void f (T) { }
*************** template <class T> struct A {
*** 11,32 ****
template <class T> void A<T>::f () { }
extern template struct A<int>;
! // { dg-error "void f<int>\\(int\\)" "suppressing f<int>" { target *-*-* } "0" }
void test_f_int () { f(42); }
! // { dg-error "A<int>::f\\(\\)" "suppressing A<int>" { target *-*-* } "0" }
void test_A_int_f () { A<int> a; a.f (); }
! // { dg-bogus "void f<double>\\(double\\)" "f<double>" { target *-*-* } "0" }
void test_f_double () { f (2.0); }
! // { dg-bogus "A<double>::f\\(\\)" "A<double>" { target *-*-* } "0" }
void test_A_double_f () { A<double> b; b.f (); }
-
- int main ()
- {
- test_f_int ();
- test_A_int_f ();
- test_f_double ();
- test_A_double_f ();
- }
--- 11,24 ----
template <class T> void A<T>::f () { }
extern template struct A<int>;
! // { dg-final { scan-assembler-not "\n_?_Z1fIiEvT_(:|\n)" } }
void test_f_int () { f(42); }
! // { dg-final { scan-assembler-not "\n_?_ZN1AIiE1fEv(:|\n)" } }
void test_A_int_f () { A<int> a; a.f (); }
! // { dg-final { scan-assembler "\n_?_Z1fIdEvT_(:|\n)" } }
void test_f_double () { f (2.0); }
! // { dg-final { scan-assembler "\n_?_ZN1AIdE1fEv(:|\n)" } }
void test_A_double_f () { A<double> b; b.f (); }
Index: g++.dg/ext/instantiate2.C
===================================================================
RCS file: instantiate2.C
diff -N instantiate2.C
*** /dev/null Tue May 5 13:32:27 1998
--- instantiate2.C Wed Mar 27 17:48:17 2002
***************
*** 0 ****
--- 1,15 ----
+ // Test that 'static template' instantiates statics.
+ // { dg-do compile }
+ // { dg-options "-fno-implicit-templates" }
+
+ template <class T> struct A {
+ static T t;
+ };
+ template <class T> T A<T>::t = 0;
+ static template struct A<int>;
+
+ // { dg-final { scan-assembler "\n_?_ZN1AIiE1tE(:|\n)" } }
+ void test_int() { A<int>::t = 42; }
+
+ // { dg-final { scan-assembler-not "\n_?_ZN1AIcE1tE(:|\n)" } }
+ void test_char() { A<char>::t = 42; }
Index: g++.dg/ext/instantiate3.C
===================================================================
RCS file: instantiate3.C
diff -N instantiate3.C
*** /dev/null Tue May 5 13:32:27 1998
--- instantiate3.C Wed Mar 27 17:48:17 2002
***************
*** 0 ****
--- 1,14 ----
+ // Test that 'inline template' instantiates the vtable.
+ // { dg-do compile }
+ // { dg-options "-O -fno-implicit-templates" }
+
+ template <class T> struct A {
+ virtual void f () { }
+ };
+ inline template struct A<int>;
+
+ // { dg-final { scan-assembler "\n_?_ZTV1AIiE(:|\n)" } }
+ A<int> a;
+
+ // { dg-final { scan-assembler-not "\n_?_ZTV1AIcE(:|\n)" } }
+ A<char> b;
Index: g++.old-deja/g++.ext/instantiate2.C
===================================================================
RCS file: instantiate2.C
diff -N instantiate2.C
*** /sourceware/cvs-tmp/cvsyy1TnT Wed Mar 27 17:48:22 2002
--- /dev/null Tue May 5 13:32:27 1998
***************
*** 1,27 ****
- // Test that 'static template' instantiates statics.
- // Special g++ Options: -g -fno-implicit-templates
-
- // Ignore the 'ld returned 1' message from collect2.
- // excess errors test - XFAIL *-*-*
-
- template <class T> struct A {
- static T t;
- };
- template <class T> T A<T>::t = 0;
- static template struct A<int>;
-
- // These functions must be defined in a single line, so that, even if
- // constants or pointers are placed in the code section (for example,
- // on the SH), we still get the same line numbers.
-
- void test_int() { A<int>::t = 42; } // gets bogus error
-
- void test_char() { A<char>::t = 42; } // ERROR - not instantiated XFAIL *-*-irix* *-*-hpux*
- // Irix's default linker does not produce line numbers so XFAIL it.
- // Similarly for HP's linker
-
- int main ()
- {
- test_int ();
- test_char ();
- }
--- 0 ----
Index: g++.old-deja/g++.ext/instantiate3.C
===================================================================
RCS file: instantiate3.C
diff -N instantiate3.C
*** /sourceware/cvs-tmp/cvs0I7F6e Wed Mar 27 17:48:22 2002
--- /dev/null Tue May 5 13:32:27 1998
***************
*** 1,20 ****
- // Test that 'inline template' instantiates the vtable.
- // Special g++ Options: -g -O -fno-implicit-templates
-
- // Ignore the 'ld returned 1' message from collect2.
- // excess errors test - XFAIL *-*-*
-
- template <class T> struct A {
- virtual void f () { }
- };
- inline template struct A<int>;
-
- A<int> a; // gets bogus error
- A<char> b; // ERROR - not instantiated XFAIL mips*-*-* *-*-hpux* i?86-pc-cygwin
- // Irix's default linker does not
- // produce line numbers so XFAIL it.
- // Similarly for HPUX.
-
- int main ()
- {
- }
--- 0 ----