diff options
author | no-author <no-author@gcc.gnu.org> | 2005-05-31 16:28:30 +0000 |
---|---|---|
committer | no-author <no-author@gcc.gnu.org> | 2005-05-31 16:28:30 +0000 |
commit | 2daf1f9f78fb5927ed943c03cf85c3a1388f645c (patch) | |
tree | fef59aca747b1f76a0c0adbaf2c0dc9ccca9c631 | |
parent | 2e297bfc5dde9de799e7343d4849e44046963fa3 (diff) |
This commit was manufactured by cvs2svn to create branch
'csl-3_4_3-linux-branch'.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/csl-3_4_3-linux-branch@100395 138bc75d-0d04-0410-961f-82ee72b054a4
61 files changed, 1793 insertions, 0 deletions
diff --git a/gcc/config/rs6000/linux-unwind.h b/gcc/config/rs6000/linux-unwind.h new file mode 100644 index 00000000000..1acf738123e --- /dev/null +++ b/gcc/config/rs6000/linux-unwind.h @@ -0,0 +1,324 @@ +/* DWARF2 EH unwinding support for PowerPC and PowerPC64 Linux. + Copyright (C) 2004, 2005 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC 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. + + In addition to the permissions in the GNU General Public License, + the Free Software Foundation gives you unlimited permission to link + the compiled version of this file with other programs, and to + distribute those programs without any restriction coming from the + use of this file. (The General Public License restrictions do + apply in other respects; for example, they cover modification of + the file, and distribution when not linked into another program.) + + GCC 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 GCC; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA. */ + +/* This file defines our own versions of various kernel and user + structs, so that system headers are not needed, which otherwise + can make bootstrapping a new toolchain difficult. Do not use + these structs elsewhere; Many fields are missing, particularly + from the end of the structures. */ + +struct gcc_vregs +{ + __attribute__ ((vector_size (16))) int vr[32]; +#ifdef __powerpc64__ + unsigned int pad1[3]; + unsigned int vscr; + unsigned int vsave; + unsigned int pad2[3]; +#else + unsigned int vsave; + unsigned int pad[2]; + unsigned int vscr; +#endif +}; + +struct gcc_regs +{ + unsigned long gpr[32]; + unsigned long nip; + unsigned long msr; + unsigned long orig_gpr3; + unsigned long ctr; + unsigned long link; + unsigned long xer; + unsigned long ccr; + unsigned long softe; + unsigned long trap; + unsigned long dar; + unsigned long dsisr; + unsigned long result; + unsigned long pad1[4]; + double fpr[32]; + unsigned int pad2; + unsigned int fpscr; +#ifdef __powerpc64__ + struct gcc_vregs *vp; +#else + unsigned int pad3[2]; +#endif + struct gcc_vregs vregs; +}; + +struct gcc_ucontext +{ +#ifdef __powerpc64__ + unsigned long pad[28]; +#else + unsigned long pad[12]; +#endif + struct gcc_regs *regs; + struct gcc_regs rsave; +}; + +#ifdef __powerpc64__ + +enum { SIGNAL_FRAMESIZE = 128 }; + +/* If the current unwind info (FS) does not contain explicit info + saving R2, then we have to do a minor amount of code reading to + figure out if it was saved. The big problem here is that the + code that does the save/restore is generated by the linker, so + we have no good way to determine at compile time what to do. */ + +#define MD_FROB_UPDATE_CONTEXT frob_update_context + +static void +frob_update_context (struct _Unwind_Context *context, _Unwind_FrameState *fs) +{ + if (fs->regs.reg[2].how == REG_UNSAVED) + { + unsigned int *insn + = (unsigned int *) _Unwind_GetGR (context, LINK_REGISTER_REGNUM); + if (*insn == 0xE8410028) + _Unwind_SetGRPtr (context, 2, context->cfa + 40); + } +} + +/* If PC is at a sigreturn trampoline, return a pointer to the + regs. Otherwise return NULL. */ + +static struct gcc_regs * +get_regs (struct _Unwind_Context *context) +{ + const unsigned char *pc = context->ra; + + /* addi r1, r1, 128; li r0, 0x0077; sc (sigreturn) */ + /* addi r1, r1, 128; li r0, 0x00AC; sc (rt_sigreturn) */ + if (*(unsigned int *) (pc + 0) != 0x38210000 + SIGNAL_FRAMESIZE + || *(unsigned int *) (pc + 8) != 0x44000002) + return NULL; + if (*(unsigned int *) (pc + 4) == 0x38000077) + { + struct sigframe { + char gap[SIGNAL_FRAMESIZE]; + unsigned long pad[7]; + struct gcc_regs *regs; + } *frame = (struct sigframe *) context->cfa; + return frame->regs; + } + else if (*(unsigned int *) (pc + 4) == 0x380000AC) + { + /* This works for 2.4 kernels, but not for 2.6 kernels with vdso + because pc isn't pointing into the stack. Can be removed when + no one is running 2.4.19 or 2.4.20, the first two ppc64 + kernels released. */ + struct rt_sigframe_24 { + int tramp[6]; + void *pinfo; + struct gcc_ucontext *puc; + } *frame24 = (struct rt_sigframe_24 *) pc; + + /* Test for magic value in *puc of vdso. */ + if ((long) frame24->puc != -21 * 8) + return frame24->puc->regs; + else + { + /* This works for 2.4.21 and later kernels. */ + struct rt_sigframe { + char gap[SIGNAL_FRAMESIZE]; + struct gcc_ucontext uc; + unsigned long pad[2]; + int tramp[6]; + void *pinfo; + struct gcc_ucontext *puc; + } *frame = (struct rt_sigframe *) context->cfa; + return frame->uc.regs; + } + } + return NULL; +} + +#else /* !__powerpc64__ */ + +enum { SIGNAL_FRAMESIZE = 64 }; + +static struct gcc_regs * +get_regs (struct _Unwind_Context *context) +{ + const unsigned char *pc = context->ra; + + /* li r0, 0x7777; sc (sigreturn old) */ + /* li r0, 0x0077; sc (sigreturn new) */ + /* li r0, 0x6666; sc (rt_sigreturn old) */ + /* li r0, 0x00AC; sc (rt_sigreturn new) */ + if (*(unsigned int *) (pc + 4) != 0x44000002) + return NULL; + if (*(unsigned int *) (pc + 0) == 0x38007777 + || *(unsigned int *) (pc + 0) == 0x38000077) + { + struct sigframe { + char gap[SIGNAL_FRAMESIZE]; + unsigned long pad[7]; + struct gcc_regs *regs; + } *frame = (struct sigframe *) context->cfa; + return frame->regs; + } + else if (*(unsigned int *) (pc + 0) == 0x38006666 + || *(unsigned int *) (pc + 0) == 0x380000AC) + { + struct rt_sigframe { + char gap[SIGNAL_FRAMESIZE + 16]; + char siginfo[128]; + struct gcc_ucontext uc; + } *frame = (struct rt_sigframe *) context->cfa; + return frame->uc.regs; + } + return NULL; +} +#endif + +/* Find an entry in the process auxiliary vector. The canonical way to + test for VMX is to look at AT_HWCAP. */ + +static long +ppc_linux_aux_vector (long which) +{ + /* __libc_stack_end holds the original stack passed to a process. */ + extern long *__libc_stack_end; + long argc; + char **argv; + char **envp; + struct auxv + { + long a_type; + long a_val; + } *auxp; + + /* The Linux kernel puts argc first on the stack. */ + argc = __libc_stack_end[0]; + /* Followed by argv, NULL terminated. */ + argv = (char **) __libc_stack_end + 1; + /* Followed by environment string pointers, NULL terminated. */ + envp = argv + argc + 1; + while (*envp++) + continue; + /* Followed by the aux vector, zero terminated. */ + for (auxp = (struct auxv *) envp; auxp->a_type != 0; ++auxp) + if (auxp->a_type == which) + return auxp->a_val; + return 0; +} + +/* Do code reading to identify a signal frame, and set the frame + state data appropriately. See unwind-dw2.c for the structs. */ + +#define MD_FALLBACK_FRAME_STATE_FOR ppc_fallback_frame_state + +static _Unwind_Reason_Code +ppc_fallback_frame_state (struct _Unwind_Context *context, + _Unwind_FrameState *fs) +{ + static long hwcap = 0; + struct gcc_regs *regs = get_regs (context); + long new_cfa; + int i; + + if (regs == NULL) + return _URC_END_OF_STACK; + + new_cfa = regs->gpr[STACK_POINTER_REGNUM]; + fs->cfa_how = CFA_REG_OFFSET; + fs->cfa_reg = STACK_POINTER_REGNUM; + fs->cfa_offset = new_cfa - (long) context->cfa; + + for (i = 0; i < 32; i++) + if (i != STACK_POINTER_REGNUM) + { + fs->regs.reg[i].how = REG_SAVED_OFFSET; + fs->regs.reg[i].loc.offset = (long) ®s->gpr[i] - new_cfa; + } + + fs->regs.reg[CR2_REGNO].how = REG_SAVED_OFFSET; + fs->regs.reg[CR2_REGNO].loc.offset = (long) ®s->ccr - new_cfa; + + fs->regs.reg[LINK_REGISTER_REGNUM].how = REG_SAVED_OFFSET; + fs->regs.reg[LINK_REGISTER_REGNUM].loc.offset = (long) ®s->link - new_cfa; + + fs->regs.reg[ARG_POINTER_REGNUM].how = REG_SAVED_OFFSET; + fs->regs.reg[ARG_POINTER_REGNUM].loc.offset = (long) ®s->nip - new_cfa; + fs->retaddr_column = ARG_POINTER_REGNUM; + + if (hwcap == 0) + { + hwcap = ppc_linux_aux_vector (16); + /* These will already be set if we found AT_HWCAP. A non-zero + value stops us looking again if for some reason we couldn't + find AT_HWCAP. */ +#ifdef __powerpc64__ + hwcap |= 0xc0000000; +#else + hwcap |= 0x80000000; +#endif + } + + /* If we have a FPU... */ + if (hwcap & 0x08000000) + for (i = 0; i < 32; i++) + { + fs->regs.reg[i + 32].how = REG_SAVED_OFFSET; + fs->regs.reg[i + 32].loc.offset = (long) ®s->fpr[i] - new_cfa; + } + + /* If we have a VMX unit... */ + if (hwcap & 0x10000000) + { + struct gcc_vregs *vregs; +#ifdef __powerpc64__ + vregs = regs->vp; +#else + vregs = ®s->vregs; +#endif + if (regs->msr & (1 << 25)) + { + for (i = 0; i < 32; i++) + { + fs->regs.reg[i + FIRST_ALTIVEC_REGNO].how = REG_SAVED_OFFSET; + fs->regs.reg[i + FIRST_ALTIVEC_REGNO].loc.offset + = (long) &vregs[i] - new_cfa; + } + + fs->regs.reg[VSCR_REGNO].how = REG_SAVED_OFFSET; + fs->regs.reg[VSCR_REGNO].loc.offset = (long) &vregs->vscr - new_cfa; + } + + fs->regs.reg[VRSAVE_REGNO].how = REG_SAVED_OFFSET; + fs->regs.reg[VRSAVE_REGNO].loc.offset = (long) &vregs->vsave - new_cfa; + } + + return _URC_NO_REASON; +} diff --git a/gcc/testsuite/g++.dg/conversion/ambig1.C b/gcc/testsuite/g++.dg/conversion/ambig1.C new file mode 100644 index 00000000000..42ac4038ec6 --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/ambig1.C @@ -0,0 +1,8 @@ +// PR c++/19787 + +struct H { + operator char(); // { dg-error "" } + operator short(); // { dg-error "" } +}; + +int const& ref = H(); // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/ext/attrib19.C b/gcc/testsuite/g++.dg/ext/attrib19.C new file mode 100644 index 00000000000..f1362c3b484 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib19.C @@ -0,0 +1,10 @@ +// PR c++/19739 + +void Dummy() __attribute__(( , )); +void Dummy() {} + +int main (int argc, char **argv) +{ + Dummy(); + return 0; +} diff --git a/gcc/testsuite/g++.dg/ext/stmtexpr4.C b/gcc/testsuite/g++.dg/ext/stmtexpr4.C new file mode 100644 index 00000000000..a37c33ae086 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/stmtexpr4.C @@ -0,0 +1,8 @@ +// PR c++/20147 +// { dg-do compile } +// { dg-options "" } + +void foo() +{ + ({x;}); // { dg-error "was not declared" } +} diff --git a/gcc/testsuite/g++.dg/ext/visibility/arm2.C b/gcc/testsuite/g++.dg/ext/visibility/arm2.C new file mode 100644 index 00000000000..7eed18d7f85 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/visibility/arm2.C @@ -0,0 +1,11 @@ +// { dg-do compile { target arm*-*-*eabi* arm*-*-symbianelf* } } +// Class data should be exported. +// { dg-final { scan-not-hidden "_ZTV1S" } } +// { dg-final { scan-not-hidden "_ZTI1S" } } +// { dg-final { scan-not-hidden "_ZTS1S" } } + +struct S { + virtual void f(); +}; + +void S::f() {} diff --git a/gcc/testsuite/g++.dg/ext/visibility/arm3.C b/gcc/testsuite/g++.dg/ext/visibility/arm3.C new file mode 100644 index 00000000000..f97813d7f21 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/visibility/arm3.C @@ -0,0 +1,12 @@ +// { dg-do compile { target arm*-*-*eabi* } } +// { dg-options "-fvisibility=hidden" } +// Class data should be exported. +// { dg-final { scan-not-hidden "_ZTI1A" } } +// { dg-final { scan-not-hidden "_ZTS1A" } } +// { dg-final { scan-not-hidden "_ZTV1B" } } +// { dg-final { scan-not-hidden "_ZTI1B" } } +// { dg-final { scan-not-hidden "_ZTS1B" } } + +struct A {}; +struct B : virtual public A {}; +B b; diff --git a/gcc/testsuite/g++.dg/ext/visibility/symbian2.C b/gcc/testsuite/g++.dg/ext/visibility/symbian2.C new file mode 100644 index 00000000000..767f0b54e15 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/visibility/symbian2.C @@ -0,0 +1,11 @@ +// { dg-do compile { target arm*-*-symbianelf* } } +// Class data should not be exported. +// { dg-final { scan-hidden "_ZTI1A" } } +// { dg-final { scan-hidden "_ZTS1A" } } +// { dg-final { scan-hidden "_ZTV1B" } } +// { dg-final { scan-hidden "_ZTI1B" } } +// { dg-final { scan-hidden "_ZTS1B" } } + +struct A {}; +struct B : virtual public A {}; +B b; diff --git a/gcc/testsuite/g++.dg/inherit/covariant12.C b/gcc/testsuite/g++.dg/inherit/covariant12.C new file mode 100644 index 00000000000..434082abb0d --- /dev/null +++ b/gcc/testsuite/g++.dg/inherit/covariant12.C @@ -0,0 +1,18 @@ +// Copyright (C) 2004 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 27 Feb 2005<nathan@codesourcery.com> + +// PR 20232: ICE on invalid + +struct T { }; + +struct S; + +struct B +{ + virtual T *Foo (); // { dg-error "overriding" "" } +}; + +struct D : B +{ + virtual S *Foo (); // { dg-error "invalid covariant" "" } +}; diff --git a/gcc/testsuite/g++.dg/inherit/covariant13.C b/gcc/testsuite/g++.dg/inherit/covariant13.C new file mode 100644 index 00000000000..af60840c818 --- /dev/null +++ b/gcc/testsuite/g++.dg/inherit/covariant13.C @@ -0,0 +1,25 @@ +// Copyright (C) 2004 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 8 May 2005<nathan@codesourcery.com> + +// Origin:Andrew Pinski: pinskia@gcc.gnu.org +// PR 21427: ICE on valid + +struct B1 { + public: + virtual void foo(); +}; + +struct B2 { + public: + virtual B2 & bar() = 0; +}; + +struct I : public B1, B2 { + public: + virtual ~I(); + virtual I & bar(); +}; + +struct D : public I { + virtual ~D(); +}; diff --git a/gcc/testsuite/g++.dg/init/array18.C b/gcc/testsuite/g++.dg/init/array18.C new file mode 100644 index 00000000000..154d03fcff8 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/array18.C @@ -0,0 +1,22 @@ +// PR c++/20142 +// { dg-do run } + +int n=4; + +struct A +{ + A() {} + A& operator= (const A&) { --n; return *this; } +}; + +struct B +{ + A x[2][2]; +}; + +int main() +{ + B b; + b = b; + return n; +} diff --git a/gcc/testsuite/g++.dg/init/ptrmem2.C b/gcc/testsuite/g++.dg/init/ptrmem2.C new file mode 100644 index 00000000000..54b69215bb4 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/ptrmem2.C @@ -0,0 +1,12 @@ +// PR c++/19916 +// { dg-do run } + +struct S { + char k; +}; + +char const volatile S::* const p01 = &S::k; +int main(void) +{ + return 0; +} diff --git a/gcc/testsuite/g++.dg/lookup/using13.C b/gcc/testsuite/g++.dg/lookup/using13.C new file mode 100644 index 00000000000..c102fdcf872 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/using13.C @@ -0,0 +1,12 @@ +// { dg-do compile } + +// Origin: Stefan Straßer <sstrasser@systemhaus-gruppe.de> + +// PR c++/20240: + +namespace A { int a; } + +namespace C{ + int a; + using A::a; // { dg-error "already declared" } +} diff --git a/gcc/testsuite/g++.dg/opt/max1.C b/gcc/testsuite/g++.dg/opt/max1.C new file mode 100644 index 00000000000..10a6e57d92d --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/max1.C @@ -0,0 +1,29 @@ +/* PR middle-end/19068 */ +/* Test case by Andrew Pinski <pinskia@physics.uc.edu> */ +/* { dg-do run } */ +/* { dg-options "-O2 -Wno-deprecated" } */ + +extern "C" void abort (void); + +long fff[10]; + +void f(long a) +{ + int i; + a = *((long*)(a+1+sizeof(long))) >? *((long*)(a+1)); + + for(i=0;i<10;i++) + fff[i] = a; +} + +int main(void) +{ + int i; + long a[2] = {10,5}; + f((long)(&a)-1); + for(i = 0;i<10;i++) + if (fff[i]!=10) + abort (); + return 0; +} + diff --git a/gcc/testsuite/g++.dg/opt/pr20995-1.C b/gcc/testsuite/g++.dg/opt/pr20995-1.C new file mode 100644 index 00000000000..aa968963923 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr20995-1.C @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +template<int N> void foo() +{ + double d = (N ? 0.0 : 0) + 1; +} + diff --git a/gcc/testsuite/g++.dg/other/ptrmem6.C b/gcc/testsuite/g++.dg/other/ptrmem6.C new file mode 100644 index 00000000000..5fe796e1c04 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/ptrmem6.C @@ -0,0 +1,10 @@ +// PR c++/19666 +// Origin: Volker Reichelt <reichelt@gcc.gnu.org> +// { dg-do compile } + +struct A { int i; }; + +int foo (A *p) +{ + return &p->i - &(p->*&A::i); +} diff --git a/gcc/testsuite/g++.dg/overload/using2.C b/gcc/testsuite/g++.dg/overload/using2.C new file mode 100644 index 00000000000..2ecb5fad6b0 --- /dev/null +++ b/gcc/testsuite/g++.dg/overload/using2.C @@ -0,0 +1,87 @@ +// { dg-do compile } + +// Copyright 2005 Free Software Foundation +// by Alexandre Oliva <aoliva@redhat.com> +// based on https://bugzilla.redhat.com/beta/show_bug.cgi?id=149098 + +// Per the ISO C++ 90 Standard, using declarations before of after a +// declaration of the same function name and prototype should be +// errors (7.3.3/11). However, DR 101's resolution recommends +// accepting such duplicates if they denote the same function, which +// means extern "C" declarations are supposed to match and be +// accepted. + +// This test makes sure we reject or accept regular and using +// declarations regardless of order as appropriate, and that having +// built-in declarations or overloads doesn't affet the outcome. + +namespace std { + extern "C" void exit (int) throw (); // these are built-in (extern "C") + extern "C" void *malloc (__SIZE_TYPE__) throw () __attribute__((malloc)); + + void abort (void) throw (); // these aren't + void _exit (int) throw (); // { dg-error "std::_exit" } + + extern "C" void c1 (void) throw (); + void C1 (void) throw (); // { dg-error "std::C1" } + + extern "C" void c2 (void) throw (); + void C2 (void) throw (); + + extern "C" void c3 (void) throw (); + void C3 (void) throw (); // { dg-error "std::C3" } +} + +namespace other { + extern "C" void c3 (void) throw (); + void C3 (void) throw (); // { dg-error "other::C3" } +} + +using std::exit; +using std::_exit; +using std::c1; +using std::C1; + + extern "C" void exit (int) throw (); + extern "C" void *malloc (__SIZE_TYPE__) throw () __attribute__((malloc)); + + void abort (void) throw (); + void _exit (int) throw (); // { dg-error "conflicts|void _exit" } + + extern "C" void c1 (void) throw (); + void C1 (void) throw (); // { dg-error "conflicts|void C1" } + + extern "C" void c2 (void) throw (); + void C2 (void) throw (); + + int C3 (int) throw (); + +using std::malloc; +using std::abort; // { dg-error "already declared" } +using std::c2; +using std::C2; // { dg-error "already declared" } + +using std::c3; using other::c3; +using std::C3; using other::C3; + + long C3 (long) throw (); + +int main () { + malloc (0); + exit (0); + + _exit (0); // { dg-error "ambiguous" } + abort (); + + c1 (); + C1 (); // { dg-error "ambiguous" } + + c2 (); + C2 (); // one might expect an ambiguous call error here as well, but + // we don't add the using decl if we find it to be in error. + + c3 (); + C3 (); // { dg-error "ambiguous" } + C3 (0); + C3 (0l); +} diff --git a/gcc/testsuite/g++.dg/parse/constant7.C b/gcc/testsuite/g++.dg/parse/constant7.C new file mode 100644 index 00000000000..c54ad55c1f0 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/constant7.C @@ -0,0 +1,9 @@ +// PR c++/19991 + +enum { e = 1 }; + +template<typename> struct A +{ + static const int i = e; + char a[i]; +}; diff --git a/gcc/testsuite/g++.dg/parse/crash23.C b/gcc/testsuite/g++.dg/parse/crash23.C new file mode 100644 index 00000000000..19ad70a6454 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/crash23.C @@ -0,0 +1,12 @@ +// PR c++/19733 + +struct A {}; +typedef int I; +void foo() { + A().~A; // { dg-error "" } + A().A::~A; // { dg-error "" } + (int().I::~I, 3); // { dg-error "" } + int().I::~I; // { dg-error "" } +} + + diff --git a/gcc/testsuite/g++.dg/parse/typename7.C b/gcc/testsuite/g++.dg/parse/typename7.C new file mode 100644 index 00000000000..56fcc7436a4 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/typename7.C @@ -0,0 +1,31 @@ +// { dg-do compile } + +// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de> and +// Alexandre Oliva <aoliva@redhat.com> + +// PR c++/18757: ICE in get_innermost_template_args + +struct A +{ + template<typename> void foo(int); + template<typename T> void bar(T t) { + this->foo<typename T>(t); } // { dg-error "expected|parse error|no matching" } + template<typename T> void bad(T t) { + foo<typename T>(t); } // { dg-error "expected|parse error" } +}; + +template <typename T> +struct B +{ + void bar(T t) { + A().bar<typename T>(t); } // { dg-error "expected|parse error|no matching" } + void bad(T t) { + B<typename T>::bar(t); } // { dg-error "invalid|not a template" } +}; + +void baz() +{ + A().bar(0); + A().bad(0); + B<int>().bar(0); +} diff --git a/gcc/testsuite/g++.dg/template/crash34.C b/gcc/testsuite/g++.dg/template/crash34.C new file mode 100644 index 00000000000..9cca62f0539 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash34.C @@ -0,0 +1,12 @@ +// { dg-do compile } + +// PR c++/20028 + +// We used to crash when referencing TYPE_SIZE_UNIT of the messed-up +// type used for x, because it was not initialized. + +class Foo; + +template <typename T> class Foo { }; // { dg-error "not a template type" } + +Foo<int> x; // { dg-error "not a template" } diff --git a/gcc/testsuite/g++.dg/template/crash36.C b/gcc/testsuite/g++.dg/template/crash36.C new file mode 100644 index 00000000000..2f0ef921a67 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash36.C @@ -0,0 +1,9 @@ +// { dg-do compile } + +// Origin: Ivan Godard <igodard@pacbell.net> +// Andrew Pinski <pinskia@gcc.gnu.org> + +// PR c++/20333: ICE parsing typename without nested-name-specifier + +template<class> struct f {}; +f<int> f2[2] = {typename f<int>()}; // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/template/dtor3.C b/gcc/testsuite/g++.dg/template/dtor3.C new file mode 100644 index 00000000000..7f4099861fb --- /dev/null +++ b/gcc/testsuite/g++.dg/template/dtor3.C @@ -0,0 +1,4 @@ +// PR c++/19762 + +template<int> struct A { ~A(){} }; // { dg-error "" } +template A<>::~A(); // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/template/enum5.C b/gcc/testsuite/g++.dg/template/enum5.C new file mode 100644 index 00000000000..b7a49f45d0f --- /dev/null +++ b/gcc/testsuite/g++.dg/template/enum5.C @@ -0,0 +1,16 @@ +// { dg-do compile } + +// Origin: robertk@mathematik.uni-freiburg.de +// Wolfgang Bangerth <bangerth@ticam.utexas.edu> + +// PR c++/14479: Template header check for enum + +template <int dim> +struct X { + enum { dimension = dim }; + template<int d> void bar (); +}; + +template <> +template <> +void X<0>::bar<0> () {} diff --git a/gcc/testsuite/g++.dg/template/non-dependent11.C b/gcc/testsuite/g++.dg/template/non-dependent11.C new file mode 100644 index 00000000000..dff5b909d95 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/non-dependent11.C @@ -0,0 +1,18 @@ +// { dg-do compile } + +// Origin: Jakub Jelinek <jakub@gcc.gnu.org> +// Wolfgang Bangerth <bangerth@ticam.utexas.edu> + +// PR c++/19311: Non-dependent address to member as function argument. + +template <class R, class T> void foo (R (T::*x) ()); +template <class R, class T, class C> void foo (R (T::*x) (C)); + +template<int> struct I { + int o (); + int o () const; +}; + +template <int> void bar (void) { + foo <int, I<1> > (&I<1>::o); +} diff --git a/gcc/testsuite/g++.dg/template/overload4.C b/gcc/testsuite/g++.dg/template/overload4.C new file mode 100644 index 00000000000..1a294eb3c05 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/overload4.C @@ -0,0 +1,20 @@ +// PR c++/20679 + +template <class T> +struct foo +{ + struct bar + { + int m; + }; + + void m() const {} + void m() {} + + bool n() const { return b->m < 42; } + + bar *b; +}; + + + diff --git a/gcc/testsuite/g++.dg/template/ptrmem14.C b/gcc/testsuite/g++.dg/template/ptrmem14.C new file mode 100644 index 00000000000..30eb1ebcc19 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/ptrmem14.C @@ -0,0 +1,12 @@ +// PR c++/15875 + +struct A +{ + void foo(); +}; + +template<int> void bar() +{ + typedef void (A::*fptr)(); + fptr ptr = &A::foo; +} diff --git a/gcc/testsuite/g++.dg/template/sizeof9.C b/gcc/testsuite/g++.dg/template/sizeof9.C new file mode 100644 index 00000000000..8d9ec95ae1f --- /dev/null +++ b/gcc/testsuite/g++.dg/template/sizeof9.C @@ -0,0 +1,6 @@ +// PR c++/21025 + +template<int N> struct X { char x[N]; }; +template<typename T> X<1 + sizeof(T) - sizeof(T)> F(T const &); +template<int N> struct S { int d() { F(1); } }; + diff --git a/gcc/testsuite/g++.dg/warn/Wbraces1.C b/gcc/testsuite/g++.dg/warn/Wbraces1.C new file mode 100644 index 00000000000..0efce7be3ff --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wbraces1.C @@ -0,0 +1,3 @@ +// PR c++/19755 +// { dg-options "-Wmissing-braces" } +int a[2][2] = { 0, 1 , 2, 3 }; // { dg-warning "" } diff --git a/gcc/testsuite/g++.dg/warn/Wbraces2.C b/gcc/testsuite/g++.dg/warn/Wbraces2.C new file mode 100644 index 00000000000..b51d5ca77b9 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wbraces2.C @@ -0,0 +1,15 @@ +// PR c++/20175 +// { dg-options "-Wmissing-braces" } +int a[2][2] = { 0, 1, 2, 3 }; // { dg-warning "missing braces" } +int b[2][2] = { { 0, 1 }, { 2, 3 } }; +int c[2][2] = { { { 0 }, 1 }, { 2, 3 } }; // { dg-error "brace-enclosed" } +struct S { char s[6]; int i; }; +S d = { "hello", 1 }; +S e = { { "hello" }, 1 }; +S f = { { { "hello" } }, 1 }; // { dg-error "brace-enclosed" } +S g = { 'h', 'e', 'l', 'l', 'o', '\0', 1 }; // { dg-warning "missing braces" } +struct T { wchar_t s[6]; int i; }; +T i = { L"hello", 1 }; +T j = { { L"hello" }, 1 }; +T k = { { { L"hello" } }, 1 }; // { dg-error "brace-enclosed" } +T l = { L'h', L'e', L'l', L'l', L'o', L'\0', 1 };// { dg-warning "missing braces" } diff --git a/gcc/testsuite/gcc.c-torture/compile/20050113-1.c b/gcc/testsuite/gcc.c-torture/compile/20050113-1.c new file mode 100644 index 00000000000..6e36ed6fd7c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20050113-1.c @@ -0,0 +1,16 @@ +/* PR c/17297 */ + +typedef float V2SF __attribute__ ((vector_size (8))); + +int test0 (V2SF, V2SF); + +int +main (void) +{ + V2SF a = (V2SF) {1.0f/0.0f - 1.0f/0.0f, 1.0f/0.0f - 1.0f/0.0f}; + V2SF b = (V2SF) {567.345, 1984.0}; + int i; + + i = test0 (a, b); + return i; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/20050121-1.c b/gcc/testsuite/gcc.c-torture/execute/20050121-1.c new file mode 100644 index 00000000000..9d5dec41642 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20050121-1.c @@ -0,0 +1,63 @@ +/* PR middle-end/19551 */ + +extern void abort (); + +#define T(type, name) \ +__attribute__((pure)) _Complex type \ +foo_##name (int x) \ +{ \ + _Complex type r; \ + __real r = x + 1; \ + __imag r = x - 1; \ + return r; \ +} \ + \ +void \ +bar_##name (type *x) \ +{ \ + *x = __real foo_##name (5); \ +} \ + \ +void \ +baz_##name (type *x) \ +{ \ + *x = __imag foo_##name (5); \ +} + +typedef long double ldouble_t; +typedef long long llong; + +T (float, float) +T (double, double) +T (long double, ldouble_t) +T (char, char) +T (short, short) +T (int, int) +T (long, long) +T (long long, llong) +#undef T + +int +main (void) +{ +#define T(type, name) \ + { \ + type var = 0; \ + bar_##name (&var); \ + if (var != 6) \ + abort (); \ + var = 0; \ + baz_##name (&var); \ + if (var != 4) \ + abort (); \ + } + T (float, float) + T (double, double) + T (long double, ldouble_t) + T (char, char) + T (short, short) + T (int, int) + T (long, long) + T (long long, llong) + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/20050124-1.c b/gcc/testsuite/gcc.c-torture/execute/20050124-1.c new file mode 100644 index 00000000000..9d039ef6623 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20050124-1.c @@ -0,0 +1,41 @@ +/* PR rtl-optimization/19579 */ + +extern void abort (void); + +int +foo (int i, int j) +{ + int k = i + 1; + + if (j) + { + if (k > 0) + k++; + else if (k < 0) + k--; + } + + return k; +} + +int +main (void) +{ + if (foo (-2, 0) != -1) + abort (); + if (foo (-1, 0) != 0) + abort (); + if (foo (0, 0) != 1) + abort (); + if (foo (1, 0) != 2) + abort (); + if (foo (-2, 1) != -2) + abort (); + if (foo (-1, 1) != 0) + abort (); + if (foo (0, 1) != 2) + abort (); + if (foo (1, 1) != 3) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/20041216-1.c b/gcc/testsuite/gcc.dg/20041216-1.c new file mode 100644 index 00000000000..3f892a2e375 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20041216-1.c @@ -0,0 +1,23 @@ +/* This test case would get an unresolved symbol during link + because stabs referred to an optimized-away literal pool + entry. */ + +/* { dg-do run { target s390*-*-* } } */ +/* { dg-options "-O2 -fno-omit-frame-pointer -gstabs" } */ + +int main (void) +{ + static char buf[4096]; + char *p; + + do + { + p = buf; + asm volatile ("" : : : "memory", "0", "1", "2", "3", "4", "5", "6", + "7", "8", "9", "10", "12"); + } + while (*p); + + return 0; +} + diff --git a/gcc/testsuite/gcc.dg/20050111-2.c b/gcc/testsuite/gcc.dg/20050111-2.c new file mode 100644 index 00000000000..17e59ce968c --- /dev/null +++ b/gcc/testsuite/gcc.dg/20050111-2.c @@ -0,0 +1,21 @@ +/* PR rtl-optimization/15139 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -funroll-loops" } */ + +void +foo (double **a, double **z) +{ + long int i, j; + double d = -1.0; + + for (i = 0; i < 6; i++) + for (j = 0; j < 5; j++) + d = z[i][j] > d ? z[i][j] : d; + + for (i = 0; i < 6; i++) + for (j = 0; j < 5; j++) + z[i][j] /= d; + + for (i = 0; i < 5; i++) + a[i][j] = z[i][j]; +} diff --git a/gcc/testsuite/gcc.dg/20050113-1.c b/gcc/testsuite/gcc.dg/20050113-1.c new file mode 100644 index 00000000000..e7f69e36641 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20050113-1.c @@ -0,0 +1,6 @@ +/* PR middle-end/19164 */ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-mmmx" } */ + +typedef short int V __attribute__ ((vector_size (8))); +static V v = (V) 0x00FF00FF00FF00FFLL; /* { dg-error "is not constant" } */ diff --git a/gcc/testsuite/gcc.dg/arm-vfp1.c b/gcc/testsuite/gcc.dg/arm-vfp1.c new file mode 100644 index 00000000000..5898e8027e6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/arm-vfp1.c @@ -0,0 +1,127 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mfpu=vfp -mfloat-abi=softfp" } */ +/* { dg-require-effective-target arm32 } */ + +extern float fabsf (float); +extern float sqrtf (float); +extern double fabs (double); +extern double sqrt (double); + +volatile float f1, f2, f3; + +void test_sf() { + /* abssf2_vfp */ + /* { dg-final { scan-assembler "fabss" } } */ + f1 = fabsf (f1); + /* negsf2_vfp */ + /* { dg-final { scan-assembler "fnegs" } } */ + f1 = -f1; + /* addsf3_vfp */ + /* { dg-final { scan-assembler "fadds" } } */ + f1 = f2 + f3; + /* subsf3_vfp */ + /* { dg-final { scan-assembler "fsubs" } } */ + f1 = f2 - f3; + /* divsf3_vfp */ + /* { dg-final { scan-assembler "fdivs" } } */ + f1 = f2 / f3; + /* mulsf3_vfp */ + /* { dg-final { scan-assembler "fmuls" } } */ + f1 = f2 * f3; + /* mulsf3negsf_vfp */ + /* { dg-final { scan-assembler "fnmuls" } } */ + f1 = -f2 * f3; + /* mulsf3addsf_vfp */ + /* { dg-final { scan-assembler "fmacs" } } */ + f1 = f2 * f3 + f1; + /* mulsf3subsf_vfp */ + /* { dg-final { scan-assembler "fmscs" } } */ + f1 = f2 * f3 - f1; + /* mulsf3negsfaddsf_vfp */ + /* { dg-final { scan-assembler "fnmacs" } } */ + f1 = f2 - f3 * f1; + /* mulsf3negsfsubsf_vfp */ + /* { dg-final { scan-assembler "fnmscs" } } */ + f1 = -f2 * f3 - f1; + /* sqrtsf2_vfp */ + /* { dg-final { scan-assembler "fsqrts" } } */ + f1 = sqrtf (f1); +} + +volatile double d1, d2, d3; + +void test_df() { + /* absdf2_vfp */ + /* { dg-final { scan-assembler "fabsd" } } */ + d1 = fabs (d1); + /* negdf2_vfp */ + /* { dg-final { scan-assembler "fnegd" } } */ + d1 = -d1; + /* adddf3_vfp */ + /* { dg-final { scan-assembler "faddd" } } */ + d1 = d2 + d3; + /* subdf3_vfp */ + /* { dg-final { scan-assembler "fsubd" } } */ + d1 = d2 - d3; + /* divdf3_vfp */ + /* { dg-final { scan-assembler "fdivd" } } */ + d1 = d2 / d3; + /* muldf3_vfp */ + /* { dg-final { scan-assembler "fmuld" } } */ + d1 = d2 * d3; + /* muldf3negdf_vfp */ + /* { dg-final { scan-assembler "fnmuld" } } */ + d1 = -d2 * d3; + /* muldf3adddf_vfp */ + /* { dg-final { scan-assembler "fmacd" } } */ + d1 = d2 * d3 + d1; + /* muldf3subdf_vfp */ + /* { dg-final { scan-assembler "fmscd" } } */ + d1 = d2 * d3 - d1; + /* muldf3negdfadddf_vfp */ + /* { dg-final { scan-assembler "fnmacd" } } */ + d1 = d2 - d3 * d1; + /* muldf3negdfsubdf_vfp */ + /* { dg-final { scan-assembler "fnmscd" } } */ + d1 = -d2 * d3 - d1; + /* sqrtdf2_vfp */ + /* { dg-final { scan-assembler "fsqrtd" } } */ + d1 = sqrt (d1); +} + +volatile int i1; +volatile unsigned int u1; + +void test_convert () { + /* extendsfdf2_vfp */ + /* { dg-final { scan-assembler "fcvtds" } } */ + d1 = f1; + /* truncdfsf2_vfp */ + /* { dg-final { scan-assembler "fcvtsd" } } */ + f1 = d1; + /* truncsisf2_vfp */ + /* { dg-final { scan-assembler "ftosizs" } } */ + i1 = f1; + /* truncsidf2_vfp */ + /* { dg-final { scan-assembler "ftosizd" } } */ + i1 = d1; + /* fixuns_truncsfsi2 */ + /* { dg-final { scan-assembler "ftouizs" } } */ + u1 = f1; + /* fixuns_truncdfsi2 */ + /* { dg-final { scan-assembler "ftouizd" } } */ + u1 = d1; + /* floatsisf2_vfp */ + /* { dg-final { scan-assembler "fsitos" } } */ + f1 = i1; + /* floatsidf2_vfp */ + /* { dg-final { scan-assembler "fsitod" } } */ + d1 = i1; + /* floatunssisf2 */ + /* { dg-final { scan-assembler "fuitos" } } */ + f1 = u1; + /* floatunssidf2 */ + /* { dg-final { scan-assembler "fuitod" } } */ + d1 = u1; +} + diff --git a/gcc/testsuite/gcc.dg/builtins-47.c b/gcc/testsuite/gcc.dg/builtins-47.c new file mode 100644 index 00000000000..b25ee1b9958 --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtins-47.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-ffast-math -fdump-tree-gimple" } */ + +extern double sqrt (double); +extern double pow (double, double); +extern void abort (void); + +int main () +{ + double x = -1.0; + if (sqrt (pow (x, 2)) != 1.0) + abort(); + if (sqrt (x*x) != 1.0) + abort(); + return 0; +} + +/* { dg-final { scan-tree-dump-times "sqrt" 0 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "pow" 0 "gimple" } } */ +/* { dg-final { cleanup-tree-dump "gimple" } } */ diff --git a/gcc/testsuite/gcc.dg/cpp/20050215-1.c b/gcc/testsuite/gcc.dg/cpp/20050215-1.c new file mode 100644 index 00000000000..e5aaf220e3e --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/20050215-1.c @@ -0,0 +1,10 @@ +/* Testcase for memory corruption bug in macro processing. + See PR preprocessor/19077 for details. */ + +/* { dg-do compile } */ +/* { dg-options "-g3" } */ +#define FOO(a,b,c,d,e) a b c d e \ +" " \ +" " \ +" " +int i; diff --git a/gcc/testsuite/gcc.dg/format/asm_fprintf-2.c b/gcc/testsuite/gcc.dg/format/asm_fprintf-2.c new file mode 100644 index 00000000000..847eeee282f --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/asm_fprintf-2.c @@ -0,0 +1,9 @@ +/* Test for ICE handling internal formats: bug 20740. The code did + not check that, if the required typedef names had been used as + identifiers, they were defined to suitable types. Test + "__gcc_host_wide_int__", not used at all, asm_fprintf format. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do compile } */ +/* { dg-options "-Wformat" } */ + +void bar (const char *, ...) __attribute__ ((__format__ (__asm_fprintf__, 1, 2))); /* { dg-error "error: '__gcc_host_wide_int__' is not defined as a type" } */ diff --git a/gcc/testsuite/gcc.dg/format/asm_fprintf-3.c b/gcc/testsuite/gcc.dg/format/asm_fprintf-3.c new file mode 100644 index 00000000000..f5fd5c022fc --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/asm_fprintf-3.c @@ -0,0 +1,10 @@ +/* Test for ICE handling internal formats: bug 20740. The code did + not check that, if the required typedef names had been used as + identifiers, they were defined to suitable types. Test + "__gcc_host_wide_int__", not defined, asm_fprintf format. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do compile } */ +/* { dg-options "-Wformat" } */ + +void foo (int __gcc_host_wide_int__); +void bar (const char *, ...) __attribute__ ((__format__ (__asm_fprintf__, 1, 2))); /* { dg-error "error: '__gcc_host_wide_int__' is not defined as a type" } */ diff --git a/gcc/testsuite/gcc.dg/format/asm_fprintf-4.c b/gcc/testsuite/gcc.dg/format/asm_fprintf-4.c new file mode 100644 index 00000000000..9de05134af3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/asm_fprintf-4.c @@ -0,0 +1,10 @@ +/* Test for ICE handling internal formats: bug 20740. The code did + not check that, if the required typedef names had been used as + identifiers, they were defined to suitable types. Test + "__gcc_host_wide_int__", not a type, asm_fprintf. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do compile } */ +/* { dg-options "-Wformat" } */ + +int __gcc_host_wide_int__; +void bar (const char *, ...) __attribute__ ((__format__ (__asm_fprintf__, 1, 2))); /* { dg-error "error: '__gcc_host_wide_int__' is not defined as a type" } */ diff --git a/gcc/testsuite/gcc.dg/format/asm_fprintf-5.c b/gcc/testsuite/gcc.dg/format/asm_fprintf-5.c new file mode 100644 index 00000000000..14ffb60d32e --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/asm_fprintf-5.c @@ -0,0 +1,10 @@ +/* Test for ICE handling internal formats: bug 20740. The code did + not check that, if the required typedef names had been used as + identifiers, they were defined to suitable types. Test + "__gcc_host_wide_int__", bad type, asm_fprintf format. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do compile } */ +/* { dg-options "-Wformat" } */ + +typedef int __gcc_host_wide_int__; +void bar (const char *, ...) __attribute__ ((__format__ (__asm_fprintf__, 1, 2))); /* { dg-error "error: '__gcc_host_wide_int__' is not defined as 'long' or 'long long'" } */ diff --git a/gcc/testsuite/gcc.dg/format/gcc_diag-2.c b/gcc/testsuite/gcc.dg/format/gcc_diag-2.c new file mode 100644 index 00000000000..60c6835da9e --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/gcc_diag-2.c @@ -0,0 +1,10 @@ +/* Test for ICE handling internal formats: bug 20740. The code did + not check that, if the required typedef names had been used as + identifiers, they were defined to suitable types. Test "tree", not + defined. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do compile } */ +/* { dg-options "-Wformat" } */ + +void foo (int tree); +void bar (const char *, ...) __attribute__ ((__format__ (__gcc_diag__, 1, 2))); diff --git a/gcc/testsuite/gcc.dg/format/gcc_diag-3.c b/gcc/testsuite/gcc.dg/format/gcc_diag-3.c new file mode 100644 index 00000000000..1a7848ed9f2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/gcc_diag-3.c @@ -0,0 +1,10 @@ +/* Test for ICE handling internal formats: bug 20740. The code did + not check that, if the required typedef names had been used as + identifiers, they were defined to suitable types. Test "tree", not + a type. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do compile } */ +/* { dg-options "-Wformat" } */ + +int tree; +void bar (const char *, ...) __attribute__ ((__format__ (__gcc_diag__, 1, 2))); /* { dg-error "error: 'tree' is not defined as a type" } */ diff --git a/gcc/testsuite/gcc.dg/format/gcc_diag-4.c b/gcc/testsuite/gcc.dg/format/gcc_diag-4.c new file mode 100644 index 00000000000..20661c41f71 --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/gcc_diag-4.c @@ -0,0 +1,10 @@ +/* Test for ICE handling internal formats: bug 20740. The code did + not check that, if the required typedef names had been used as + identifiers, they were defined to suitable types. Test "tree", not + a pointer type. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do compile } */ +/* { dg-options "-Wformat" } */ + +typedef int tree; +void bar (const char *, ...) __attribute__ ((__format__ (__gcc_diag__, 1, 2))); /* { dg-error "error: 'tree' is not defined as a pointer type" } */ diff --git a/gcc/testsuite/gcc.dg/format/gcc_diag-5.c b/gcc/testsuite/gcc.dg/format/gcc_diag-5.c new file mode 100644 index 00000000000..f8f12d68cdd --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/gcc_diag-5.c @@ -0,0 +1,10 @@ +/* Test for ICE handling internal formats: bug 20740. The code did + not check that, if the required typedef names had been used as + identifiers, they were defined to suitable types. Test + "location_t", not defined. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do compile } */ +/* { dg-options "-Wformat" } */ + +void foo (int location_t); +void bar (const char *, ...) __attribute__ ((__format__ (__gcc_diag__, 1, 2))); diff --git a/gcc/testsuite/gcc.dg/format/gcc_diag-6.c b/gcc/testsuite/gcc.dg/format/gcc_diag-6.c new file mode 100644 index 00000000000..fdb493d4973 --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/gcc_diag-6.c @@ -0,0 +1,10 @@ +/* Test for ICE handling internal formats: bug 20740. The code did + not check that, if the required typedef names had been used as + identifiers, they were defined to suitable types. Test + "location_t", not a type. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do compile } */ +/* { dg-options "-Wformat" } */ + +int location_t; +void bar (const char *, ...) __attribute__ ((__format__ (__gcc_diag__, 1, 2))); /* { dg-error "error: 'location_t' is not defined as a type" } */ diff --git a/gcc/testsuite/gcc.dg/format/gcc_diag-7.c b/gcc/testsuite/gcc.dg/format/gcc_diag-7.c new file mode 100644 index 00000000000..fccf5d24041 --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/gcc_diag-7.c @@ -0,0 +1,10 @@ +/* Test for ICE handling internal formats: bug 20740. The code did + not check that, if the required typedef names had been used as + identifiers, they were defined to suitable types. Test + "__gcc_host_wide_int__", not defined. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do compile } */ +/* { dg-options "-Wformat" } */ + +void foo (int __gcc_host_wide_int__); +void bar (const char *, ...) __attribute__ ((__format__ (__gcc_diag__, 1, 2))); diff --git a/gcc/testsuite/gcc.dg/format/gcc_diag-8.c b/gcc/testsuite/gcc.dg/format/gcc_diag-8.c new file mode 100644 index 00000000000..835ec3f98d3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/gcc_diag-8.c @@ -0,0 +1,10 @@ +/* Test for ICE handling internal formats: bug 20740. The code did + not check that, if the required typedef names had been used as + identifiers, they were defined to suitable types. Test + "__gcc_host_wide_int__", not a type. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do compile } */ +/* { dg-options "-Wformat" } */ + +int __gcc_host_wide_int__; +void bar (const char *, ...) __attribute__ ((__format__ (__gcc_diag__, 1, 2))); /* { dg-error "error: '__gcc_host_wide_int__' is not defined as a type" } */ diff --git a/gcc/testsuite/gcc.dg/format/gcc_diag-9.c b/gcc/testsuite/gcc.dg/format/gcc_diag-9.c new file mode 100644 index 00000000000..6481c26caf7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/gcc_diag-9.c @@ -0,0 +1,10 @@ +/* Test for ICE handling internal formats: bug 20740. The code did + not check that, if the required typedef names had been used as + identifiers, they were defined to suitable types. Test + "__gcc_host_wide_int__", bad type. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do compile } */ +/* { dg-options "-Wformat" } */ + +typedef int __gcc_host_wide_int__; +void bar (const char *, ...) __attribute__ ((__format__ (__gcc_diag__, 1, 2))); /* { dg-error "error: '__gcc_host_wide_int__' is not defined as 'long' or 'long long'" } */ diff --git a/gcc/testsuite/gcc.dg/ppc-eabi.c b/gcc/testsuite/gcc.dg/ppc-eabi.c new file mode 100644 index 00000000000..47ba1a73390 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ppc-eabi.c @@ -0,0 +1,4 @@ +/* PR target/16952 */ +/* { dg-do compile { target { powerpc*-*-linux* && ilp32 } } } */ +/* { dg-options "-meabi -mrelocatable" } */ +char *s = "boo"; diff --git a/gcc/testsuite/gcc.dg/pr12092-1.c b/gcc/testsuite/gcc.dg/pr12092-1.c new file mode 100644 index 00000000000..80c7546d9fb --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr12092-1.c @@ -0,0 +1,13 @@ +/* PR rtl-optimization/12092 */ +/* Test case reduced by Andrew Pinski <pinskia@physics.uc.edu> */ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-options "-O2 -mtune=i486 -march=pentium4 -fprefetch-loop-arrays" } */ + +void DecodeAC(int index,int *matrix) +{ + int *mptr; + + for(mptr=matrix+index;mptr<matrix+64;mptr++) {*mptr = 0;} +} + diff --git a/gcc/testsuite/gcc.dg/pr18502-1.c b/gcc/testsuite/gcc.dg/pr18502-1.c new file mode 100644 index 00000000000..038c8104aa8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr18502-1.c @@ -0,0 +1,7 @@ +/* Test that -trigraphs isn't reordered before -std=gnu99. Bug + 18502. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -trigraphs" } */ + +int a??(2??); diff --git a/gcc/testsuite/gcc.dg/setjmp-2.c b/gcc/testsuite/gcc.dg/setjmp-2.c new file mode 100644 index 00000000000..b44ac666145 --- /dev/null +++ b/gcc/testsuite/gcc.dg/setjmp-2.c @@ -0,0 +1,49 @@ +/* PR middle-end/17813 */ +/* Origin: Tom Hughes <tom@compton.nu> */ +/* { dg-do run { target i?86-*-linux* x86_64-*-linux* } } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-options "-O -fomit-frame-pointer -march=i386" { target { i?86-*-linux* && ilp32 } } } */ +/* { dg-options "-O -fomit-frame-pointer -march=i386" { target { x86_64-*-linux* && ilp32 } } } */ + +#include <setjmp.h> +#include <signal.h> +#include <stdlib.h> + +static jmp_buf segv_jmpbuf; + +static void segv_handler(int seg) +{ + __builtin_longjmp(segv_jmpbuf, 1); +} + +static int is_addressable(void *p, size_t size) +{ + volatile char * volatile cp = (volatile char *)p; + volatile int ret; + struct sigaction sa, origsa; + sigset_t mask; + + sa.sa_handler = segv_handler; + sa.sa_flags = 0; + sigfillset(&sa.sa_mask); + sigaction(SIGSEGV, &sa, &origsa); + sigprocmask(SIG_SETMASK, NULL, &mask); + + if (__builtin_setjmp(segv_jmpbuf) == 0) { + while(size--) + *cp++; + ret = 1; + } else + ret = 0; + + sigaction(SIGSEGV, &origsa, NULL); + sigprocmask(SIG_SETMASK, &mask, NULL); + + return ret; +} + +int main(int argc, char **argv) +{ + is_addressable(0x0, 1); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/short-compare-1.c b/gcc/testsuite/gcc.dg/short-compare-1.c new file mode 100644 index 00000000000..8c02a893347 --- /dev/null +++ b/gcc/testsuite/gcc.dg/short-compare-1.c @@ -0,0 +1,21 @@ +/* PR rtl-optimization/19296 */ +/* Origin: Falk Hueffner <falk@debian.org> */ + +/* { dg-do run } */ +/* { dg-options "-O" } */ +/* { dg-options "-O -mtune=i686" { target { i?86-*-* && ilp32 } } } */ +/* { dg-options "-O -mtune=i686" { target { x86_64-*-* && ilp32 } } } */ + +extern void abort(void); + +void f(unsigned short ad) +{ + if (ad >= 0x4000 && ad < 0xc000) + abort(); +} + +int main(void) +{ + f(0xff00); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/short-compare-2.c b/gcc/testsuite/gcc.dg/short-compare-2.c new file mode 100644 index 00000000000..1c2192e821a --- /dev/null +++ b/gcc/testsuite/gcc.dg/short-compare-2.c @@ -0,0 +1,22 @@ +/* PR rtl-optimization/19296 */ +/* Origin: Falk Hueffner <falk@debian.org> */ +/* Testcase by Andrew Pinski <pinskia@gcc.gnu.org> */ + +/* { dg-do run } */ +/* { dg-options "-O" } */ +/* { dg-options "-O -mtune=i686" { target { i?86-*-* && ilp32 } } } */ +/* { dg-options "-O -mtune=i686" { target { x86_64-*-* && ilp32 } } } */ + +extern void abort(); + +void f(unsigned short ad) +{ + if ((short) (ad - 0x4000) >= 0) + abort(); +} + +int main(void) +{ + f(0xc000); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr19683-1.c b/gcc/testsuite/gcc.dg/torture/pr19683-1.c new file mode 100644 index 00000000000..96674811f1e --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr19683-1.c @@ -0,0 +1,50 @@ +/* From PR rtl-optimization/19683. On little-endian MIPS targets, + reload would incorrectly inherit the high part of the multiplication + result. */ +/* { dg-do run { target mips*-*-* } } */ + +extern void abort (void); +extern void exit (int); + +#ifndef __mips16 +#define REPEAT10(X, Y) \ + X(Y##0); X(Y##1); X(Y##2); X(Y##3); X(Y##4); \ + X(Y##5); X(Y##6); X(Y##7); X(Y##8); X(Y##9) + +#define REPEAT30(X) REPEAT10 (X, 0); REPEAT10 (X, 1); REPEAT10 (X, 2) +#define IN(X) unsigned int x##X = ptr[0] +#define OUT(X) ptr[0] = x##X + +union u { unsigned long long ll; unsigned int i[2]; }; + +unsigned int +foo (volatile unsigned int *ptr) +{ + union u u; + int result; + + u.ll = (unsigned long long) ptr[0] * ptr[0]; + REPEAT30 (IN); + REPEAT30 (OUT); + asm ("#" : "=l" (result) : "l" (u.i[1])); + return result; +} + +int +main (void) +{ + unsigned int array[] = { 1000 * 1000 * 1000 }; + union u u; + + u.ll = (unsigned long long) array[0] * array[0]; + if (foo (array) != u.i[1]) + abort (); + exit (0); +} +#else +int +main (void) +{ + exit (0); +} +#endif diff --git a/gcc/testsuite/gcc.dg/transparent-union-3.c b/gcc/testsuite/gcc.dg/transparent-union-3.c new file mode 100644 index 00000000000..cebd5f85771 --- /dev/null +++ b/gcc/testsuite/gcc.dg/transparent-union-3.c @@ -0,0 +1,22 @@ +/* Test for ICEs on invalid transparent unions (empty or no named + members). Bug 21213. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +enum e { A }; + +union __attribute__((__transparent_union__)) ue1 { enum e; }; /* { dg-warning "warning: declaration does not declare anything" } */ +/* { dg-warning "warning: union cannot be made transparent" "" { target *-*-* } 9 } */ +union ue2 { enum e; } __attribute__((__transparent_union__)); /* { dg-warning "warning: declaration does not declare anything" } */ +/* { dg-warning "warning: union cannot be made transparent" "" { target *-*-* } 11 } */ + +union __attribute__((__transparent_union__)) ui1 { int; }; /* { dg-warning "warning: declaration does not declare anything" } */ +/* { dg-warning "warning: union cannot be made transparent" "" { target *-*-* } 14 } */ +union ui2 { int; } __attribute__((__transparent_union__)); /* { dg-warning "warning: declaration does not declare anything" } */ +/* { dg-warning "warning: union cannot be made transparent" "" { target *-*-* } 16 } */ + +union __attribute__((__transparent_union__)) u1 { }; +/* { dg-warning "warning: union cannot be made transparent" "" { target *-*-* } 19 } */ +union u2 { } __attribute__((__transparent_union__)); +/* { dg-warning "warning: union cannot be made transparent" "" { target *-*-* } 21 } */ diff --git a/gcc/testsuite/lib/target-libpath.exp b/gcc/testsuite/lib/target-libpath.exp new file mode 100644 index 00000000000..e8cf4630e16 --- /dev/null +++ b/gcc/testsuite/lib/target-libpath.exp @@ -0,0 +1,237 @@ +# Copyright (C) 2004 Free Software Foundation, Inc. + +# This program 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 of the License, or +# (at your option) any later version. +# +# This program 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 program; if not, write to the Free Software +# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This file was contributed by John David Anglin (dave.anglin@nrc-cnrc.gc.ca) + +set orig_environment_saved 0 +set orig_ld_library_path_saved 0 +set orig_ld_run_path_saved 0 +set orig_shlib_path_saved 0 +set orig_ld_libraryn32_path_saved 0 +set orig_ld_library64_path_saved 0 +set orig_ld_library_path_32_saved 0 +set orig_ld_library_path_64_saved 0 +set orig_dyld_library_path_saved 0 + + +####################################### +# proc set_ld_library_path_env_vars { } +####################################### + +proc set_ld_library_path_env_vars { } { + global ld_library_path + global orig_environment_saved + global orig_ld_library_path_saved + global orig_ld_run_path_saved + global orig_shlib_path_saved + global orig_ld_libraryn32_path_saved + global orig_ld_library64_path_saved + global orig_ld_library_path_32_saved + global orig_ld_library_path_64_saved + global orig_dyld_library_path_saved + global orig_ld_library_path + global orig_ld_run_path + global orig_shlib_path + global orig_ld_libraryn32_path + global orig_ld_library64_path + global orig_ld_library_path_32 + global orig_ld_library_path_64 + global orig_dyld_library_path + + # Setting the ld library path causes trouble when testing cross-compilers. + if { [is_remote target] } { + return + } + + if { $orig_environment_saved == 0 } { + global env + + set orig_environment_saved 1 + + # Save the original environment. + if [info exists env(LD_LIBRARY_PATH)] { + set orig_ld_library_path "$env(LD_LIBRARY_PATH)" + set orig_ld_library_path_saved 1 + } + if [info exists env(LD_RUN_PATH)] { + set orig_ld_run_path "$env(LD_RUN_PATH)" + set orig_ld_run_path_saved 1 + } + if [info exists env(SHLIB_PATH)] { + set orig_shlib_path "$env(SHLIB_PATH)" + set orig_shlib_path_saved 1 + } + if [info exists env(LD_LIBRARYN32_PATH)] { + set orig_ld_libraryn32_path "$env(LD_LIBRARYN32_PATH)" + set orig_ld_libraryn32_path_saved 1 + } + if [info exists env(LD_LIBRARY64_PATH)] { + set orig_ld_library64_path "$env(LD_LIBRARY64_PATH)" + set orig_ld_library64_path_saved 1 + } + if [info exists env(LD_LIBRARY_PATH_32)] { + set orig_ld_library_path_32 "$env(LD_LIBRARY_PATH_32)" + set orig_ld_library_path_32_saved 1 + } + if [info exists env(LD_LIBRARY_PATH_64)] { + set orig_ld_library_path_64 "$env(LD_LIBRARY_PATH_64)" + set orig_ld_library_path_64_saved 1 + } + if [info exists env(DYLD_LIBRARY_PATH)] { + set orig_dyld_library_path "$env(DYLD_LIBRARY_PATH)" + set orig_dyld_library_path_saved 1 + } + } + + # We need to set ld library path in the environment. Currently, + # unix.exp doesn't set the environment correctly for all systems. + # It only sets SHLIB_PATH and LD_LIBRARY_PATH when it executes a + # program. We also need the environment set for compilations, etc. + # + # On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but + # called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH + # (for the 64-bit ABI). The same applies to Darwin (DYLD_LIBRARY_PATH), + # Solaris 32 bit (LD_LIBRARY_PATH_32), Solaris 64 bit (LD_LIBRARY_PATH_64), + # and HP-UX (SHLIB_PATH). In some cases, the variables are independent + # of LD_LIBRARY_PATH, and in other cases LD_LIBRARY_PATH is used if the + # variable is not defined. + # + # Doing this is somewhat of a hack as ld_library_path gets repeated in + # SHLIB_PATH and LD_LIBRARY_PATH when unix_load sets these variables. + if { $orig_ld_library_path_saved } { + setenv LD_LIBRARY_PATH "$ld_library_path:$orig_ld_library_path" + } else { + setenv LD_LIBRARY_PATH "$ld_library_path" + } + if { $orig_ld_run_path_saved } { + setenv LD_RUN_PATH "$ld_library_path:$orig_ld_run_path" + } else { + setenv LD_RUN_PATH "$ld_library_path" + } + # The default shared library dynamic path search for 64-bit + # HP-UX executables searches LD_LIBRARY_PATH before SHLIB_PATH. + # LD_LIBRARY_PATH isn't used for 32-bit executables. Thus, we + # set LD_LIBRARY_PATH and SHLIB_PATH as if they were independent. + if { $orig_shlib_path_saved } { + setenv SHLIB_PATH "$ld_library_path:$orig_shlib_path" + } else { + setenv SHLIB_PATH "$ld_library_path" + } + if { $orig_ld_libraryn32_path_saved } { + setenv LD_LIBRARYN32_PATH "$ld_library_path:$orig_ld_libraryn32_path" + } elseif { $orig_ld_library_path_saved } { + setenv LD_LIBRARYN32_PATH "$ld_library_path:$orig_ld_library_path" + } else { + setenv LD_LIBRARYN32_PATH "$ld_library_path" + } + if { $orig_ld_library64_path_saved } { + setenv LD_LIBRARY64_PATH "$ld_library_path:$orig_ld_library64_path" + } elseif { $orig_ld_library_path_saved } { + setenv LD_LIBRARY64_PATH "$ld_library_path:$orig_ld_library_path" + } else { + setenv LD_LIBRARY64_PATH "$ld_library_path" + } + if { $orig_ld_library_path_32_saved } { + setenv LD_LIBRARY_PATH_32 "$ld_library_path:$orig_ld_library_path_32" + } elseif { $orig_ld_library_path_saved } { + setenv LD_LIBRARY_PATH_32 "$ld_library_path:$orig_ld_library_path" + } else { + setenv LD_LIBRARY_PATH_32 "$ld_library_path" + } + if { $orig_ld_library_path_64_saved } { + setenv LD_LIBRARY_PATH_64 "$ld_library_path:$orig_ld_library_path_64" + } elseif { $orig_ld_library_path_saved } { + setenv LD_LIBRARY_PATH_64 "$ld_library_path:$orig_ld_library_path" + } else { + setenv LD_LIBRARY_PATH_64 "$ld_library_path" + } + if { $orig_dyld_library_path_saved } { + setenv DYLD_LIBRARY_PATH "$ld_library_path:$orig_dyld_library_path" + } else { + setenv DYLD_LIBRARY_PATH "$ld_library_path" + } + + verbose -log "set_ld_library_path_env_vars: ld_library_path=$ld_library_path" +} + +####################################### +# proc restore_ld_library_path_env_vars { } +####################################### + +proc restore_ld_library_path_env_vars { } { + global orig_environment_saved + global orig_ld_library_path_saved + global orig_ld_run_path_saved + global orig_shlib_path_saved + global orig_ld_libraryn32_path_saved + global orig_ld_library64_path_saved + global orig_ld_library_path_32_saved + global orig_ld_library_path_64_saved + global orig_dyld_library_path_saved + global orig_ld_library_path + global orig_ld_run_path + global orig_shlib_path + global orig_ld_libraryn32_path + global orig_ld_library64_path + global orig_ld_library_path_32 + global orig_ld_library_path_64 + global orig_dyld_library_path + + if { $orig_environment_saved == 0 } { + return + } + + if { $orig_ld_library_path_saved } { + setenv LD_LIBRARY_PATH "$orig_ld_library_path" + } elseif [info exists env(LD_LIBRARY_PATH)] { + unsetenv LD_LIBRARY_PATH + } + if { $orig_ld_run_path_saved } { + setenv LD_RUN_PATH "$orig_ld_run_path" + } elseif [info exists env(LD_RUN_PATH)] { + unsetenv LD_RUN_PATH + } + if { $orig_shlib_path_saved } { + setenv SHLIB_PATH "$orig_shlib_path" + } elseif [info exists env(SHLIB_PATH)] { + unsetenv SHLIB_PATH + } + if { $orig_ld_libraryn32_path_saved } { + setenv LD_LIBRARYN32_PATH "$orig_ld_libraryn32_path" + } elseif [info exists env(LD_LIBRARYN32_PATH)] { + unsetenv LD_LIBRARYN32_PATH + } + if { $orig_ld_library64_path_saved } { + setenv LD_LIBRARY64_PATH "$orig_ld_library64_path" + } elseif [info exists env(LD_LIBRARY64_PATH)] { + unsetenv LD_LIBRARY64_PATH + } + if { $orig_ld_library_path_32_saved } { + setenv LD_LIBRARY_PATH_32 "$orig_ld_library_path_32" + } elseif [info exists env(LD_LIBRARY_PATH_32)] { + unsetenv LD_LIBRARY_PATH_32 + } + if { $orig_ld_library_path_64_saved } { + setenv LD_LIBRARY_PATH_64 "$orig_ld_library_path_64" + } elseif [info exists env(LD_LIBRARY_PATH_64)] { + unsetenv LD_LIBRARY_PATH_64 + } + if { $orig_dyld_library_path_saved } { + setenv DYLD_LIBRARY_PATH "$orig_dyld_library_path" + } elseif [info exists env(DYLD_LIBRARY_PATH)] { + unsetenv DYLD_LIBRARY_PATH + } +} diff --git a/libstdc++-v3/testsuite/22_locale/ctype/narrow/char/19955.cc b/libstdc++-v3/testsuite/22_locale/ctype/narrow/char/19955.cc new file mode 100644 index 00000000000..4ce1da33f01 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/ctype/narrow/char/19955.cc @@ -0,0 +1,105 @@ +// Copyright (C) 2005 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. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 22.2.1.3.2 ctype<char> members + +#include <locale> +#include <testsuite_hooks.h> + +class Ctype1 +: public std::ctype<char> +{ +protected: + const char* + do_narrow(const char* lo, const char* hi, + char dflt, char* to) const + { + for (int i = 0; lo != hi; ++lo, ++to, ++i) + *to = *lo + i; + return hi; + } +}; + +class Ctype2 +: public std::ctype<char> +{ +protected: + const char* + do_narrow(const char* lo, const char* hi, + char dflt, char* to) const + { + for (int i = 0; lo != hi; ++lo, ++to, ++i) + if (*lo == '\000') + *to = dflt; + else + *to = *lo; + return hi; + } +}; + +// libstdc++/19955 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + const char src[] = "abcd"; + + locale mylocale1(locale::classic(), new Ctype1); + const ctype<char>& mc1 = use_facet<ctype<char> >(mylocale1); + + char dst1[sizeof(src)]; + memset(dst1, 0, sizeof(src)); + char dst2[sizeof(src)]; + memset(dst2, 0, sizeof(src)); + + mc1.narrow(src, src + sizeof(src), '*', dst1); + mc1.narrow(src, src + sizeof(src), '*', dst2); + + VERIFY( !memcmp(dst1, "aceg\004", 5) ); + VERIFY( !memcmp(dst1, dst2, 5) ); + + locale mylocale2(locale::classic(), new Ctype2); + const ctype<char>& mc2 = use_facet<ctype<char> >(mylocale2); + + char dst3[sizeof(src)]; + memset(dst3, 0, sizeof(src)); + char dst4[sizeof(src)]; + memset(dst4, 0, sizeof(src)); + + mc2.narrow(src, src + sizeof(src), '*', dst3); + mc2.narrow(src, src + sizeof(src), '*', dst4); + + VERIFY( !memcmp(dst3, "abcd*", 5) ); + VERIFY( !memcmp(dst3, dst4, 5) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/libstdc++-abi/abi.exp b/libstdc++-v3/testsuite/libstdc++-abi/abi.exp new file mode 100644 index 00000000000..f226e0aaf77 --- /dev/null +++ b/libstdc++-v3/testsuite/libstdc++-abi/abi.exp @@ -0,0 +1,43 @@ +# Copyright (C) 2005 Free Software Foundation, Inc. +# +# This program 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 of the License, or +# (at your option) any later version. +# +# This program 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 program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# If there is no baseline file, or we can't find the library, skip +# this test. +if { ![info exists baseline_file] \ + || ![file exists $baseline_file] \ + || ![file exists "../src/.libs/libstdc++.so"] } { + return +} + +# Figure out what symbols are defined by the active build of the library. +remote_exec "build" "$srcdir/../scripts/extract_symvers" \ + [list "../src/.libs/libstdc++.so" "current_symbols.txt"] + +# Build the support objects. +v3-build_support + +# Build the abi_check program. +if { [v3_target_compile "$srcdir/testsuite_abi_check.cc" "abi_check" \ + "executable" [list "additional_flags=-w"]] != "" } { + error "could not compile testsuite_abi_check.cc" +} + +remote_download "target" $baseline_file "baseline_symbols.txt" +remote_download "target" "current_symbols.txt" "current_symbols.txt" +set result [${tool}_load "./abi_check" \ + [list "--check-verbose" "current_symbols.txt" \ + "baseline_symbols.txt"]] +[lindex $result 0] "abi_check" |