aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/testsuite/g++.dg/debug/debug6.C7
-rw-r--r--gcc/testsuite/g++.dg/debug/debug7.C18
-rw-r--r--gcc/testsuite/g++.dg/opt/nrv4.C23
-rw-r--r--gcc/testsuite/g++.dg/other/ptrmem3.C14
-rw-r--r--gcc/testsuite/g++.dg/template/qualttp21.C17
-rw-r--r--gcc/testsuite/g++.dg/warn/incomplete1.C21
-rw-r--r--gcc/testsuite/g++.dg/warn/noreturn-1.C71
-rw-r--r--gcc/testsuite/g++.old-deja/g++.oliva/linkage1-main.cc13
-rw-r--r--gcc/testsuite/g++.old-deja/g++.oliva/linkage1.C21
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/20020706-1.c50
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/20020706-2.c26
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/simd-1.c7
-rw-r--r--libstdc++-v3/testsuite/20_util/auto_ptr_neg.cc50
-rw-r--r--libstdc++-v3/testsuite/23_containers/map_operators_neg.cc49
-rw-r--r--libstdc++-v3/testsuite/23_containers/set_operators_neg.cc43
-rw-r--r--libstdc++-v3/testsuite/ext/hash_map.cc102
16 files changed, 532 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/debug/debug6.C b/gcc/testsuite/g++.dg/debug/debug6.C
new file mode 100644
index 00000000000..64f121b00ad
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/debug6.C
@@ -0,0 +1,7 @@
+// { dg-do compile }
+
+void foo()
+{
+ int i=1, x[i];
+}
+
diff --git a/gcc/testsuite/g++.dg/debug/debug7.C b/gcc/testsuite/g++.dg/debug/debug7.C
new file mode 100644
index 00000000000..78faa20ff03
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/debug7.C
@@ -0,0 +1,18 @@
+// { dg-do compile }
+
+void f (int);
+
+int
+main() {
+
+ int a = 4;
+ int b = 5;
+ int (*x)[b] = new int[a][b];
+
+ x[2][1] = 7;
+
+ for (int i = 0; i < a; ++i)
+ for (int j = 0; j < b; ++j)
+ f (x[i][j]);
+ delete [] x;
+}
diff --git a/gcc/testsuite/g++.dg/opt/nrv4.C b/gcc/testsuite/g++.dg/opt/nrv4.C
new file mode 100644
index 00000000000..531647d67e1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/nrv4.C
@@ -0,0 +1,23 @@
+// PR optimization/7145
+// Bug: The NRV optimization caused us to lose the initializer for 'ret'.
+// { dg-options -O }
+// { dg-do run }
+
+struct GdkColor {
+ long pixel;
+ short red;
+ short green;
+ short blue;
+};
+
+inline GdkColor mkcolor() {
+ GdkColor ret={0,1,2,3};
+ return ret;
+}
+
+int
+main()
+{
+ GdkColor col=mkcolor();
+ return (col.pixel != 0 || col.red != 1 || col.green != 2 || col.blue != 3);
+}
diff --git a/gcc/testsuite/g++.dg/other/ptrmem3.C b/gcc/testsuite/g++.dg/other/ptrmem3.C
new file mode 100644
index 00000000000..ed6d8757441
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/ptrmem3.C
@@ -0,0 +1,14 @@
+// Bug: The double cast had an TREE_INT_CST_HIGH of 0, while the single
+// cast had -1, so the comparison failed.
+
+// { dg-do run }
+
+struct A { };
+
+typedef int A::* aip;
+typedef long A::* alp;
+
+int main()
+{
+ return ((aip)(alp)0 != (aip)0);
+}
diff --git a/gcc/testsuite/g++.dg/template/qualttp21.C b/gcc/testsuite/g++.dg/template/qualttp21.C
new file mode 100644
index 00000000000..00fcf40c45c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/qualttp21.C
@@ -0,0 +1,17 @@
+// Copyright (C) 2002 Free Software Foundation
+// Contributed by Roger Sayle <roger@eyesopen.com>
+// { dg-do compile }
+
+template <class A>
+class foo {
+ int _foo;
+public:
+ foo() {}
+protected:
+ ~foo() {} // { dg-error "~foo" }
+};
+
+int main()
+{
+ foo<int> a; // { dg-error "context" }
+}
diff --git a/gcc/testsuite/g++.dg/warn/incomplete1.C b/gcc/testsuite/g++.dg/warn/incomplete1.C
new file mode 100644
index 00000000000..f4d074aa085
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/incomplete1.C
@@ -0,0 +1,21 @@
+// { dg-do compile }
+
+// Contributed by Brian Gaeke; public domain.
+
+// 5 If the object being deleted has incomplete class type at the
+// point of deletion and the complete class has a non-trivial
+// destructor or a deallocation function, the behavior is undefined.
+
+// (But the deletion does not constitute an ill-formed program. So the
+// program should nevertheless compile, but it should give a warning.)
+
+class A; // { dg-warning "forward declaration of `struct A'" "" }
+
+A *a; // { dg-warning "`a' has incomplete type" "" }
+
+int
+main (int argc, char **argv)
+{
+ delete a; // { dg-warning "delete" "" { xfail *-*-* } }
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/warn/noreturn-1.C b/gcc/testsuite/g++.dg/warn/noreturn-1.C
new file mode 100644
index 00000000000..17375d42eb7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/noreturn-1.C
@@ -0,0 +1,71 @@
+// Test that noreturn attributes are properly set.
+// Origin: Kaveh Ghazi <ghazi@caip.rutgers.edu> 2002-06-18.
+// { dg-do compile }
+// { dg-options "-Wall -O2" }
+
+#include <cstdlib>
+
+int foo1 (int i)
+{
+ switch (i)
+ {
+ case 1:
+ case 2:
+ return i;
+ }
+ abort();
+}
+
+int foo2 (int i)
+{
+ switch (i)
+ {
+ case 1:
+ case 2:
+ return i;
+ }
+ std::abort();
+}
+
+int foo3 (int i)
+{
+ switch (i)
+ {
+ case 1:
+ case 2:
+ return i;
+ }
+ exit(1);
+}
+
+int foo4 (int i)
+{
+ switch (i)
+ {
+ case 1:
+ case 2:
+ return i;
+ }
+ std::exit(1);
+}
+
+void __attribute__ ((__noreturn__)) foo5 ()
+{
+ abort();
+}
+
+void __attribute__ ((__noreturn__)) foo6 ()
+{
+ std::abort();
+}
+
+void __attribute__ ((__noreturn__)) foo7 ()
+{
+ exit(1);
+}
+
+void __attribute__ ((__noreturn__)) foo8 ()
+{
+ std::exit(1);
+}
+
diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/linkage1-main.cc b/gcc/testsuite/g++.old-deja/g++.oliva/linkage1-main.cc
new file mode 100644
index 00000000000..80d27c36c29
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.oliva/linkage1-main.cc
@@ -0,0 +1,13 @@
+// Copyright 2002 Free Software Foundation
+
+// Derived by Alexandre Oliva <aoliva@redhat.com> from code posted by
+// Mark Mitchell <mark@codesourcery.com>
+
+typedef struct {
+ void f();
+} S;
+
+int main() {
+ S s;
+ s.f();
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/linkage1.C b/gcc/testsuite/g++.old-deja/g++.oliva/linkage1.C
new file mode 100644
index 00000000000..031fface3b7
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.oliva/linkage1.C
@@ -0,0 +1,21 @@
+// Copyright 2002 Free Software Foundation
+
+// Derived by Alexandre Oliva <aoliva@redhat.com> from code posted by
+// Mark Mitchell <mark@codesourcery.com>
+
+// Build don't run:
+
+// Additional sources: linkage1-main.cc
+
+// Verify that a member of a class is given global linkage when it's a
+// member of a function whose name is taken from a typedef, by
+// checking that another translation unit can call it. We don't do
+// the right things on functions, but we do on data members.
+
+// excess errors test - XFAIL *-*-*
+
+typedef struct {
+ void f();
+} S;
+
+void S::f() {}
diff --git a/gcc/testsuite/gcc.c-torture/compile/20020706-1.c b/gcc/testsuite/gcc.c-torture/compile/20020706-1.c
new file mode 100644
index 00000000000..c8811bc68ff
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/20020706-1.c
@@ -0,0 +1,50 @@
+// Contributed by Alexandre Oliva <aoliva@redhat.com>
+// From Red Hat case 106165.
+
+typedef struct s1
+{
+ unsigned short v1;
+ unsigned char *v2;
+} S1;
+
+extern void bar(const struct s1 *const hdb);
+extern unsigned char* foo ();
+
+unsigned int sn;
+S1 *hdb;
+S1 *pb;
+unsigned short len;
+
+unsigned int crashIt()
+{
+ unsigned char *p;
+ unsigned int nsn;
+ unsigned short cnt;
+
+ if (sn != 0) return 1;
+
+ if ((len < 12) || ((p = (((pb->v1) >= 8) ? pb->v2 : foo() )) == 0))
+ return 1;
+
+ nsn = (
+ (((*(unsigned int*)p) & 0x000000ff) << 24) |
+ (((*(unsigned int*)p) & 0x0000ff00) << 8) |
+ (((*(unsigned int*)p) & 0x00ff0000) >> 8) |
+ (((*(unsigned int*)p) & 0xff000000) >> 24) );
+ p += 4;
+
+ cnt = (unsigned short) ((
+ (((*(unsigned int*)p) & 0x000000ff) << 24) |
+ (((*(unsigned int*)p) & 0x0000ff00) << 8) |
+ (((*(unsigned int*)p) & 0x00ff0000) >> 8) |
+ (((*(unsigned int*)p) & 0xff000000) >> 24) ) &
+ 0xffff);
+
+ if ((len != 12 + (cnt * 56)) || (nsn == 0))
+ {
+ bar(hdb);
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/20020706-2.c b/gcc/testsuite/gcc.c-torture/compile/20020706-2.c
new file mode 100644
index 00000000000..b84dda60fd3
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/20020706-2.c
@@ -0,0 +1,26 @@
+// Contributed by Alexandre Oliva <aoliva@redhat.com>
+// From Red Hat case 106165.
+
+typedef unsigned short (FUNC_P) (void *, unsigned char *, unsigned short);
+
+void crashIt(int id, FUNC_P *func, unsigned char *funcparm)
+{
+ unsigned char buff[5], reverse[4];
+ unsigned char *bp = buff;
+ unsigned char *rp = reverse;
+ unsigned short int count = 0;
+ unsigned short cnt;
+ while (id > 0)
+ {
+ *rp++ = (unsigned char) (id & 0x7F);
+ id >>= 7;
+ count++;
+ }
+ cnt = count + 1;
+ while ((count--) > 1)
+ {
+ *bp++ = (unsigned char)(*(--rp) | 0x80);
+ }
+ *bp++ = *(--rp);
+ (void)(*func)(funcparm, buff, cnt);
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/simd-1.c b/gcc/testsuite/gcc.c-torture/compile/simd-1.c
new file mode 100644
index 00000000000..c113bd4fa2d
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/simd-1.c
@@ -0,0 +1,7 @@
+typedef int v2si __attribute__ ((mode(V2SI)));
+typedef unsigned di __attribute__ ((mode(DI)));
+void foo(unsigned long);
+void bar() {
+ v2si x = { 1, 2 };
+ foo((di) x);
+}
diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr_neg.cc b/libstdc++-v3/testsuite/20_util/auto_ptr_neg.cc
new file mode 100644
index 00000000000..ff39a0d24d5
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/auto_ptr_neg.cc
@@ -0,0 +1,50 @@
+// Copyright (C) 2002 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 20.4.5 Template class auto_ptr negative tests [lib.auto.ptr]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+// { dg-do compile }
+// { dg-excess-errors "" }
+
+// via Jack Reeves <jack_reeves@hispeed.ch>
+// libstdc++/3946
+// http://gcc.gnu.org/ml/libstdc++/2002-07/msg00024.html
+struct Base { };
+struct Derived : public Base { };
+
+std::auto_ptr<Derived>
+foo() { return std::auto_ptr<Derived>(new Derived); }
+
+int
+test01()
+{
+ std::auto_ptr<Base> ptr2;
+ ptr2 = new Base; // { dg-error "no" "candidates" "auto_ptr"}
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/map_operators_neg.cc b/libstdc++-v3/testsuite/23_containers/map_operators_neg.cc
new file mode 100644
index 00000000000..75b604c80c2
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/map_operators_neg.cc
@@ -0,0 +1,49 @@
+// 2000-09-07 bgarcia@laurelnetworks.com
+
+// Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 23.3.4 template class multiset negative tests
+
+#include <map>
+#include <string>
+
+// { dg-do compile }
+
+// libstdc++/86: map & set iterator comparisons are not type-safe
+void test01()
+{
+ bool test = true;
+ std::map<unsigned int, int> mapByIndex;
+ std::map<std::string, unsigned> mapByName;
+
+ mapByIndex.insert(std::pair<unsigned, int>(0, 1));
+ mapByIndex.insert(std::pair<unsigned, int>(6, 5));
+
+ std::map<unsigned, int>::iterator itr(mapByIndex.begin());
+
+ // NB: notice, it's not mapByIndex!!
+ test &= itr != mapByName.end(); // { dg-error "no" }
+ test &= itr == mapByName.end(); // { dg-error "no" }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/set_operators_neg.cc b/libstdc++-v3/testsuite/23_containers/set_operators_neg.cc
new file mode 100644
index 00000000000..c3c23741e2e
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/set_operators_neg.cc
@@ -0,0 +1,43 @@
+// 2000-09-07 bgarcia@laurelnetworks.com
+
+// Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 23.3.4 template class multiset negative tests
+
+#include <set>
+#include <string>
+
+// { dg-do compile }
+
+// libstdc++/86: map & set iterator comparisons are not type-safe
+int main(void)
+{
+ bool test = true;
+
+ std::set<unsigned int> setByIndex;
+ std::set<std::string> setByName;
+
+ std::set<unsigned int>::iterator itr(setByIndex.begin());
+
+ // NB: it's not setByIndex!!
+ test &= itr != setByName.end(); // { dg-error "no" }
+ test &= itr == setByName.end(); // { dg-error "no" }
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/hash_map.cc b/libstdc++-v3/testsuite/ext/hash_map.cc
new file mode 100644
index 00000000000..55b740f3ee8
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/hash_map.cc
@@ -0,0 +1,102 @@
+// Copyright (C) 2002 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// hash_map (SGI extension)
+
+#include <cstdlib>
+#include <string>
+#include <ext/hash_map>
+#include <testsuite_hooks.h>
+
+using namespace std;
+using namespace __gnu_cxx;
+
+namespace __gnu_cxx
+{
+ inline size_t hash_string(const char* s)
+ {
+ unsigned long h;
+ for (h=0; *s; ++s) {
+ h = 5*h + *s;
+ }
+ return size_t(h);
+ }
+
+ template<class T> struct hash<T *>
+ {
+ size_t operator()(const T *const & s) const
+ { return reinterpret_cast<size_t>(s); }
+ };
+
+ template<> struct hash<string>
+ {
+ size_t operator()(const string &s) const { return hash_string(s.c_str()); }
+ };
+
+ template<> struct hash<const string>
+ {
+ size_t operator()(const string &s) const { return hash_string(s.c_str()); }
+ };
+
+ template<class T1, class T2> struct hash<pair<T1,T2> >
+ {
+ hash<T1> __fh;
+ hash<T2> __sh;
+ size_t operator()(const pair<T1,T2> &p) const {
+ return __fh(p.first) ^ __sh(p.second);
+ }
+ };
+}
+
+
+const int Size = 5;
+
+void test01()
+{
+ bool test = true;
+
+ for (int i = 0; i < 10; i++)
+ {
+ hash_map<string,int> a;
+ hash_map<string,int> b;
+
+ vector<pair<string,int> > contents (Size);
+ for (int j = 0; j < Size; j++)
+ {
+ string s;
+ for (int k = 0; k < 10; k++)
+ {
+ s += 'a' + (rand() % 26);
+ }
+ contents[j] = make_pair(s,j);
+ }
+ for (int j = 0; j < Size; j++)
+ {
+ a[contents[j].first] = contents[j].second;
+ int k = Size - 1 - j;
+ b[contents[k].first] = contents[k].second;
+ }
+ VERIFY( a == b );
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}