Annotation of researchv10no/cmd/cfront/ooptcfront/demo/comp-tests.c, revision 1.1.1.1

1.1       root        1: #include "check.h"
                      2: 
                      3: 
                      4: /* Compilation tests */
                      5: 
                      6: 
                      7: // There is some trickiness involved in cfront in dealing with member
                      8: // initializations, so check it.
                      9: class f ;
                     10: 
                     11: template <class T> class c {
                     12: public:
                     13:   const T f ;
                     14:   c() ;
                     15: } ;
                     16: 
                     17: template <class T> c<T>::c() : f(1) {}
                     18: 
                     19: c<int> x ;
                     20: 
                     21: 
                     22: // should able to define a class with a name that is identical to a type
                     23: // formal, they are in different scopes
                     24: class T {
                     25: } ;
                     26: T t1 ;
                     27: 
                     28: 
                     29: 
                     30: // it is ok to reference an as yet incomplete template class
                     31: template <class T> class t {
                     32: public:
                     33:   T m ;
                     34:   // references to an as yet incompletely defined template are ok
                     35:   t<double> * d  ;
                     36: 
                     37:   t() {}
                     38: } ;
                     39: 
                     40: t<int> tv ;
                     41: 
                     42: 
                     43: // check forward declarations of a template class
                     44: 
                     45: template <class T> class forward ;
                     46: 
                     47: 
                     48: template <class T> class backward {
                     49: public:
                     50:   T mem ;
                     51: 
                     52:   backward() { mem = 1.0 ; }
                     53: } ;
                     54: 
                     55: // shouldn't have any impact on the earlier template definition.
                     56: template <class T> class backward ;
                     57: 
                     58: 
                     59: class X {
                     60: public:
                     61:   forward<int> * p ;
                     62:   backward<double> *pb ;
                     63: 
                     64:   X() ;
                     65: } ;
                     66: 
                     67: 
                     68: template <class T> class forward {
                     69: public:
                     70:   T mem ;
                     71: 
                     72:   forward() { mem = 2 ; }
                     73: } ;
                     74: 
                     75: 
                     76: template <class T> class forward ;
                     77: 
                     78: X::X() {
                     79:   p = new forward<int> ; pb = new backward<double> ;
                     80:   check((p->mem == 2) && (pb->mem == 1.0)) ;
                     81: } 
                     82: 
                     83: X xv ;
                     84: 
                     85: 
                     86: 
                     87: main () {
                     88:   start_test(__FILE__) ;
                     89:   check(x.f == 1) ;
                     90: 
                     91:   end_test() ;
                     92: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.