Commit 994de9dd by Martin v. Löwis

New test cases.

From-SVN: r25498
parent 282e5df8
// ecgs-bugs 1999-02-22 14:21, Stefan Schwarzer
// sts@ica1.uni-stuttgart.de
// this code should compile quietly
class CArray
{
public:
operator double* (){ return a; }
// works if we comment this line:
operator double* () const { return const_cast<double *>(a); }
private:
double a[2];
};
int main(){
CArray a;
double *pa = a + 1; // gets bogus error - should convert
return 0;
}
// egcs-bugs 999-02-22 14:26 Stefan Schwarzer
// sts@ica1.uni-stuttgart.de
// should compile and return 0
template <int N>
struct Outer{
struct Inner{
Inner(int n): sum(n){}
typename Outer<N-1>::Inner operator[](int n) const
{ return Outer<N-1>::Inner(sum + n); }
int sum;
};
typename Outer<N-1>::Inner operator[](int n) const
{ return Outer<N-1>::Inner(n); }
};
// specializations for N==1
template<>
struct Outer<1> {
struct Inner {
Inner(int n): sum(n){}
int operator[](int n) const
{ return sum+n; }
int sum;
};
int operator[](int n) const
{ return n; }
};
int main()
{
Outer<1> sum1;
//std::cout << sum1[1] << "\n";
Outer<2> sum2;
//std::cout << sum2[1][1] << "\n";
return sum1[1] + sum2[1][1] - 3;
}
// excess errors test - XFAIL
// ecgs-bugs 1999-02-22 14:26 Stefan Schwarzer
// sts@ica1.uni-stuttgart.de
// partial ordering problem in egcs <= 1.1.1
template<class T>
int f(T &){ return 1; }
template<class T>
int f( T[] ){ return 0; }
int main(){
int d[] ={2};
return f(d);
}
// Special g++ Options: -O2
// egcs-bugs 1999-02-22 14:24 Stefan Schwarzer
// sts@ica1.uni-stuttgart.de
// optimizer problem in egcs <= 1.1.1
struct XTVec{
XTVec(){x[0]=x[1] =x[2] =0;}
XTVec(int ax,int y=0.,int z=0.){x[0]=ax;x[1]=y; x[2]=z; }
int& operator[](int);
int x[3];
};
inline
int & XTVec::operator[](int i){
return x[i];
}
inline
XTVec& operator+=(XTVec& lhs, XTVec& rhs){
lhs[0]+=rhs[0];
lhs[1]+=rhs[1];
lhs[2]+=rhs[2];
return lhs;
}
inline
XTVec operator+(XTVec& lhs, XTVec& rhs){
XTVec result(lhs);
return result += rhs;
}
int main()
{
XTVec ur(4.,0.,1.);
XTVec ll(0.,2.,0.);
XTVec initsum(ur + ll);
// sum of components should be 7
return (initsum[0] + initsum[1] + initsum[2] - 7);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment