diff options
author | no-author <no-author@gcc.gnu.org> | 2003-10-17 11:14:55 +0000 |
---|---|---|
committer | no-author <no-author@gcc.gnu.org> | 2003-10-17 11:14:55 +0000 |
commit | 9dc24585d4de38a630d86d3cc42873812d5506dd (patch) | |
tree | 063c7637f62b15c7aa4ad1af3419cf097fedcae0 | |
parent | 48adcc512e1ce095c4499a71ed68878272ff3877 (diff) |
This commit was manufactured by cvs2svn to create branch 'cygming331'.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/cygming331@72597 138bc75d-0d04-0410-961f-82ee72b054a4
47 files changed, 1297 insertions, 0 deletions
diff --git a/gcc/config/m68k/t-rtems b/gcc/config/m68k/t-rtems new file mode 100644 index 00000000000..d0e50e22ea9 --- /dev/null +++ b/gcc/config/m68k/t-rtems @@ -0,0 +1,6 @@ +# Custom multilibs for RTEMS + +MULTILIB_OPTIONS = m68000/m68020/m5200/mcpu32/m68030/m68040/m68060 m68881/msoft-float +MULTILIB_DIRNAMES = +MULTILIB_MATCHES = m68000=mc68000 m68000=m68302 mcpu32=m68332 m68020=mc68020 m68030=mc68030 +MULTILIB_EXCEPTIONS = m68000/msoft-float m5200/m68881 m5200/msoft-float mcpu32/m68881 mcpu32/msoft-float m68040/m68881 m68060/m68881 diff --git a/gcc/config/mips/t-rtems b/gcc/config/mips/t-rtems new file mode 100644 index 00000000000..bd7b7adf467 --- /dev/null +++ b/gcc/config/mips/t-rtems @@ -0,0 +1,5 @@ +# Custom multilibs for RTEMS + +MULTILIB_OPTIONS = mips1/mips3 msoft-float/msingle-float EL/EB +MULTILIB_DIRNAMES = mips1 mips3 soft-float single el eb +MULTILIB_MATCHES = msingle-float=m4650 diff --git a/gcc/fixinc/tests/base/string.h b/gcc/fixinc/tests/base/string.h new file mode 100644 index 00000000000..d70f9e08a3a --- /dev/null +++ b/gcc/fixinc/tests/base/string.h @@ -0,0 +1,13 @@ +/* DO NOT EDIT THIS FILE. + + It has been auto-edited by fixincludes from: + + "fixinc/tests/inc/string.h" + + This had to be done to correct non-standard usages in the + original, manufacturer supplied header file. */ + +#ifndef _STRING_INCLUDED + #define _STRING_INCLUDED + #include <strings.h> +#endif /* _STRING_INCLUDED */
\ No newline at end of file diff --git a/gcc/fixinc/tests/base/sys/regset.h b/gcc/fixinc/tests/base/sys/regset.h new file mode 100644 index 00000000000..6723427e89c --- /dev/null +++ b/gcc/fixinc/tests/base/sys/regset.h @@ -0,0 +1,26 @@ +/* DO NOT EDIT THIS FILE. + + It has been auto-edited by fixincludes from: + + "fixinc/tests/inc/sys/regset.h" + + This had to be done to correct non-standard usages in the + original, manufacturer supplied header file. */ + + + +#if defined( SCO_REGSET_CHECK ) +union u_fps { + struct rsfpstate + { + int whatever; + } +}; +union _u_fps { + struct _rsfpstate + { + int whatever; + } +}; + +#endif /* SCO_REGSET_CHECK */ diff --git a/gcc/testsuite/g++.dg/abi/bitfield11.C b/gcc/testsuite/g++.dg/abi/bitfield11.C new file mode 100644 index 00000000000..e78ea121d61 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/bitfield11.C @@ -0,0 +1,14 @@ +// { dg-do run } +// { dg-options "-w -fabi-version=0" } + +struct S { + char c : 1024; +}; + +S s; + +int main () { + s.c = 1; + if (*(char *)&s != 1) + return 1; +} diff --git a/gcc/testsuite/g++.dg/abi/bitfield12.C b/gcc/testsuite/g++.dg/abi/bitfield12.C new file mode 100644 index 00000000000..6cfda5d47df --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/bitfield12.C @@ -0,0 +1,5 @@ +// { dg-options "-Wabi -fabi-version=1" } + +struct S { // { dg-warning "ABI" } + char c : 1024; // { dg-warning "width" } +}; diff --git a/gcc/testsuite/g++.dg/eh/delayslot1.C b/gcc/testsuite/g++.dg/eh/delayslot1.C new file mode 100644 index 00000000000..ddc960e6d8b --- /dev/null +++ b/gcc/testsuite/g++.dg/eh/delayslot1.C @@ -0,0 +1,47 @@ +// PR target/12301 +// Origin: Colin Hirsch <gcc@cohi.at> +// Testcase by Christian Ehrhardt <ehrhardt@mathematik.uni-ulm.de> + +// This used to fail on SPARC because the reorg pass moved an insn +// across a function call that can throw internally, in order to put +// it in a delay slot. + +// { dg-do run } +// { dg-options "-O" } + +struct S{ + char *c; + char data[100]; + S () : c (data) {}; + S (const S& s) { + c = data; + data[0] = s.c[0]; + } +}; + +S real_cast () +{ + throw 3; +} + +S cast_helper(S& debug) +{ + try { + return real_cast(); + } + catch (int e) { + throw debug; + } +} + +int main() +{ + S tmp; + + try { + cast_helper (tmp); + } + catch (S& e) {} + + return 0; +} diff --git a/gcc/testsuite/g++.dg/expr/comma1.C b/gcc/testsuite/g++.dg/expr/comma1.C new file mode 100644 index 00000000000..5424ce1a84e --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/comma1.C @@ -0,0 +1,21 @@ +// { dg-do run } + +extern "C" void abort (); + +struct gtst +{ + unsigned char data[2]; +}; + +static struct gtst s; + +int main(int argc, char *argv[]) +{ + unsigned char * pc; + struct gtst * ps; + ps = &s; + pc = (ps->data[0]='A', ps->data); + if (&s.data[0] != pc) + abort(); + return 0; +} diff --git a/gcc/testsuite/g++.dg/expr/static_cast4.C b/gcc/testsuite/g++.dg/expr/static_cast4.C new file mode 100644 index 00000000000..cea7f487393 --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/static_cast4.C @@ -0,0 +1,11 @@ +class C { +public: + explicit C(int) {} +}; + +int main() +{ + int i = 0; + static_cast<C>(i); + return 0; +} diff --git a/gcc/testsuite/g++.dg/expr/static_cast5.C b/gcc/testsuite/g++.dg/expr/static_cast5.C new file mode 100644 index 00000000000..1a51f151677 --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/static_cast5.C @@ -0,0 +1,17 @@ +void ambig() +{ + struct A {}; + struct B : A {}; + struct C : A {}; + struct D : B, C {}; + + D d; + A* ap = static_cast<B*> (&d); + D* db = static_cast<D*> (ap); // { dg-error "" } + + D& dr1 = static_cast<D&> (*ap); // { dg-error "" } + + A& ar = static_cast<C&> (d); + D& dr = static_cast<D&> (ar); // { dg-error "" } +} + diff --git a/gcc/testsuite/g++.dg/ext/attrib8.C b/gcc/testsuite/g++.dg/ext/attrib8.C new file mode 100644 index 00000000000..26021c56ca4 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib8.C @@ -0,0 +1,10 @@ +// PR 8656 +// { dg-do compile { target i?86-*-* } } + +extern int * (__attribute__((stdcall)) *fooPtr)( void); +int * __attribute__((stdcall)) myFn01( void) { return 0; } + +void snafu( void) +{ + fooPtr = myFn01; +} diff --git a/gcc/testsuite/g++.dg/inherit/conv1.C b/gcc/testsuite/g++.dg/inherit/conv1.C new file mode 100644 index 00000000000..e16c489a235 --- /dev/null +++ b/gcc/testsuite/g++.dg/inherit/conv1.C @@ -0,0 +1,23 @@ +typedef struct _A A; +typedef struct _A B; + +void some_function(B *b); + +class AClass { + +public: + operator A*() { return 0;} + +}; + +class BClass :public AClass { + +public: + operator B*() { return 0;} + +}; + +int main(int argc, char **argv) { + BClass b; + some_function(b); +} diff --git a/gcc/testsuite/g++.dg/inherit/error1.C b/gcc/testsuite/g++.dg/inherit/error1.C new file mode 100644 index 00000000000..1570bf11e2e --- /dev/null +++ b/gcc/testsuite/g++.dg/inherit/error1.C @@ -0,0 +1,10 @@ +// PR 12486 + +struct A { int ma; }; +struct B { }; + +void foo() +{ + B *b; + b->A::ma=0; // { dg-error "" } +} diff --git a/gcc/testsuite/g++.dg/init/array11.C b/gcc/testsuite/g++.dg/init/array11.C new file mode 100644 index 00000000000..e52effe9ff7 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/array11.C @@ -0,0 +1,28 @@ +/* PR 11665 + Orgin: jwhite@cse.unl.edu + The problem was in initializer_constant_valid_p, + "for a CONSTRUCTOR, only the last element + of the CONSTRUCTOR was being checked" + (from the email of the patch which fixed this). + This used to ICE because GCC thought gdt_table was a + constant value when it is not. */ + +int x; + +typedef __SIZE_TYPE__ size_t; + +struct gdt +{ +size_t a,b,c,d,e,f; +}; +void f() +{ +struct gdt gdt_table[2]= +{ + { + 0, + ( (((size_t)(&x))<<(24))&(-1<<(8)) ), + }, +}; +} + diff --git a/gcc/testsuite/g++.dg/init/new9.C b/gcc/testsuite/g++.dg/init/new9.C new file mode 100644 index 00000000000..6729d76fd00 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/new9.C @@ -0,0 +1,22 @@ +// PR 12337 + +class A {}; + +template <typename T> +class X : public A { +public: + X(T&); +}; + +class B { +public: + bool foo(A*); + template <typename T> + bool foo(T& t) { return foo(new X<T>(t)); } +}; + +int main() +{ + B x, y; + x.foo(y); +} diff --git a/gcc/testsuite/g++.dg/init/ref9.C b/gcc/testsuite/g++.dg/init/ref9.C new file mode 100644 index 00000000000..127b7d8e1fd --- /dev/null +++ b/gcc/testsuite/g++.dg/init/ref9.C @@ -0,0 +1,36 @@ +// { dg-do run } + +struct ex; +struct basic { + int refcount; + ex eval() const; + basic() : refcount(0) {} +}; + +struct ex { + basic *bp; + ex() : bp(0) { } + ex(const basic &); + virtual ~ex(); + void construct_from_basic(const basic &); +}; + +ex basic::eval() const { + throw 1; +} + +inline ex::ex(const basic &b) { construct_from_basic (b); } +inline ex::~ex() { if (--bp->refcount == 0) delete bp; } +void ex::construct_from_basic(const basic &b) { + const ex & tmpex = b.eval(); + bp = tmpex.bp; + bp->refcount++; +} + +ex pow() { return basic(); } + +int main() +{ + try { pow (); } catch (int) {} + return 0; +} diff --git a/gcc/testsuite/g++.dg/init/struct1.C b/gcc/testsuite/g++.dg/init/struct1.C new file mode 100644 index 00000000000..4cabc99e0e2 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/struct1.C @@ -0,0 +1,6 @@ +struct bug { + const char *name; + unsigned long type; +}; + +struct bug s = { 0, (unsigned long) &s | 1 }; diff --git a/gcc/testsuite/g++.dg/lookup/koenig2.C b/gcc/testsuite/g++.dg/lookup/koenig2.C new file mode 100644 index 00000000000..04f95258999 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/koenig2.C @@ -0,0 +1,15 @@ +struct S +{ + template <typename T> void operator() (T) {} +}; + +namespace N +{ + S s; + struct A {} a; +} + +using N::s; + +void f () { s(N::a); } + diff --git a/gcc/testsuite/g++.dg/opt/cfg2.C b/gcc/testsuite/g++.dg/opt/cfg2.C new file mode 100644 index 00000000000..229f4bc3a52 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/cfg2.C @@ -0,0 +1,38 @@ +// PR optimization/12215 +// Origin: <nick@ilm.com> +// Reduced testcase by Wolfgang Bangerth <bangerth@ticam.utexas.edu> + +// This used to fail because the CSE pass destroyed the CFG in presence +// of trapping loads, which led to the deletion of basic blocks. + +// { dg-do compile } +// { dg-options "-O2 -fno-gcse -fnon-call-exceptions" } + + +struct B { + ~B() throw() {} +}; + +struct X { + X(const char*, const B&); + ~X() {} +}; + +bool m(); +void f(int &i, float &arg0); + +void g (const char **argv) { + float val; + int i = 1; + + try { + while ( i < 1 ) + { + X arg(argv[i], B()); + if (m()) + throw(0); + + f(i, val); + } + } catch (...) {} +} diff --git a/gcc/testsuite/g++.dg/opt/cfg3.C b/gcc/testsuite/g++.dg/opt/cfg3.C new file mode 100644 index 00000000000..123c2f5157b --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/cfg3.C @@ -0,0 +1,61 @@ +// PR optimization/11646 +// Origin: <nick@ilm.com> + +// This used to fail because the compiler inadvertently cleared +// the EDGE_ABNORMAL flag on a EDGE_EH edge and didn't delete +// unreachable blocks after CSE. + +// { dg-do compile } +// { dg-options "-O -fgcse -fnon-call-exceptions" } + +struct C +{ + int i; +}; + +struct allocator +{ + ~allocator() throw() {} +}; + +struct _Vector_alloc_base +{ + _Vector_alloc_base(const allocator& __a) {} + allocator _M_data_allocator; + struct C *_M_start, *_M_end_of_storage; + void _M_deallocate(struct C* __p, unsigned int __n) {} +}; + +struct _Vector_base : _Vector_alloc_base +{ + _Vector_base(const allocator& __a) : _Vector_alloc_base(__a) { } + ~_Vector_base() { _M_deallocate(0, _M_end_of_storage - _M_start); } +}; + +struct vector : _Vector_base +{ + vector(const allocator& __a = allocator()) : _Vector_base(__a) {} + struct C& operator[](unsigned int __n) { return *_M_start; } +}; + +struct A +{ + float l() const; + A operator-(const A &) const; + const A& operator=(float) const; +}; + +struct B +{ + float d(); +}; + +float f(const A& a, B& b) +{ + vector vc; + int index = vc[0].i; + A aa; + float d = (aa - a).l(); + if (d > b.d()) aa = 0; + return b.d(); +} diff --git a/gcc/testsuite/g++.dg/opt/cond1.C b/gcc/testsuite/g++.dg/opt/cond1.C new file mode 100644 index 00000000000..ae8fa4d45d9 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/cond1.C @@ -0,0 +1,24 @@ +// { dg-do run } +// { dg-options "-O2" } + +struct D { int x; }; +struct W +{ + W () {} + D & operator * () { return d; } + D d; +}; + +int +foo (int y) +{ + W m; + (*m).x = (y > 1 ? y : 0); + return (*m).x; +} + +int +main () +{ + return (foo (6) != 6); +} diff --git a/gcc/testsuite/g++.dg/opt/float1.C b/gcc/testsuite/g++.dg/opt/float1.C new file mode 100644 index 00000000000..8f26ed5c852 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/float1.C @@ -0,0 +1,21 @@ +// PR optimization/11637 +// Origin: <nick@ilm.com> + +// This used to fail to assemble on x86 because a decimal +// floating point litteral was emitted, which originated +// from a bogus REG_EQUAL note not removed by the combiner. + +// { dg-do assemble } +// { dg-options "-O2 -fnon-call-exceptions" } + +void f(long int seed); + +void g(float &o) +{ + float a = 0.05f; + float b = 1.0 - a; + float c = 1.0 + a; + + f(0); + o = a; +} diff --git a/gcc/testsuite/g++.dg/opt/longbranch2.C b/gcc/testsuite/g++.dg/opt/longbranch2.C new file mode 100644 index 00000000000..b74ceddf085 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/longbranch2.C @@ -0,0 +1,62 @@ +// PR target/11689 +// Originator: thor@math.tu-berlin.de + +// { dg-do compile } +// { dg-options "-O3 -funroll-loops -mtune=k6 -fomit-frame-pointer" { target i?86-*-* } } + +// This used to fail to assemble because of an out-of-range 'loop' instructions. + + +class JKeeper { +public: + unsigned long a0; +}; + +class EBCOTLut : public JKeeper { + unsigned char a1[1<<8]; + unsigned char a2[1<<8]; + unsigned char a3[1<<8]; + long a4[1<<9]; +public: + EBCOTLut(void); +}; + +EBCOTLut::EBCOTLut(void) +{ + unsigned char inter[36]; // intermediate lookup table; + unsigned long i; + for(i=0;i<36;i++) { + inter[i] = 0; + } + for(i=1;i<16;i++) { + a1[i | (1<<7)] = 8<<1; + a1[i | (1<<6)] = 8<<1; + } + for(i=0;i < ((1<<9)-1);i++) { + int ds = (i>>0) & 0x01; // significance of DOWN + int us = (i>>1) & 0x01; // significance of UP + int rs = (i>>2) & 0x01; // significance of RIGHT + int ls = (i>>3) & 0x01; // significance of LEFT + int dn = (i>>5) & 0x01; // sign of DOWN + int un = (i>>6) & 0x01; // sign of UP + int rn = (i>>7) & 0x01; // sign of RIGHT + int ln = (i>>8) & 0x01; // sign of LEFT + int h,v; // h and v as in the VM description + + h = ls*(1-ln*2) + rs*(1-2*rn); + v = us*(1-un*2) + ds*(1-2*dn); + h = (h >= -1)?(h):(-1); + v = (v >= -1)?(v):(-1); + h = (h <= 1)?(h):(1); + v = (v <= 1)?(v):(1); + a2[i] = inter[((h+1)<<3) | (v+1)]; + a3[i] = inter[((h+1)<<3) | (v+1)] & (unsigned char)(~1); + } + for(i=0;i< 1<<9; i++) { + a4[i] = 2*(i-(1<<(9-1)))*(i-(1<<(9-1))) - + ((i< (1<<(9-1)))? + (2*(i-(1<<(9-2)))*(i-(1<<(9-2)))): + (2*(i-(3<<(9-2)))*(i-(3<<(9-2))))); + + } +} diff --git a/gcc/testsuite/g++.dg/opt/reg-stack2.C b/gcc/testsuite/g++.dg/opt/reg-stack2.C new file mode 100644 index 00000000000..08cd590b471 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/reg-stack2.C @@ -0,0 +1,34 @@ +// PR target/9786 +// Origin: <nick@ilm.com> + +// This used to fail on x86 because the reg-stack pass deleted +// an insn that could seemingly trap (but actually doesn't) +// without updating the CFG. + +// { dg-do compile } +// { dg-options "-O2 -fnon-call-exceptions" } + +struct D1 { + float l; + D1 GS() const {D1 d;float f=.299*l;d.l=f;return d;} + static D1 G() {return D1();} +}; + +struct D2 { + D1 g; + D2(const D1& gi) : g(gi) {} + D2 GS() const {return D2(g.GS());} +}; + +class A { + public: + virtual ~A() {} +}; + +class B : public A { + public: + B(const D2& mi); + D2 fm; +}; + +B::B(const D2 &mi) : fm(mi.GS()) {} diff --git a/gcc/testsuite/g++.dg/opt/unroll1.C b/gcc/testsuite/g++.dg/opt/unroll1.C new file mode 100644 index 00000000000..fd07f889a1d --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/unroll1.C @@ -0,0 +1,420 @@ +// PR optimization/12340 +// Origin: Richard Guenther <richard.guenther@uni-tuebingen.de> +// Testcase by Eric Botcazou <ebotcazou@libertysurf.fr> + +// This used to segfault on x86 because the loop optimizer wrongly +// interpreted a double assignment to a biv as a double increment, +// which subsequently fooled the unroller. + +// { dg-do run } +// { dg-options "-O2 -fno-exceptions -funroll-loops" } + +typedef __SIZE_TYPE__ size_t; + +inline void* operator new(size_t, void* __p) throw() { return __p; } +inline void operator delete (void*, void*) throw() { }; + +class Loc; +class Interval; + +template<class DT> +class DomainBase +{ +public: + typedef typename DT::Domain_t Domain_t; + typedef typename DT::Storage_t Storage_t; + + Domain_t &unwrap() { return *static_cast<Domain_t *>(this); } + + const Domain_t &unwrap() const { + return *static_cast<Domain_t *>(const_cast<DomainBase<DT> *>(this)); + } + +protected: + Storage_t domain_m; +}; + +template<class DT> +class Domain : public DomainBase<DT> +{ + typedef DomainBase<DT> Base_t; + +public: + typedef typename DT::Size_t Size_t; + typedef typename DT::Element_t Element_t; + typedef typename Base_t::Domain_t Domain_t; + typedef typename Base_t::Storage_t Storage_t; + + Domain_t &operator[](int) { return this->unwrap(); } + + const Domain_t &operator[](int) const { return this->unwrap(); } + + template<class T> + void setDomain(const T &newdom) { + DT::setDomain(this->domain_m, newdom); + } + + Element_t first() const { return DT::first(this->domain_m); } + + Size_t length() const { return DT::length(this->domain_m); } + + Size_t size() const { return length(); } +}; + +template<class T> +struct DomainTraits; + +template<> +struct DomainTraits<Interval> +{ + typedef int Size_t; + typedef int Element_t; + typedef Interval Domain_t; + typedef Interval OneDomain_t; + typedef Loc AskDomain_t; + typedef int Storage_t[2]; + enum { dimensions = 1 }; + enum { wildcard = false }; + + static int first(const Storage_t &d) { return d[0]; } + + static int length(const Storage_t &d) { return d[1]; } + + static OneDomain_t &getDomain(Domain_t &d, int) { return d; } + + static const OneDomain_t &getDomain(const Domain_t &d, int) { return d; } + + template<class T> + static void setDomain(Storage_t &dom, const T &newdom) { + dom[0] = newdom.first(); + dom[1] = newdom.length(); + } + + template<class T1, class T2> + static void setDomain(Storage_t &dom, const T1 &begval, const T2 &endval) { + dom[0] = begval; + dom[1] = (endval - begval + 1); + } + +}; + +class Interval : public Domain<DomainTraits<Interval> > +{ +public: + Interval(const Interval &a) : Domain<DomainTraits<Interval> >() { + for (int i=0; i < DomainTraits<Interval>::dimensions; ++i) + DomainTraits<Interval>::getDomain(*this, i).setDomain( + DomainTraits<Interval>::getDomain(a, i)); + } + + Interval(int a) : Domain<DomainTraits<Interval> >() + { + DomainTraits<Interval>::setDomain(domain_m, 0, a - 1); + } +}; + +template<> +struct DomainTraits<Loc> +{ + typedef int Size_t; + typedef int Element_t; + typedef Loc Domain_t; + typedef Loc AskDomain_t; + typedef Loc MultResult_t; + typedef int Storage_t; + + static int first(int d) { return d; } + + template<class T> + static void setDomain(int &dom, const T &newdom) { + dom = DomainTraits<T>::getFirst(newdom); + } +}; + +template<> +struct DomainTraits<int> + { + enum { dimensions = 1 }; + enum { wildcard = false }; + + static int getPointDomain(int d, int) { return d; } + + static int getFirst(const int &d) { return d; } +}; + +class Loc : public Domain<DomainTraits<Loc> > +{ +public: + explicit Loc(const int &a) : Domain<DomainTraits<Loc> >() { + for (int i=0; i < 1; ++i) + (*this)[i].setDomain(DomainTraits<int>::getPointDomain(a, 0)); + } +}; + +struct ElementProperties +{ + enum { hasTrivialDefaultConstructor = false }; + enum { hasTrivialDestructor = false }; + + static void construct(double* addr) + { + new (addr) double(); + } + + static void construct(double* addr, const double& model) + { + new (addr) double(model); + } + + static void destruct(double *addr) {} +}; + +class RefCounted +{ +public: + RefCounted() : count_m(0) {} + + void addReference() { ++count_m; } + bool removeRefAndCheckGarbage() + { + return (--count_m == 0); + } + +private: + int count_m; +}; + +class RefBlockController : public RefCounted +{ +public: + explicit RefBlockController(unsigned int size) + : pBegin_m(0), pEnd_m(0), pEndOfStorage_m(0), dealloc_m(false) + { + reallocateStorage(size, false); + + if (!ElementProperties::hasTrivialDefaultConstructor) + { + for (double * pt = begin(); pt != end(); ++pt) + ElementProperties::construct(pt); + } + } + + ~RefBlockController() + { + deleteStorage(); + } + + double *begin() const + { + return pBegin_m; + } + + double *end() const + { + return pEnd_m; + } + + bool isMine() const + { + return dealloc_m; + } + +private: + void deleteStorage() + { + if (isMine() && pBegin_m != 0) + { + if (!ElementProperties::hasTrivialDestructor) + for (double *pt = begin(); pt != end(); ++pt) + ElementProperties::destruct(pt); + + char *tmp = reinterpret_cast<char *>(pBegin_m); + delete [] tmp; + } + } + + void reallocateStorage(unsigned int newsize, bool copyold = false) + { + double *pBeginNew = 0; + double *pEndNew = 0; + double *pEndOfStorageNew = 0; + + if (newsize > 0) + { + int nsize = newsize * sizeof(double); + char *tmp = new char[nsize]; + pBeginNew = reinterpret_cast<double *>(tmp); + pEndNew = pBeginNew + newsize; + pEndOfStorageNew = pBeginNew + (nsize / sizeof(double)); + + if (copyold) + { + double * pOld = begin(); + double * pNew = pBeginNew; + while (pOld != end() && pNew != pEndNew) + ElementProperties::construct(pNew++,*pOld++); + } + } + + deleteStorage(); + + pBegin_m = pBeginNew; + pEnd_m = pEndNew; + pEndOfStorage_m = pEndOfStorageNew; + dealloc_m = true; + } + + double *pBegin_m; + double *pEnd_m; + double *pEndOfStorage_m; + bool dealloc_m; +}; + +class DataBlockController : public RefBlockController +{ +public: + explicit + DataBlockController(unsigned int size) + : RefBlockController(size), dataObjectPtr_m(new char), owned_m(true) {} + + ~DataBlockController() + { + if (owned_m) delete dataObjectPtr_m; + } + +private: + mutable char *dataObjectPtr_m; + bool owned_m; +}; + +class RefCountedPtr +{ +public: + RefCountedPtr(DataBlockController * const pT) : ptr_m(pT) + { if (isValid()) ptr_m->addReference(); } + + ~RefCountedPtr() { invalidate(); } + + DataBlockController* operator->() const { return ptr_m; } + void invalidate(); + bool isValid() const { return ptr_m != 0; } + +private: + friend class RefCountedBlockPtr; + DataBlockController * ptr_m; +}; + +inline void RefCountedPtr::invalidate() +{ + if ( isValid() && ptr_m->removeRefAndCheckGarbage() ) + delete ptr_m; + ptr_m = 0; +} + +class RefCountedBlockPtr +{ +public: + explicit RefCountedBlockPtr(unsigned int size) + : offset_m(0), + blockControllerPtr_m(new DataBlockController(size)) {} + + int offset() const + { + return offset_m; + } + + double *beginPointer() const + { + return blockControllerPtr_m->begin(); + } + + double *currentPointer() const + { + return beginPointer() + offset(); + } + +protected: + int offset_m; + RefCountedPtr blockControllerPtr_m; +}; + +class DataBlockPtr : public RefCountedBlockPtr +{ +public: + explicit DataBlockPtr(unsigned int size) : RefCountedBlockPtr(size) {} +}; + +class Node +{ +public: + Node(const Interval &owned, const Interval &allocated) + : domain_m(owned), allocated_m(allocated) {} + + const Interval &allocated() const { return allocated_m; } + +private: + Interval domain_m; + Interval allocated_m; +}; + +class DomainLayout +{ +public: + explicit DomainLayout(const Interval &dom) : node_m(0, dom) {} + + const Interval &domain() const + { + return node_m.allocated(); + } + +private: + Node node_m; +}; + +class BrickBase +{ +public: + explicit BrickBase(const Interval &domain); + + int offset(const Loc &dom) const { return off_m + dom[0].first(); } + +protected: + DomainLayout layout_m; + int firsts_m; + int off_m; +}; + +BrickBase::BrickBase(const Interval &dom) + : layout_m(dom) +{ + firsts_m = layout_m.domain()[0].first(); + off_m = -firsts_m; +} + +class Engine : public BrickBase +{ +public: + explicit Engine(const Interval &dom) + : BrickBase(dom), dataBlock_m(dom.size()), data_m(dataBlock_m.currentPointer()) {} + + double& operator()(const Loc &loc) const + { + return data_m[this->offset(loc)]; + } + +private: + DataBlockPtr dataBlock_m; + double *data_m; +}; + + +int main() +{ + Interval I(10); + Engine A(I); + + for (int i = 0; i < 10; i++) + A(Loc(i)) = 2.0 + i - i*i; + + return 0; +} diff --git a/gcc/testsuite/g++.dg/overload/builtin3.C b/gcc/testsuite/g++.dg/overload/builtin3.C new file mode 100644 index 00000000000..dcd9fd02e38 --- /dev/null +++ b/gcc/testsuite/g++.dg/overload/builtin3.C @@ -0,0 +1,10 @@ +// PR c++/11409 +// { dg-do compile } + +namespace std { + double fabs (double); +} +using std::fabs; + +double (*p) (double) = &fabs; // { dg-bogus "is ambiguous" "" } + diff --git a/gcc/testsuite/g++.dg/overload/template1.C b/gcc/testsuite/g++.dg/overload/template1.C new file mode 100644 index 00000000000..5bfad8464f7 --- /dev/null +++ b/gcc/testsuite/g++.dg/overload/template1.C @@ -0,0 +1,12 @@ +template<typename T> T Foo (int) {T d;} + +void Baz (void (*)(int), int); + +int Foo (); +int Baz (int (*)(), float); + +void Bar () +{ + Baz (Foo, 1.0f); + +} diff --git a/gcc/testsuite/g++.dg/parse/template12.C b/gcc/testsuite/g++.dg/parse/template12.C new file mode 100644 index 00000000000..ba375bc437a --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/template12.C @@ -0,0 +1,10 @@ +template <int J> +struct A { +}; + +struct B { + template <int I> + struct C : public A<I> {}; + + typedef double I; +}; diff --git a/gcc/testsuite/g++.dg/rtti/typeid2.C b/gcc/testsuite/g++.dg/rtti/typeid2.C new file mode 100644 index 00000000000..0dbcc598b9d --- /dev/null +++ b/gcc/testsuite/g++.dg/rtti/typeid2.C @@ -0,0 +1,15 @@ +// { dg-do run } + +#include <typeinfo> + +template <typename T> const char *print_type (const T &) { + return typeid(T).name(); +} + +/* no template */ void pp1 (int) {} +template <typename X> void pp2 (X) {} + +int main () { + if (print_type (&pp1) != print_type (&pp2<int>)) + return 1; +} diff --git a/gcc/testsuite/g++.dg/rtti/typeid3.C b/gcc/testsuite/g++.dg/rtti/typeid3.C new file mode 100644 index 00000000000..a07b399249c --- /dev/null +++ b/gcc/testsuite/g++.dg/rtti/typeid3.C @@ -0,0 +1,11 @@ +#include <typeinfo> + +template <template <class> class T> struct A { + void error() { + typeid(T).name(); // { dg-error "missing" } + } +}; + +template <class T> struct B {}; + +template void A<B>::error(); diff --git a/gcc/testsuite/g++.dg/template/crash11.C b/gcc/testsuite/g++.dg/template/crash11.C new file mode 100644 index 00000000000..3c69514e243 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash11.C @@ -0,0 +1,9 @@ +// { dg-do compile } + +// Origin: kparz@iastate.edu + +// PR c++/7939: ICE for invalid function parameter after template +// substitution. + +template <class T, class U> void foo(T, U) {} +template <class T> void foo<T,void>(T, void) {} // { dg-error "incomplete|invalid|partial" } diff --git a/gcc/testsuite/g++.dg/template/crash9.C b/gcc/testsuite/g++.dg/template/crash9.C new file mode 100644 index 00000000000..7a568fe054a --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash9.C @@ -0,0 +1,12 @@ +struct A { }; +struct B { }; + +A f(const B & b) { + return A(); +} + +template<> +B f(const A & a) { // { dg-error "" } + return B(); +} + diff --git a/gcc/testsuite/g++.dg/template/friend25.C b/gcc/testsuite/g++.dg/template/friend25.C new file mode 100644 index 00000000000..fa11defc21a --- /dev/null +++ b/gcc/testsuite/g++.dg/template/friend25.C @@ -0,0 +1,14 @@ +// { dg-do compile } + +// Origin: Jiangbin Zhao <zhaojiangbin@yahoo.com> + +// PR c++/12369: ICE for specialization of member function template +// as friend in ordinary class. + +struct A { + template<class T> T* make() { return new T(); } +}; + +struct B { + friend B* A::make< B >(); // (1) +}; diff --git a/gcc/testsuite/gcc.c-torture/compile/20030907-1.c b/gcc/testsuite/gcc.c-torture/compile/20030907-1.c new file mode 100644 index 00000000000..e362b910284 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20030907-1.c @@ -0,0 +1,25 @@ +/* PR 11665 + Orgin: jwhite@cse.unl.edu + The problem was in initializer_constant_valid_p, + "for a CONSTRUCTOR, only the last element + of the CONSTRUCTOR was being checked" + (from the email of the patch which fixed this). + This used to ICE because GCC thought gdt_table was a + constant value when it is not. */ + +int x; +struct gdt +{ +unsigned a,b,c,d,e,f; +}; +void f() +{ +struct gdt gdt_table[2]= +{ + { + 0, + ( (((unsigned)(&x))<<(24))&(-1<<(8)) ), + }, +}; +} + diff --git a/gcc/testsuite/gcc.c-torture/compile/20031002-1.c b/gcc/testsuite/gcc.c-torture/compile/20031002-1.c new file mode 100644 index 00000000000..a023994f402 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20031002-1.c @@ -0,0 +1,9 @@ +/* PR/12292 + http://gcc.gnu.org/ml/gcc-patches/2003-10/msg00143.html */ + +char flags; + +int bug12292(int t) +{ + flags &= ~(1 << (t + 4)); +} diff --git a/gcc/testsuite/gcc.c-torture/compile/20031011-1.c b/gcc/testsuite/gcc.c-torture/compile/20031011-1.c new file mode 100644 index 00000000000..e35d76211b6 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20031011-1.c @@ -0,0 +1,21 @@ +/* PR optimization/12544 */ +/* Origin: Tony Hosking <hosking@cs.purdue.edu> */ + +/* Verify that non-local structures passed by invisible + reference are correctly put in the stack. */ + +typedef struct { + int a; + int f; +} A; + +A *b; + +void x (A a) { + void y () { + a.a = 0; + } + + b = &a; + y(); +} diff --git a/gcc/testsuite/gcc.dg/20030702-1.c b/gcc/testsuite/gcc.dg/20030702-1.c new file mode 100644 index 00000000000..70dad2eb8a9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20030702-1.c @@ -0,0 +1,10 @@ +/* This tests whether REG_ALWAYS_RETURN notes are handled + correctly in combine. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fpic -fprofile-arcs" } */ + +void test (void) +{ + fork (); +} + diff --git a/gcc/testsuite/gcc.dg/20030815-1.c b/gcc/testsuite/gcc.dg/20030815-1.c new file mode 100644 index 00000000000..fe1e7b49a58 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20030815-1.c @@ -0,0 +1,26 @@ +/* Test completion of incomplete types. + There used to be a bug where some types from incomplete + list were accidentally lost. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef struct a A[1]; +typedef struct b B[1]; +typedef struct c C[1]; +typedef struct d D[1]; +typedef struct a E; +typedef struct b F; +typedef struct c G; +typedef struct d H; +struct a { int a; }; +struct c { int c; }; +struct d { int d; }; +struct b { int b; }; +int sa = sizeof (A); +int sb = sizeof (B); +int sc = sizeof (C); +int sd = sizeof (D); +int se = sizeof (E); +int sf = sizeof (F); +int sg = sizeof (G); +int sh = sizeof (H); diff --git a/gcc/testsuite/gcc.dg/20031002-1.c b/gcc/testsuite/gcc.dg/20031002-1.c new file mode 100644 index 00000000000..57a31ed7f85 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20031002-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +void generic_sendmsg (char *fmt, ...) +{ + __builtin_next_arg(fmt); +} + +void generic_sendstat() +{ + double t; + + generic_sendmsg("F %3.2f", t); +} diff --git a/gcc/testsuite/gcc.dg/builtin-apply1.c b/gcc/testsuite/gcc.dg/builtin-apply1.c new file mode 100644 index 00000000000..38b384e7cca --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtin-apply1.c @@ -0,0 +1,9 @@ +/* PR 11184 */ +/* Origin: Dara Hazeghi <dhazeghi@yahoo.com> */ + +void * +objc_msg_sendv (char * arg_frame, void (*foo)()) +{ + return __builtin_apply ( foo, arg_frame, 4); +} + diff --git a/gcc/testsuite/gcc.dg/c90-array-lval-6.c b/gcc/testsuite/gcc.dg/c90-array-lval-6.c new file mode 100644 index 00000000000..f42ef52bd19 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c90-array-lval-6.c @@ -0,0 +1,16 @@ +/* PR c/12446 */ +/* Origin: Keith Thompson <kst@cts.com> */ + +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + + +struct s { char c[1]; }; + +extern struct s foo(void); + +void bar(void) +{ + char *ptr = foo().c; /* { dg-bogus "warning" "warning in place of error" } */ +} +/* { dg-error "non-lvalue" "array not decaying to lvalue" { target *-*-* } 14 } */ diff --git a/gcc/testsuite/gcc.dg/c99-array-lval-6.c b/gcc/testsuite/gcc.dg/c99-array-lval-6.c new file mode 100644 index 00000000000..426b3c75c90 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c99-array-lval-6.c @@ -0,0 +1,15 @@ +/* PR c/12446 */ +/* Origin: Keith Thompson <kst@cts.com> */ + +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + + +struct s { char c[1]; }; + +extern struct s foo(void); + +void bar(void) +{ + char *ptr = foo().c; /* { dg-bogus "non-lvalue" "array not decaying to lvalue" } */ +} diff --git a/gcc/testsuite/gcc.dg/cpp/Wunknown-pragmas-1.c b/gcc/testsuite/gcc.dg/cpp/Wunknown-pragmas-1.c new file mode 100644 index 00000000000..4f6a04be45a --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/Wunknown-pragmas-1.c @@ -0,0 +1,29 @@ +/* Copyright 2003 Free Software Foundation, Inc. */ + +/* { dg-do compile } */ +/* { dg-options "-Wunknown-pragmas" } */ + +/* Make sure we get warnings in the expected lines. */ + +#pragma unknown1 /* { dg-warning "unknown1" "unknown1" } */ + +#define COMMA , +#define FOO(x) x +#define BAR(x) _Pragma("unknown_before") x +#define BAZ(x) x _Pragma("unknown_after") + +int _Pragma("unknown2") bar1; /* { dg-warning "unknown2" "unknown2" } */ + +FOO(int _Pragma("unknown3") bar2); /* { dg-warning "unknown3" "unknown3" } */ + +int BAR(bar3); /* { dg-warning "unknown_before" "unknown_before 1" } */ + +BAR(int bar4); /* { dg-warning "unknown_before" "unknown_before 2" } */ + +int BAZ(bar5); /* { dg-warning "unknown_after" "unknown_after 1" } */ + +int BAZ(bar6;) /* { dg-warning "unknown_after" "unknown_after 2" } */ + +FOO(int bar7; _Pragma("unknown4")) /* { dg-warning "unknown4" "unknown4" } */ + +#pragma unknown5 /* { dg-warning "unknown5" "unknown5" } */ diff --git a/gcc/testsuite/gcc.dg/cpp/separate-1.c b/gcc/testsuite/gcc.dg/cpp/separate-1.c new file mode 100644 index 00000000000..a80e0014929 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/separate-1.c @@ -0,0 +1,15 @@ +/* Copyright 2003 Free Software Foundation. */ + +/* { dg-do compile } */ +/* { dg-options "-save-temps" } */ + +/* Make sure we report errors in the right line, even if separate + preprocessing is used. */ + +#define FOO() + +int FOO( /* { dg-error "(parse|syntax) error" "error on this line" } */ + ), bar; + +int baz FOO /* { dg-error "(parse|syntax) error" "error on this line" } */ +; /* { dg-warning "no type or storage class" "warning on this line" } */ diff --git a/gcc/testsuite/gcc.dg/darwin-abi-1.c b/gcc/testsuite/gcc.dg/darwin-abi-1.c new file mode 100644 index 00000000000..c7c0288e8bb --- /dev/null +++ b/gcc/testsuite/gcc.dg/darwin-abi-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile { target powerpc*-*-darwin* } } */ +/* { dg-options "-O" } */ +/* { dg-final { scan-assembler "li r3,12345\n\tbl " } } */ + +/* Check that zero-size structures don't affect parameter passing. */ + +struct empty { }; +extern void foo (struct empty e, int a); +void bar (void) { + struct empty e; + foo (e, 12345); +} diff --git a/gcc/testsuite/gcc.dg/noncompile/20030818-1.c b/gcc/testsuite/gcc.dg/noncompile/20030818-1.c new file mode 100644 index 00000000000..71b89ec6fa7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/noncompile/20030818-1.c @@ -0,0 +1,3 @@ +/* PR 11207. */ + +char font8x8[256][8] = { [-1] = { 0 } }; /* { dg-error "array index|near init" } */ diff --git a/gcc/testsuite/gcc.dg/ultrasp10.c b/gcc/testsuite/gcc.dg/ultrasp10.c new file mode 100644 index 00000000000..ffa3229fa4f --- /dev/null +++ b/gcc/testsuite/gcc.dg/ultrasp10.c @@ -0,0 +1,25 @@ +/* PR target/11965 */ +/* Originator: <jk@tools.de> */ +/* { dg-do run { target sparc*-*-* } } */ +/* { dg-options "-O -mcpu=ultrasparc" } */ + +/* This used to fail on 32-bit Ultrasparc because GCC emitted + an invalid shift instruction. */ + + +static inline unsigned int shift(int n, unsigned int value) +{ + return value << n; +} + +unsigned int val = 1; + +int main(void) +{ + int i; + + for (i = 0; i < 4; i++) + val = shift(32, val); + + return 0; +} |