OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [g++.old-deja/] [g++.law/] [visibility13.C] - Diff between revs 149 and 154

Only display areas with differences | Details | Blame | View Log

Rev 149 Rev 154
// { dg-do assemble  }
// { dg-do assemble  }
// GROUPS passed visibility
// GROUPS passed visibility
// visibility file
// visibility file
// From: dinh@cs.ucla.edu (Dinh Le)
// From: dinh@cs.ucla.edu (Dinh Le)
// Date:     Mon, 12 Jul 93 22:21:06 -0700
// Date:     Mon, 12 Jul 93 22:21:06 -0700
// Subject:  class, template and their scoping problem
// Subject:  class, template and their scoping problem
// Message-ID: <9307130521.AA18312@oahu.cs.ucla.edu>
// Message-ID: <9307130521.AA18312@oahu.cs.ucla.edu>
#include 
#include 
#include 
#include 
//     ---------------   Array.h  &&  Array.cc   ------------------
//     ---------------   Array.h  &&  Array.cc   ------------------
using namespace std;
using namespace std;
const int ArraySize = 12;
const int ArraySize = 12;
template 
template 
class Array { // { dg-error "" } .struct Array_RC redecl.*
class Array { // { dg-error "" } .struct Array_RC redecl.*
friend class Array_RC;
friend class Array_RC;
public:
public:
    Array(const Type *ar, int sz) { init(ar,sz); }
    Array(const Type *ar, int sz) { init(ar,sz); }
    virtual ~Array() { delete [] ia; }
    virtual ~Array() { delete [] ia; }
    virtual void print(ostream& = cout);
    virtual void print(ostream& = cout);
    virtual Type& operator[](int ix) { return ia[ix]; }
    virtual Type& operator[](int ix) { return ia[ix]; }
private:
private:
    void init(const Type*, int);
    void init(const Type*, int);
    int size;
    int size;
    int *ia;
    int *ia;
};
};
template 
template 
ostream& operator<<( ostream& os, Array& ar )
ostream& operator<<( ostream& os, Array& ar )
{
{
    ar.print(os);
    ar.print(os);
    return os;
    return os;
}
}
template 
template 
void Array::print(ostream& os)
void Array::print(ostream& os)
{
{
    const int lineLength = 12;
    const int lineLength = 12;
    os << "( " << size << " )< ";
    os << "( " << size << " )< ";
    for (int ix = 0; ix < size; ++ix) {
    for (int ix = 0; ix < size; ++ix) {
        if (ix % lineLength == 0 && ix) os << "\n\t";
        if (ix % lineLength == 0 && ix) os << "\n\t";
        os << ia[ ix ];
        os << ia[ ix ];
        if (ix % lineLength != lineLength-1 &&
        if (ix % lineLength != lineLength-1 &&
            ix != size-1)
            ix != size-1)
            os << ", ";
            os << ", ";
    }
    }
    os << " >\n";
    os << " >\n";
}
}
template 
template 
void Array::init(const Type *array, int sz)
void Array::init(const Type *array, int sz)
{
{
    ia = new Type[size = sz];
    ia = new Type[size = sz];
    for (int ix = 0; ix < size; ++ix)
    for (int ix = 0; ix < size; ++ix)
        ia[ix] = (array!=0) ? array[ix] : (Type)0;
        ia[ix] = (array!=0) ? array[ix] : (Type)0;
}
}
//     ---------------   Array_RC.h  &&  Array_RC.cc   ----------------
//     ---------------   Array_RC.h  &&  Array_RC.cc   ----------------
template 
template 
class Array_RC : public Array {
class Array_RC : public Array {
public:
public:
    Array_RC(const Type *ar, int sz);
    Array_RC(const Type *ar, int sz);
    Type& operator[](int ix);
    Type& operator[](int ix);
};
};
template 
template 
Array_RC::Array_RC(const Type *ar, int sz) : Array(ar, sz) {}
Array_RC::Array_RC(const Type *ar, int sz) : Array(ar, sz) {}
template 
template 
Type &Array_RC::operator[](int ix) {
Type &Array_RC::operator[](int ix) {
    assert(ix >= 0 && ix < size);// { dg-error "" } member .size.*
    assert(ix >= 0 && ix < size);// { dg-error "" } member .size.*
    return ia[ix];// { dg-error "" } member .ia.*
    return ia[ix];// { dg-error "" } member .ia.*
}
}
//    -------------------   Test routine   ----------------------
//    -------------------   Test routine   ----------------------
template 
template 
void try_array( Array &iA )
void try_array( Array &iA )
{
{
    cout << "try_array: initial array values:\n";
    cout << "try_array: initial array values:\n";
    cout << iA << endl;
    cout << iA << endl;
}
}
template 
template 
inline void
inline void
try_array( Array_RC &rc )
try_array( Array_RC &rc )
{
{
    try_array( ((Array&)rc) );
    try_array( ((Array&)rc) );
}
}
int main()
int main()
{
{
    static int ia[10] = { 12, 7, 14, 9, 128, 17, 6, 3, 27, 5 };
    static int ia[10] = { 12, 7, 14, 9, 128, 17, 6, 3, 27, 5 };
    Array_RC iA(ia, 10);
    Array_RC iA(ia, 10);
    cout << "template Array_RC class" << endl;
    cout << "template Array_RC class" << endl;
    try_array(iA);
    try_array(iA);
    return 0;
    return 0;
}
}
template class Array_RC;
template class Array_RC;
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.