New test cases.
authorMartin v. Löwis <loewis@gcc.gnu.org>
Sun, 28 Feb 1999 09:07:01 +0000 (09:07 +0000)
committerMartin v. Löwis <loewis@gcc.gnu.org>
Sun, 28 Feb 1999 09:07:01 +0000 (09:07 +0000)
From-SVN: r25498

gcc/testsuite/g++.old-deja/g++.martin/sts_conv.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.martin/sts_iarr.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.martin/sts_partial.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.martin/sts_vectini.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.old-deja/g++.martin/sts_conv.C b/gcc/testsuite/g++.old-deja/g++.martin/sts_conv.C
new file mode 100644 (file)
index 0000000..4a3a436
--- /dev/null
@@ -0,0 +1,24 @@
+// 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; 
+}
+
+
+
+
+
diff --git a/gcc/testsuite/g++.old-deja/g++.martin/sts_iarr.C b/gcc/testsuite/g++.old-deja/g++.martin/sts_iarr.C
new file mode 100644 (file)
index 0000000..c05fb16
--- /dev/null
@@ -0,0 +1,45 @@
+// 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;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.martin/sts_partial.C b/gcc/testsuite/g++.old-deja/g++.martin/sts_partial.C
new file mode 100644 (file)
index 0000000..c2dc941
--- /dev/null
@@ -0,0 +1,15 @@
+// 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);
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.martin/sts_vectini.C b/gcc/testsuite/g++.old-deja/g++.martin/sts_vectini.C
new file mode 100644 (file)
index 0000000..56f7a1c
--- /dev/null
@@ -0,0 +1,41 @@
+// 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);
+}