-// Build don't link:
+// { dg-do assemble }
// GROUPS passed visibility
// visibility file
// From: dinh@cs.ucla.edu (Dinh Le)
// Subject: class, template and their scoping problem
// Message-ID: <9307130521.AA18312@oahu.cs.ucla.edu>
-#include <iostream.h>
-#include <assert.h>
+#include <iostream>
+#include <cassert>
// --------------- Array.h && Array.cc ------------------
+using namespace std;
+
const int ArraySize = 12;
template <class Type>
-class Array { // ERROR - .struct Array_RC redecl.*
+class Array { // { dg-error "" } .struct Array_RC redecl.*
friend class Array_RC;
public:
Array(const Type *ar, int sz) { init(ar,sz); }
virtual Type& operator[](int ix) { return ia[ix]; }
private:
void init(const Type*, int);
- int size; // ERROR - private
- int *ia; // ERROR - private
+ int size;
+ int *ia;
};
template <class Type>
// --------------- Array_RC.h && Array_RC.cc ----------------
template <class Type>
-class Array_RC : public Array<Type> {// ERROR - previous declaration.*
+class Array_RC : public Array<Type> {
public:
Array_RC(const Type *ar, int sz);
Type& operator[](int ix);
template <class Type>
Type &Array_RC<Type>::operator[](int ix) {
- assert(ix >= 0 && ix < size);// ERROR - member .size.*
- return ia[ix];// ERROR - member .ia.*
+ assert(ix >= 0 && ix < size);// { dg-error "" } member .size.*
+ return ia[ix];// { dg-error "" } member .ia.*
}
// ------------------- Test routine ----------------------
int main()
{
static int ia[10] = { 12, 7, 14, 9, 128, 17, 6, 3, 27, 5 };
- Array_RC<int> iA(ia, 10);// ERROR - instantiated from here
+ Array_RC<int> iA(ia, 10);
cout << "template Array_RC class" << endl;
try_array(iA);