diff options
author | no-author <no-author@gcc.gnu.org> | 2004-09-19 18:50:44 +0000 |
---|---|---|
committer | no-author <no-author@gcc.gnu.org> | 2004-09-19 18:50:44 +0000 |
commit | 5538fca01a6968cf0a3d02f547b7b1b1624e9e04 (patch) | |
tree | 71608e297e6e86d54791703e472b9e7185d7336a | |
parent | fd0578ea3f445baecdc856e974be088d8a98e01d (diff) |
This commit was manufactured by cvs2svn to create branch
'structure-aliasing-branch'.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/structure-aliasing-branch@87732 138bc75d-0d04-0410-961f-82ee72b054a4
55 files changed, 1340 insertions, 0 deletions
diff --git a/fixincludes/tests/base/sys/ucontext.h b/fixincludes/tests/base/sys/ucontext.h new file mode 100644 index 00000000000..6a873672d6c --- /dev/null +++ b/fixincludes/tests/base/sys/ucontext.h @@ -0,0 +1,16 @@ +/* DO NOT EDIT THIS FILE. + + It has been auto-edited by fixincludes from: + + "fixinc/tests/inc/sys/ucontext.h" + + This had to be done to correct non-standard usages in the + original, manufacturer supplied header file. */ + + + +#if defined( LINUX_IA64_UCONTEXT_CHECK ) +# define _SC_GR0_OFFSET \ + __builtin_offsetof (struct sigcontext, sc_gr[0]) + +#endif /* LINUX_IA64_UCONTEXT_CHECK */ diff --git a/gcc/ada/prj-attr-pm.adb b/gcc/ada/prj-attr-pm.adb new file mode 100644 index 00000000000..13ec76fbba8 --- /dev/null +++ b/gcc/ada/prj-attr-pm.adb @@ -0,0 +1,68 @@ +------------------------------------------------------------------------------ +-- -- +-- GNAT COMPILER COMPONENTS -- +-- -- +-- P R J . A T T R . P M -- +-- -- +-- B o d y -- +-- -- +-- Copyright (C) 2004 Free Software Foundation, Inc. -- +-- -- +-- GNAT is free software; you can redistribute it and/or modify it under -- +-- terms of the GNU General Public License as published by the Free Soft- -- +-- ware Foundation; either version 2, or (at your option) any later ver- -- +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- +-- OUT 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 distributed with GNAT; see file COPYING. If not, write -- +-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- +-- MA 02111-1307, USA. -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +package body Prj.Attr.PM is + + ------------------- + -- Add_Attribute -- + ------------------- + + procedure Add_Attribute + (To_Package : Package_Node_Id; + Attribute_Name : Name_Id; + Attribute_Node : out Attribute_Node_Id) + is + begin + -- Only add the attribute if the package is already defined + + if To_Package /= Empty_Package then + Attrs.Increment_Last; + Attrs.Table (Attrs.Last) := + (Name => Attribute_Name, + Var_Kind => Undefined, + Optional_Index => False, + Attr_Kind => Unknown, + Next => + Package_Attributes.Table (To_Package.Value).First_Attribute); + Package_Attributes.Table (To_Package.Value).First_Attribute := + Attrs.Last; + Attribute_Node := (Value => Attrs.Last); + end if; + end Add_Attribute; + + ------------------------- + -- Add_Unknown_Package -- + ------------------------- + + procedure Add_Unknown_Package (Name : Name_Id; Id : out Package_Node_Id) is + begin + Package_Attributes.Increment_Last; + Id := (Value => Package_Attributes.Last); + Package_Attributes.Table (Id.Value) := + (Name => Name, Known => False, First_Attribute => Empty_Attr); + end Add_Unknown_Package; + +end Prj.Attr.PM; diff --git a/gcc/ada/prj-attr-pm.ads b/gcc/ada/prj-attr-pm.ads new file mode 100644 index 00000000000..423b60fc759 --- /dev/null +++ b/gcc/ada/prj-attr-pm.ads @@ -0,0 +1,45 @@ +------------------------------------------------------------------------------ +-- -- +-- GNAT COMPILER COMPONENTS -- +-- -- +-- P R J . A T T R . P M -- +-- -- +-- S p e c -- +-- -- +-- Copyright (C) 2004 Free Software Foundation, Inc. -- +-- -- +-- GNAT is free software; you can redistribute it and/or modify it under -- +-- terms of the GNU General Public License as published by the Free Soft- -- +-- ware Foundation; either version 2, or (at your option) any later ver- -- +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- +-- OUT 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 distributed with GNAT; see file COPYING. If not, write -- +-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- +-- MA 02111-1307, USA. -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +with Types; use Types; + +package Prj.Attr.PM is + -- The following procedures are not secure and should only be used by the + -- Project Manager, that is the packages of the Prj or MLib hierarchies. + + procedure Add_Unknown_Package (Name : Name_Id; Id : out Package_Node_Id); + -- Add a new unknown package. The Name cannot be the name of a predefined + -- or already registered package, but this is not checked. + + procedure Add_Attribute + (To_Package : Package_Node_Id; + Attribute_Name : Name_Id; + Attribute_Node : out Attribute_Node_Id); + -- Add an attribute to the list for package To_Package. Attribute_Name + -- cannot be the name of an existing attribute of the package, but this is + -- not checked. Does nothing if To_Package is Empty_Package. + +end Prj.Attr.PM; diff --git a/gcc/testsuite/g++.dg/eh/cleanup4.C b/gcc/testsuite/g++.dg/eh/cleanup4.C new file mode 100644 index 00000000000..ba2d891c949 --- /dev/null +++ b/gcc/testsuite/g++.dg/eh/cleanup4.C @@ -0,0 +1,17 @@ +// PR 16254 +// { dg-do compile } +// We lost a CLEANUP_POINT_EXPR, leading to a crash destroying temp of A. + +struct A +{ + ~A (); + A (int); +}; + +int bar (const A &); + +void +foo (int i) +{ + int format[1] = { bar (A (i)) }; +} diff --git a/gcc/testsuite/g++.dg/opt/switch1.C b/gcc/testsuite/g++.dg/opt/switch1.C new file mode 100644 index 00000000000..c21630d752b --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/switch1.C @@ -0,0 +1,23 @@ +// { dg-options "-O1" } + +template <typename T> +int f(T t) { + switch (t) { + case 1: + return 5; + case 2: + return 6; + case 3: + return -4; + case 4: + return 8; + case 5: + return 12; + case 6: + return 13; + default: + return -27; + } +} + +template int f(int); diff --git a/gcc/testsuite/g++.dg/parse/crash17.C b/gcc/testsuite/g++.dg/parse/crash17.C new file mode 100644 index 00000000000..bdc66399f27 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/crash17.C @@ -0,0 +1,9 @@ +// PR c++/16716 + +template <typename> class allocator; + +template<typename T> class vector { + // With the dg-error on the next line, we are really just trying to + // check that the message is not an ICE message. + typedef typename allocator<T> allocator_type; // { dg-error "expected|forbids" } +}; diff --git a/gcc/testsuite/g++.dg/parse/error18.C b/gcc/testsuite/g++.dg/parse/error18.C new file mode 100644 index 00000000000..363aae99879 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/error18.C @@ -0,0 +1,7 @@ +// PR c++/16002 + +void f() +{ + double Q *= 5.0; // { dg-error "initializer" } +} + diff --git a/gcc/testsuite/g++.dg/pch/wchar-1.C b/gcc/testsuite/g++.dg/pch/wchar-1.C new file mode 100644 index 00000000000..6cb5fe15e4c --- /dev/null +++ b/gcc/testsuite/g++.dg/pch/wchar-1.C @@ -0,0 +1 @@ +#include "wchar-1.H" diff --git a/gcc/testsuite/g++.dg/pch/wchar-1.Hs b/gcc/testsuite/g++.dg/pch/wchar-1.Hs new file mode 100644 index 00000000000..431908b88b1 --- /dev/null +++ b/gcc/testsuite/g++.dg/pch/wchar-1.Hs @@ -0,0 +1,2 @@ +#include <stddef.h> +const wchar_t test_var[] = L"wide string"; diff --git a/gcc/testsuite/g++.dg/template/decl2.C b/gcc/testsuite/g++.dg/template/decl2.C new file mode 100644 index 00000000000..3a77777bd0a --- /dev/null +++ b/gcc/testsuite/g++.dg/template/decl2.C @@ -0,0 +1,13 @@ +// PR c++/16162 + +template <int N> struct O { + struct I { + template <typename T> struct II { + void f(); + }; + }; +}; + +template <int N> +template <typename T> +void O<N>::I::II<T>::f () {} diff --git a/gcc/testsuite/g++.dg/template/enum3.C b/gcc/testsuite/g++.dg/template/enum3.C new file mode 100644 index 00000000000..b248d788c50 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/enum3.C @@ -0,0 +1,8 @@ +// PR c++/17327 + +enum E { E0, E1 }; +template <class T,class U> class A {}; +template <class T> void f(A<E,T>) {} +// We used to issue a "sorry" message. By using an explicit error +// message below, we make sure that we will not match "sorry". +template void f(A<int,E>); // { dg-error "template-id" } diff --git a/gcc/testsuite/g++.dg/template/mangle1.C b/gcc/testsuite/g++.dg/template/mangle1.C new file mode 100644 index 00000000000..96d06472341 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/mangle1.C @@ -0,0 +1,16 @@ +// PR c++/17324 +// { dg-do assemble } + +template<int, typename T> struct A +{ + template<int I> void foo(const A<I,T>&) {} +}; + +template<typename> struct B +{ + template<int J> void bar(const A<J,B>&); + void baz() { A<0,B>().foo(A<0,B>()); } +}; + +template struct B<void>; +template struct B<int>; diff --git a/gcc/testsuite/g++.dg/template/stmtexpr1.C b/gcc/testsuite/g++.dg/template/stmtexpr1.C new file mode 100644 index 00000000000..a470ca8f14f --- /dev/null +++ b/gcc/testsuite/g++.dg/template/stmtexpr1.C @@ -0,0 +1,10 @@ +// PR c++/17404 +// { dg-do compile } +// { dg-options "" } + +template <int> void foo () +{ + __builtin_expect (({0;}), 1); +} + +template void foo<1> (); diff --git a/gcc/testsuite/g++.dg/template/typename7.C b/gcc/testsuite/g++.dg/template/typename7.C new file mode 100644 index 00000000000..d9c8f2609aa --- /dev/null +++ b/gcc/testsuite/g++.dg/template/typename7.C @@ -0,0 +1,19 @@ +// PR c++/17501 + +template<int> struct A; + +template<> struct A<0> +{ + struct B + { + struct C + { + typedef int D; + }; + }; +}; + +template<int I> struct E +{ + typename A<I>::B::C::D i; +}; diff --git a/gcc/testsuite/g++.dg/tree-ssa/pointer-reference-alias.C b/gcc/testsuite/g++.dg/tree-ssa/pointer-reference-alias.C new file mode 100644 index 00000000000..028240b3908 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pointer-reference-alias.C @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-vars" } */ + +int f(int *a) +{ + int &b = *a; + b = 0; + return *a; +} + +/* There should be only one dereferencing of a. */ +/* { dg-final { scan-tree-dump-times "\\*a" 1 "vars"} } */ + diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr17153.C b/gcc/testsuite/g++.dg/tree-ssa/pr17153.C new file mode 100644 index 00000000000..91b4cfe1503 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr17153.C @@ -0,0 +1,17 @@ +/* The alias analyzer was marking RETVAL non-addressable, but RETVAL + is a special variable that's available across different functions. */ +void foo(const char*); + +struct A {}; + +struct B : A +{ + B(){} + B bar() + { + foo(__PRETTY_FUNCTION__); + return B(); + }; +}; + +B b=B().bar(); diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr17400.C b/gcc/testsuite/g++.dg/tree-ssa/pr17400.C new file mode 100644 index 00000000000..a6619a84fd3 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr17400.C @@ -0,0 +1,53 @@ +// Test PR 17400. Test case provided by Serge Belyshev. + +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + + +void inc (int &); +bool dec_test (int &); + +struct A +{ + int c; + + friend void AddRef (A * p) + { + inc (p->c); + } + + friend void Release (A * p) + { + if(dec_test (p->c)) + delete p; + } +}; + +struct B +{ + B (A *p) : obj(p) + { + AddRef (obj); + } + + ~B() + { + Release (obj); + } + + void swap (B &rhs) + { + A * tmp = obj; + obj = rhs.obj; + rhs.obj = tmp; + } + + A *obj; +}; + +void bar (A *p1, A* p2) +{ + B px (p1); + B px2 (p2); + px.swap (px2); +} diff --git a/gcc/testsuite/g++.dg/warn/Wunused-8.C b/gcc/testsuite/g++.dg/warn/Wunused-8.C new file mode 100644 index 00000000000..a1c8a1fb426 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wunused-8.C @@ -0,0 +1,9 @@ +// PR c++/16029 +// { dg-options "-Wunused" } + +int main () +{ + // We should not see an "unused" warning about "whatever" on the + // next line. + return whatever (); // { dg-error "declared" } +} diff --git a/gcc/testsuite/gcc.c-torture/compile/20040914-1.c b/gcc/testsuite/gcc.c-torture/compile/20040914-1.c new file mode 100644 index 00000000000..824664c889b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20040914-1.c @@ -0,0 +1,39 @@ +extern int clobber_k (int *); +extern int barrier (void); +int t, u; + +int +process_second_stream(void) +{ + int k; + int i = 0, j = 0, result; + + clobber_k (&k); + + while(t) + ; + + while(!j) + { + while(!j) + { + barrier (); + if (t == 0) + break; + else if(t == 1) + t = 2; + else + { + if(t < 0) + j=1; + if(u < 0) + k = i++; + } + } + + if(!j && u) + j=1; + } + + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr17273.c b/gcc/testsuite/gcc.c-torture/compile/pr17273.c new file mode 100644 index 00000000000..42d318ef69f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr17273.c @@ -0,0 +1,22 @@ +struct A { int i; }; +struct B { struct A a; }; + +void f(struct A*, struct A*); +#define bool _Bool + +void bar(bool b) +{ + struct B * D1601; + struct A D1576; + struct A * D1593; + struct B * D1592; + struct B D1575; + + D1575 = (struct B){}; + + if (b) D1592 = &D1575; else D1592 = &D1575; + + D1593 = &D1592->a; // <-- we are prograting &D1575 into here. + D1576 = (struct A){}; + f (D1593, &D1576); +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr17397.c b/gcc/testsuite/gcc.c-torture/compile/pr17397.c new file mode 100644 index 00000000000..b857472f65f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr17397.c @@ -0,0 +1,12 @@ +/* ICE due to invalid GIMPLE created during strlen simplification. */ + +extern unsigned long strlen (__const char *__s); +extern void bar (); +extern int cols; + +void foo (void) +{ + char s[cols + 2]; + if (strlen (s) > 0) + bar (); +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr17408.c b/gcc/testsuite/gcc.c-torture/compile/pr17408.c new file mode 100644 index 00000000000..4819673f284 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr17408.c @@ -0,0 +1,5 @@ +/* PRs 17408 and 17409, with different options. */ +extern int t; +extern int t = 0; +void f(){t =0;} +void g(){h(&t);} diff --git a/gcc/testsuite/gcc.c-torture/execute/20040917-1.c b/gcc/testsuite/gcc.c-torture/execute/20040917-1.c new file mode 100644 index 00000000000..73bc6c6479c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20040917-1.c @@ -0,0 +1,32 @@ +/* submitted by kenneth zadeck */ + +static int test_var; + +/* the idea here is that not only is inlinable, inlinable but since it + is static, the cgraph node will not be marked as output. The + current version of the code ignores these cgraph nodes. */ + +void not_inlinable() __attribute__((noinline)); + +static void +inlinable () +{ + test_var = -10; +} + +void +not_inlinable () +{ + inlinable(); +} + +main () +{ + test_var = 10; + /* Variable test_var should be considered call-clobbered by the call + to not_inlinable(). */ + not_inlinable (); + if (test_var == 10) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/memmove-2-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/memmove-2-lib.c new file mode 100644 index 00000000000..5be3df52fe5 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/memmove-2-lib.c @@ -0,0 +1 @@ +#include "lib/memmove.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/memmove-2.c b/gcc/testsuite/gcc.c-torture/execute/builtins/memmove-2.c new file mode 100644 index 00000000000..3afe3431338 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/memmove-2.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Check builtin memmove and bcopy optimization when length is 1. + + Written by Jakub Jelinek, 9/14/2004. */ + +extern void abort (void); +typedef __SIZE_TYPE__ size_t; +extern void *memmove (void *, const void *, size_t); +extern void bcopy (const void *, void *, size_t); +extern int memcmp (const void *, const void *, size_t); + +char p[32] = "abcdefg"; +char *q = p + 4; + +void +main_test (void) +{ + /* memmove with length 1 can be optimized into memcpy if it can be + expanded inline. */ + if (memmove (p + 2, p + 3, 1) != p + 2 || memcmp (p, "abddefg", 8)) + abort (); + if (memmove (p + 1, p + 1, 1) != p + 1 || memcmp (p, "abddefg", 8)) + abort (); + if (memmove (q, p + 4, 1) != p + 4 || memcmp (p, "abddefg", 8)) + abort (); + bcopy (p + 5, p + 6, 1); + if (memcmp (p, "abddeff", 8)) + abort (); + bcopy (p + 1, p + 1, 1); + if (memcmp (p, "abddeff", 8)) + abort (); + bcopy (q, p + 4, 1); + if (memcmp (p, "abddeff", 8)) + abort (); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strlen-3-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strlen-3-lib.c new file mode 100644 index 00000000000..9753c2498f1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strlen-3-lib.c @@ -0,0 +1 @@ +#include "lib/strlen.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strlen-3.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strlen-3.c new file mode 100644 index 00000000000..f912c0267db --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strlen-3.c @@ -0,0 +1,68 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Test strlen on const variables initialized to string literals. + + Written by Jakub Jelinek, 9/14/2004. */ + +extern void abort (void); +extern __SIZE_TYPE__ strlen (const char *); +extern char *strcpy (char *, const char *); +const char bar[] = "Hello, World!"; +const char baz[] = "hello, world?"; +const char larger[20] = "short string"; +extern volatile int inside_main; + +int l1 = 1; +int x = 6; + +void +main_test(void) +{ + const char *foo; + int i; + + if (strlen (bar) != 13) + abort (); + + if (strlen (bar + 3) != 10) + abort (); + + if (strlen (&bar[6]) != 7) + abort (); + + if (strlen (bar + (x++ & 7)) != 7) + abort (); + if (x != 7) + abort (); + +#ifdef __OPTIMIZE__ + foo = bar; + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + foo = "HELLO, WORLD!"; + else if (i == l1) + foo = bar; + else if (i == l1 + 1) + foo = "hello, world!"; + else + foo = baz; + } + if (strlen (foo) != 13) + abort (); +#endif + + if (strlen (larger) != 12) + abort (); + if (strlen (&larger[10]) != 2) + abort (); + + inside_main = 0; + /* This will result in strlen call, because larger + array is bigger than its initializer. */ + if (strlen (larger + (x++ & 7)) != 5) + abort (); + if (x != 8) + abort (); + inside_main = 1; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr15262-1.c b/gcc/testsuite/gcc.c-torture/execute/pr15262-1.c new file mode 100644 index 00000000000..f6a6fe40b73 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr15262-1.c @@ -0,0 +1,47 @@ +/* PR 15262. + The alias analyzer only considers relations between pointers and + symbols. If two pointers P and Q point to the same symbol S, then + their respective memory tags will either be the same or they will + have S in their alias set. + + However, if there are no common symbols between P and Q, TBAA will + currently miss their alias relationship altogether. */ +struct A +{ + int t; + int i; +}; + +int foo () { return 3; } + +main () +{ + struct A loc, *locp; + float f, g, *p; + int T355, *T356; + + /* Avoid the partial hack in TBAA that would consider memory tags if + the program had no addressable symbols. */ + f = 3; + g = 2; + p = foo () ? &g : &f; + if (*p > 0.0) + g = 1; + + /* Store into *locp and cache its current value. */ + locp = malloc (sizeof (*locp)); + locp->i = 10; + T355 = locp->i; + + /* Take the address of one of locp's fields and write to it. */ + T356 = &locp->i; + *T356 = 1; + + /* Read the recently stored value. If TBAA fails, this will appear + as a redundant load that will be replaced with '10'. */ + T355 = locp->i; + if (T355 != 1) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr15262-2.c b/gcc/testsuite/gcc.c-torture/execute/pr15262-2.c new file mode 100644 index 00000000000..82e8aabd1ab --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr15262-2.c @@ -0,0 +1,37 @@ +/* PR 15262. Similar to pr15262-1.c but with no obvious addresses + being taken in function foo(). Without IPA, by only looking inside + foo() we cannot tell for certain whether 'q' and 'b' alias each + other. */ +struct A +{ + int t; + int i; +}; + +struct B +{ + int *p; + float b; +}; + +float X; + +foo (struct B b, struct A *q, float *h) +{ + X += *h; + *(b.p) = 3; + q->t = 2; + return *(b.p); +} + +main() +{ + struct A a; + struct B b; + + b.p = &a.t; + if (foo (b, &a, &X) == 3) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr17252.c b/gcc/testsuite/gcc.c-torture/execute/pr17252.c new file mode 100644 index 00000000000..bd1b6b99e98 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr17252.c @@ -0,0 +1,21 @@ +/* PR 17252. When a char * pointer P takes its own address, storing + into *P changes P itself. */ + +char *a; + +main () +{ + /* Make 'a' point to itself. */ + a = (char *)&a; + + /* Change what 'a' is pointing to. */ + a[0]++; + + /* If a's memory tag does not contain 'a' in its alias set, we will + think that this predicate is superfluous and change it to + 'if (1)'. */ + if (a == (char *)&a) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/20040813-1.c b/gcc/testsuite/gcc.dg/20040813-1.c new file mode 100644 index 00000000000..c866d4cfeb0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20040813-1.c @@ -0,0 +1,14 @@ +/* Test lang in N_SO stab. */ +/* Contributed by Devang Patel <dpatel@apple.com> */ + +/* { dg-do compile } */ +/* { dg-options "-gstabs" } */ + +int +main () +{ + return 0; +} + +/* { dg-final { scan-assembler ".stabs*100,0,2" } } */ + diff --git a/gcc/testsuite/gcc.dg/20040916-1.c b/gcc/testsuite/gcc.dg/20040916-1.c new file mode 100644 index 00000000000..fbea9e385b7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20040916-1.c @@ -0,0 +1,45 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +/* PR17513 - we hit a bug where EDGE_EXECUTABLE was not cleared on + successors of the entry block. This lead to a flow verification + error much later in the compilation (after gcse). */ +typedef unsigned char uint8; +typedef unsigned int uint32; + +uint32 marker = 0; +uint8 *buff = 0; +uint32 bsize = 0; + +extern int foo (void); + +uint32 +bar (void) +{ + int len, d; + + for (;;) + { + if (foo () == 0) + return (0); + + switch (marker) + { + case 0xfe: + { + len |= (*buff++); + bsize -= 2; + + while (len > 0) + { + d = *buff++; + len--; + } + } + break; + default: + break; + } + } +} + diff --git a/gcc/testsuite/gcc.dg/declspec-12.c b/gcc/testsuite/gcc.dg/declspec-12.c new file mode 100644 index 00000000000..a1373efa3f1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/declspec-12.c @@ -0,0 +1,6 @@ +/* Test type qualifier in empty declaration: OK but useless. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +const struct foo; /* { dg-warning "warning: useless type qualifier in empty declaration" } */ diff --git a/gcc/testsuite/gcc.dg/declspec-13.c b/gcc/testsuite/gcc.dg/declspec-13.c new file mode 100644 index 00000000000..317252064e5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/declspec-13.c @@ -0,0 +1,86 @@ +/* Test declaration specifiers. Test messages for bad type + specifiers. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -pedantic" } */ + +/* typeof should act much like typedef, so the following are + invalid. */ +typeof(double) long x0; /* { dg-error "error: two or more data types in declaration specifiers" } */ +typeof(double) _Complex x1; /* { dg-error "error: two or more data types in declaration specifiers" } */ + +/* The following is erroneous, and used to get a bogus message about + complex integer types. */ +typedef double D; +D _Complex x2; /* { dg-error "error: two or more data types in declaration specifiers" } */ + +/* The following empty declarations should have problems in their type + specifiers diagnosed, not just the general problem that they are + empty declarations. */ +long short; /* { dg-error "error: both 'long' and 'short' in declaration specifiers" } */ +/* { dg-warning "warning: useless type name in empty declaration" "empty" { target *-*-* } 20 } */ +_Complex double; /* { dg-warning "warning: ISO C90 does not support complex types" } */ +/* { dg-warning "warning: useless type name in empty declaration" "empty" { target *-*-* } 22 } */ +_Complex; /* { dg-warning "warning: ISO C90 does not support complex types" } */ +/* { dg-warning "warning: ISO C does not support plain 'complex' meaning 'double complex'" "ISO C" { target *-*-* } 24 } */ +/* { dg-warning "warning: useless type name in empty declaration" "empty" { target *-*-* } 24 } */ +_Complex int; /* { dg-warning "warning: ISO C90 does not support complex types" } */ +/* { dg-warning "warning: ISO C does not support complex integer types" "ISO C" { target *-*-* } 27 } */ +/* { dg-warning "warning: useless type name in empty declaration" "empty" { target *-*-* } 27 } */ + +/* Specific messages for each invalid combination. (That some message + is given when appropriate for a larger collection of combinations + of type specifiers is tested in *typespec*.c.) */ + +long double long x3; /* { dg-error "both 'long long' and 'double' in declaration specifiers" } */ +short long x4; /* { dg-error "both 'long' and 'short' in declaration specifiers" } */ +void long x5; /* { dg-error "both 'long' and 'void' in declaration specifiers" } */ +_Bool long x6; /* { dg-error "both 'long' and '_Bool' in declaration specifiers" } */ +char long x7; /* { dg-error "both 'long' and 'char' in declaration specifiers" } */ +float long x8; /* { dg-error "both 'long' and 'float' in declaration specifiers" } */ +long short x9; /* { dg-error "both 'long' and 'short' in declaration specifiers" } */ +void short x10; /* { dg-error "both 'short' and 'void' in declaration specifiers" } */ +_Bool short x11; /* { dg-error "both 'short' and '_Bool' in declaration specifiers" } */ +char short x12; /* { dg-error "both 'short' and 'char' in declaration specifiers" } */ +float short x13; /* { dg-error "both 'short' and 'float' in declaration specifiers" } */ +double short x14; /* { dg-error "both 'short' and 'double' in declaration specifiers" } */ +unsigned signed x15; /* { dg-error "both 'signed' and 'unsigned' in declaration specifiers" } */ +void signed x16; /* { dg-error "both 'signed' and 'void' in declaration specifiers" } */ +_Bool signed x17; /* { dg-error "both 'signed' and '_Bool' in declaration specifiers" } */ +float signed x18; /* { dg-error "both 'signed' and 'float' in declaration specifiers" } */ +double signed x19; /* { dg-error "both 'signed' and 'double' in declaration specifiers" } */ +signed unsigned x20; /* { dg-error "both 'signed' and 'unsigned' in declaration specifiers" } */ +void unsigned x21; /* { dg-error "both 'unsigned' and 'void' in declaration specifiers" } */ +_Bool unsigned x22; /* { dg-error "both 'unsigned' and '_Bool' in declaration specifiers" } */ +float unsigned x23; /* { dg-error "both 'unsigned' and 'float' in declaration specifiers" } */ +double unsigned x24; /* { dg-error "both 'unsigned' and 'double' in declaration specifiers" } */ +void _Complex x25; /* { dg-error "both 'complex' and 'void' in declaration specifiers" } */ +/* { dg-warning "warning: ISO C90 does not support complex types" "C90" { target *-*-* } 57 } */ +_Bool _Complex x26; /* { dg-error "both 'complex' and '_Bool' in declaration specifiers" } */ +/* { dg-warning "warning: ISO C90 does not support complex types" "C90" { target *-*-* } 59 } */ + +long void x27; /* { dg-error "both 'long' and 'void' in declaration specifiers" } */ +short void x28; /* { dg-error "both 'short' and 'void' in declaration specifiers" } */ +signed void x29; /* { dg-error "both 'signed' and 'void' in declaration specifiers" } */ +unsigned void x30; /* { dg-error "both 'unsigned' and 'void' in declaration specifiers" } */ +_Complex void x31; /* { dg-error "both 'complex' and 'void' in declaration specifiers" } */ +/* { dg-warning "warning: ISO C90 does not support complex types" "C90" { target *-*-* } 66 } */ +/* { dg-warning "warning: ISO C does not support plain 'complex' meaning 'double complex'" "complex" { target *-*-* } 66 } */ +long _Bool x32; /* { dg-error "both 'long' and '_Bool' in declaration specifiers" } */ +short _Bool x33; /* { dg-error "both 'short' and '_Bool' in declaration specifiers" } */ +signed _Bool x34; /* { dg-error "both 'signed' and '_Bool' in declaration specifiers" } */ +unsigned _Bool x35; /* { dg-error "both 'unsigned' and '_Bool' in declaration specifiers" } */ +_Complex _Bool x36; /* { dg-error "both 'complex' and '_Bool' in declaration specifiers" } */ +/* { dg-warning "warning: ISO C90 does not support complex types" "C90" { target *-*-* } 73 } */ +/* { dg-warning "warning: ISO C does not support plain 'complex' meaning 'double complex'" "complex" { target *-*-* } 73 } */ +long char x37; /* { dg-error "both 'long' and 'char' in declaration specifiers" } */ +short char x38; /* { dg-error "both 'short' and 'char' in declaration specifiers" } */ +long float x39; /* { dg-error "both 'long' and 'float' in declaration specifiers" } */ +short float x40; /* { dg-error "both 'short' and 'float' in declaration specifiers" } */ +signed float x41; /* { dg-error "both 'signed' and 'float' in declaration specifiers" } */ +unsigned float x42; /* { dg-error "both 'unsigned' and 'float' in declaration specifiers" } */ +long long double x43; /* { dg-error "both 'long long' and 'double' in declaration specifiers" } */ +/* { dg-warning "warning: ISO C90 does not support 'long long'" "C90" { target *-*-* } 82 } */ +short double x44; /* { dg-error "both 'short' and 'double' in declaration specifiers" } */ +signed double x45; /* { dg-error "both 'signed' and 'double' in declaration specifiers" } */ +unsigned double x46; /* { dg-error "both 'unsigned' and 'double' in declaration specifiers" } */ diff --git a/gcc/testsuite/gcc.dg/i386-asm-3.c b/gcc/testsuite/gcc.dg/i386-asm-3.c new file mode 100644 index 00000000000..f60f7d6378a --- /dev/null +++ b/gcc/testsuite/gcc.dg/i386-asm-3.c @@ -0,0 +1,34 @@ +/* PR inline-asm/6806 */ +/* { dg-do run { target i?86-*-* } } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +volatile int out = 1; +volatile int a = 2; +volatile int b = 4; +volatile int c = 8; +volatile int d = 16; +volatile int e = 32; +volatile int f = 64; + +int +main () +{ + asm volatile ("xorl %%eax, %%eax \n\t" + "xorl %%esi, %%esi \n\t" + "addl %1, %0 \n\t" + "addl %2, %0 \n\t" + "addl %3, %0 \n\t" + "addl %4, %0 \n\t" + "addl %5, %0 \n\t" + "addl %6, %0" + : "+r" (out) + : "r" (a), "r" (b), "r" (c), "g" (d), "g" (e), "g" (f) + : "%eax", "%esi"); + + if (out != 127) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/inline-10.c b/gcc/testsuite/gcc.dg/inline-10.c new file mode 100644 index 00000000000..ed6851a615b --- /dev/null +++ b/gcc/testsuite/gcc.dg/inline-10.c @@ -0,0 +1,6 @@ +/* Test inline main, gnu99 mode, freestanding, -pedantic-errors. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -ffreestanding -pedantic-errors" } */ + +inline int main (void); diff --git a/gcc/testsuite/gcc.dg/inline-11.c b/gcc/testsuite/gcc.dg/inline-11.c new file mode 100644 index 00000000000..6d0f41d969c --- /dev/null +++ b/gcc/testsuite/gcc.dg/inline-11.c @@ -0,0 +1,14 @@ +/* Test misuses of inline. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +/* These should perhaps be hard errors, but are pedwarns at + present. */ + +inline int a; /* { dg-warning "warning: variable 'a' declared 'inline'" } */ +inline int (*b)(void); /* { dg-warning "warning: variable 'b' declared 'inline'" } */ +typedef inline void c(void); /* { dg-warning "warning: typedef 'c' declared 'inline'" } */ +typedef inline int d; /* { dg-warning "warning: typedef 'd' declared 'inline'" } */ +void e(inline int f(void)); /* { dg-warning "warning: parameter 'f' declared 'inline'" } */ +void g(inline int(void)); /* { dg-warning "warning: parameter '\\({anonymous}\\)' declared 'inline'" } */ diff --git a/gcc/testsuite/gcc.dg/inline-12.c b/gcc/testsuite/gcc.dg/inline-12.c new file mode 100644 index 00000000000..c793196fe72 --- /dev/null +++ b/gcc/testsuite/gcc.dg/inline-12.c @@ -0,0 +1,14 @@ +/* Test misuses of inline. -pedantic-errors test. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic-errors" } */ + +/* These should perhaps be hard errors, but are pedwarns at + present. */ + +inline int a; /* { dg-error "error: variable 'a' declared 'inline'" } */ +inline int (*b)(void); /* { dg-error "error: variable 'b' declared 'inline'" } */ +typedef inline void c(void); /* { dg-error "error: typedef 'c' declared 'inline'" } */ +typedef inline int d; /* { dg-error "error: typedef 'd' declared 'inline'" } */ +void e(inline int f(void)); /* { dg-error "error: parameter 'f' declared 'inline'" } */ +void g(inline int(void)); /* { dg-error "error: parameter '\\({anonymous}\\)' declared 'inline'" } */ diff --git a/gcc/testsuite/gcc.dg/inline-6.c b/gcc/testsuite/gcc.dg/inline-6.c new file mode 100644 index 00000000000..81d6dc22082 --- /dev/null +++ b/gcc/testsuite/gcc.dg/inline-6.c @@ -0,0 +1,6 @@ +/* Test duplicate inline, gnu89 mode. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ + +inline inline void f (void) {} diff --git a/gcc/testsuite/gcc.dg/inline-7.c b/gcc/testsuite/gcc.dg/inline-7.c new file mode 100644 index 00000000000..b239a20461c --- /dev/null +++ b/gcc/testsuite/gcc.dg/inline-7.c @@ -0,0 +1,6 @@ +/* Test duplicate inline, gnu99 mode. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +inline inline void f (void) {} diff --git a/gcc/testsuite/gcc.dg/inline-8.c b/gcc/testsuite/gcc.dg/inline-8.c new file mode 100644 index 00000000000..80d9fff5440 --- /dev/null +++ b/gcc/testsuite/gcc.dg/inline-8.c @@ -0,0 +1,6 @@ +/* Test inline main, gnu99 mode, hosted. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -fhosted" } */ + +inline int main (void); /* { dg-warning "warning: cannot inline function 'main'" } */ diff --git a/gcc/testsuite/gcc.dg/inline-9.c b/gcc/testsuite/gcc.dg/inline-9.c new file mode 100644 index 00000000000..0f22b0805a3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/inline-9.c @@ -0,0 +1,6 @@ +/* Test inline main, gnu99 mode, hosted, -pedantic-errors. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -fhosted -pedantic-errors" } */ + +inline int main (void); /* { dg-error "error: cannot inline function 'main'" } */ diff --git a/gcc/testsuite/gcc.dg/pr17319.c b/gcc/testsuite/gcc.dg/pr17319.c new file mode 100644 index 00000000000..5d39e4c5707 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr17319.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-dce" } */ + +typedef unsigned long long HARD_REG_ELT_TYPE; +typedef HARD_REG_ELT_TYPE HARD_REG_SET[2]; +static HARD_REG_SET newpat_used_regs; +int try_combine (void) +{ + HARD_REG_ELT_TYPE *scan_tp_ = newpat_used_regs; + scan_tp_[0] = 0; + scan_tp_[1] = 0; +} diff --git a/gcc/testsuite/gcc.dg/pr17424-1.c b/gcc/testsuite/gcc.dg/pr17424-1.c new file mode 100644 index 00000000000..893b4af13d2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr17424-1.c @@ -0,0 +1,5 @@ +/* Test for bug 17424: ICE for sizeof an undeclared variable. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +;int foezis = sizeof tni; /* { dg-error "'tni' undeclared" } */ diff --git a/gcc/testsuite/gcc.dg/pr9771-1.c b/gcc/testsuite/gcc.dg/pr9771-1.c new file mode 100644 index 00000000000..1e3bc036aee --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr9771-1.c @@ -0,0 +1,43 @@ +/* PR rtl-optimization/9771 */ +/* { dg-do run { target i?86-*-* } } */ +/* { dg-options "-O2 -fomit-frame-pointer -ffixed-ebp" } */ + +extern void abort(void); +extern void exit(int); + +register long *B asm ("ebp"); + +long x = 10; +long y = 20; + +void bar(void) +{ + B = &y; +} + +void foo() +{ + long *adr = B; + long save = *adr; + + *adr = 123; + + bar(); + + *adr = save; +} + +int main() +{ + B = &x; + + foo(); + + if (x != 10 || y != 20) + abort(); + + /* We can't return, as our caller may assume %ebp is preserved! */ + /* We could save/restore it (like foo), but its easier to exit. */ + exit(0); +} + diff --git a/gcc/testsuite/gcc.dg/vect/vect-73.c b/gcc/testsuite/gcc.dg/vect/vect-73.c new file mode 100644 index 00000000000..4df315d1f0d --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-73.c @@ -0,0 +1,42 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* x86_64-*-* } } */ + +#include <stdarg.h> +#include "tree-vect.h" + +#define N 16 + +int ic[N*2]; + +#define ia (ic+N) + +int main1 () +{ + int i, j; + int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + + for (i = 0; i < N; i++) + { + ia[i] = ib[i]; + } + + /* check results: */ + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i]) + abort(); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/gcc/testsuite/gcc.target/mips/sb1-1.c b/gcc/testsuite/gcc.target/mips/sb1-1.c new file mode 100644 index 00000000000..b6d671b7756 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/sb1-1.c @@ -0,0 +1,29 @@ +/* Test SB-1 v2sf extensions. */ +/* { dg-do compile { target mipsisa64*-*-* } } */ +/* { dg-options "-march=sb1 -O2 -mpaired-single -mhard-float -mfp64 -ffast-math" } */ +/* { dg-final { scan-assembler "div.ps" } } */ +/* { dg-final { scan-assembler "recip.ps" } } */ +/* { dg-final { scan-assembler "sqrt.ps" } } */ +/* { dg-final { scan-assembler "rsqrt.ps" } } */ + +typedef float v2sf __attribute__ ((vector_size (8))); + +v2sf divide (v2sf a, v2sf b) +{ + return a / b; +} + +v2sf recip (v2sf a) +{ + return ((v2sf) {1.0, 1.0}) / a; +} + +v2sf squareroot (v2sf a) +{ + return __builtin_mips_sqrt_ps (a); +} + +v2sf rsqrt (v2sf a) +{ + return ((v2sf) {1.0, 1.0}) / __builtin_mips_sqrt_ps (a); +} diff --git a/gcc/testsuite/gfortran.dg/der_array_io_1.f90 b/gcc/testsuite/gfortran.dg/der_array_io_1.f90 new file mode 100644 index 00000000000..5bfd0c64547 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/der_array_io_1.f90 @@ -0,0 +1,24 @@ +! Test IO of arrays of integers in derived types +! { dg-do run } +program main + + character* 10000 :: buf1, buf2 + type xyz + integer :: x, y(3), z + end type xyz + + type (xyz) :: foo(4) + + do i=1,ubound(foo,1) + foo(i)%x = 100*i + do j=1,3 + foo(i)%y(j) = 100*i + 10*j + enddo + foo(i)%z = 100*i+40 + enddo + + print (buf1, '(20i4)'), foo + print (buf2, '(20i4)'), (foo(i)%x, (foo(i)%y(j), j=1,3), foo(i)%z, i=1,4) + + if (buf1.ne.buf2) call abort +end program main diff --git a/gcc/testsuite/gfortran.dg/der_array_io_2.f90 b/gcc/testsuite/gfortran.dg/der_array_io_2.f90 new file mode 100644 index 00000000000..5d4a7ce01e3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/der_array_io_2.f90 @@ -0,0 +1,29 @@ +! Test IO of arrays in derived type arrays +! { dg-do run } +program main + + character *1000 buf1, buf2 + + type :: foo_type + integer x(3) + integer y(4) + integer z(5) + character*11 a(3) + end type foo_type + + type (foo_type) :: foo(2) + + foo(1)%x = 3 + foo(1)%y = 4 + foo(1)%z = 5 + foo(1)%a = "hello world" + + foo(2)%x = 30 + foo(2)%y = 40 + foo(2)%z = 50 + foo(2)%a = "HELLO WORLD" + + print (buf1,*), foo + print (buf2,*), ((foo(i)%x(j),j=1,3), (foo(i)%y(j),j=1,4), (foo(i)%z(j),j=1,5), (foo(i)%a(j),j=1,3), i=1,2) + if (buf1.ne.buf2) call abort +end program main diff --git a/gcc/testsuite/gfortran.dg/der_array_io_3.f90 b/gcc/testsuite/gfortran.dg/der_array_io_3.f90 new file mode 100644 index 00000000000..7898a1e8c5c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/der_array_io_3.f90 @@ -0,0 +1,13 @@ +! Test IO of character arrays in derived types. +! { dg-do run } +program main + character*1000 buf1, buf2 + type :: foo_type + character(12), dimension(13) :: name = "hello world " + end type foo_type + type (foo_type) :: foo +! foo = foo_type("hello world ") + print (buf1,*), foo + print (buf2,*), (foo%name(i), i=1,13) + if (buf1.ne.buf2) call abort +end program main diff --git a/gcc/testsuite/gfortran.dg/pr17090.f90 b/gcc/testsuite/gfortran.dg/pr17090.f90 new file mode 100644 index 00000000000..6a685c2eddd --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr17090.f90 @@ -0,0 +1,22 @@ +! { dg-do run } +! pr 17090 Runtime I/O error +! bdavis9659@comcast.net +! 9/12/2004 +! list directed read with spaces between the last data item and the +! eoln cause missed data items. +! this is a libgfortran test case + implicit none + integer i,sum + real a(14) + data sum / 0 / + open(unit=9,status='SCRATCH') + write(9,*)1.0,2.0,3.0,4.0,' ' + write(9,*)5.0,6.0,7.0,8.0,' ' + write(9,*)9.0,10.0,11.0,12.0,13.0,14.0,' ' + rewind(9) + read(9,*)a + do i = 1,14 + sum = sum + a(i) + end do + if (sum.ne.105) call abort + end diff --git a/gcc/testsuite/gfortran.dg/same_name_1.f90 b/gcc/testsuite/gfortran.dg/same_name_1.f90 new file mode 100644 index 00000000000..cbeb875e36b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/same_name_1.f90 @@ -0,0 +1,13 @@ +! { dg-do assemble } +module n +private u +contains + subroutine u + end subroutine u +end module n +module m + private :: u +contains + subroutine u + end subroutine u +end module m diff --git a/gcc/testsuite/lib/wrapper.exp b/gcc/testsuite/lib/wrapper.exp new file mode 100644 index 00000000000..6dd990ce8fc --- /dev/null +++ b/gcc/testsuite/lib/wrapper.exp @@ -0,0 +1,42 @@ +# 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, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This file contains GCC-specifics for status wrappers for test programs. + +# ${tool}_maybe_build_wrapper -- Build wrapper object if the target needs it. + +proc ${tool}_maybe_build_wrapper { filename } { + global gluefile wrap_flags + + if { [target_info needs_status_wrapper] != "" \ + && [target_info needs_status_wrapper] != "0" \ + && ![info exists gluefile] } { + set saved_wrap_compile_flags [target_info wrap_compile_flags] + # The wrapper code may contain code that gcc objects on. This + # became true for dejagnu-1.4.4. The set of warnings and code + # that gcc objects on may change, so just make sure -w is always + # passed to turn off all warnings. + set_currtarget_info wrap_compile_flags "$saved_wrap_compile_flags -w" + set result [build_wrapper $filename]; + set_currtarget_info wrap_compile_flags "$saved_wrap_compile_flags" + if { $result != "" } { + set gluefile [lindex $result 0]; + set wrap_flags [lindex $result 1]; + } else { + unset gluefile + } + } +} diff --git a/libgfortran/intrinsics/getcwd.c b/libgfortran/intrinsics/getcwd.c new file mode 100644 index 00000000000..86afa6ca5c4 --- /dev/null +++ b/libgfortran/intrinsics/getcwd.c @@ -0,0 +1,71 @@ +/* Implementation of the GETCWD intrinsic. + Copyright (C) 2004 Free Software Foundation, Inc. + Contributed by Steven G. Kargl <kargls@comcast.net>. + +This file is part of the GNU Fortran 95 runtime library (libgfortran). + +Libgfortran is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +Libgfortran 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 Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with libgfor; see the file COPYING.LIB. If not, +write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "config.h" +#include "libgfortran.h" + +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif + +#include <errno.h> + +void +prefix(getcwd_i4_sub) (char * cwd, GFC_INTEGER_4 * status, + gfc_charlen_type cwd_len) +{ + char str[cwd_len + 1], *s; + GFC_INTEGER_4 stat; + + memset(cwd, ' ', (size_t) cwd_len); + + if (!getcwd (str, (size_t) cwd_len + 1)) + stat = errno; + else + { + stat = 0; + memcpy (cwd, str, strlen (str)); + } + if (status != NULL) + *status = stat; +} + +void +prefix(getcwd_i8_sub) (char * cwd, GFC_INTEGER_8 * status, + gfc_charlen_type cwd_len) +{ + GFC_INTEGER_4 status4; + + prefix (getcwd_i4_sub) (cwd, &status4, cwd_len); + if (status) + *status = status4; +} + +GFC_INTEGER_4 +prefix(getcwd) (char * cwd, gfc_charlen_type cwd_len) +{ + GFC_INTEGER_4 status; + prefix(getcwd_i4_sub) (cwd, &status, cwd_len); + return status; +} diff --git a/libstdc++-v3/testsuite/performance/27_io/filebuf_sgetn_unbuf.cc b/libstdc++-v3/testsuite/performance/27_io/filebuf_sgetn_unbuf.cc new file mode 100644 index 00000000000..5741ab308bb --- /dev/null +++ b/libstdc++-v3/testsuite/performance/27_io/filebuf_sgetn_unbuf.cc @@ -0,0 +1,85 @@ +// Copyright (C) 2004 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. + +#include <cstdio> +#include <fstream> +#include <testsuite_performance.h> + +// libstdc++/11722 +int main() +{ + using namespace std; + using namespace __gnu_test; + + time_counter time; + resource_counter resource; + + const int iterations = 500000; + const int chunksize = 100; + + char* chunk = new char[chunksize]; + const char* name = "/usr/share/dict/linux.words"; + + // C + FILE* file = fopen(name, "r"); + setvbuf(file, 0, _IONBF, 0); + start_counters(time, resource); + for (int i = 0; i < iterations; ++i) + if (fread(chunk, 1, chunksize, file) < chunksize) + fseek(file, 0, SEEK_SET); + stop_counters(time, resource); + fclose(file); + report_performance(__FILE__, "C", time, resource); + clear_counters(time, resource); + + // C unlocked + file = fopen(name, "r"); + setvbuf(file, 0, _IONBF, 0); + start_counters(time, resource); + for (int i = 0; i < iterations; ++i) + if (fread_unlocked(chunk, 1, chunksize, file) < chunksize) + fseek(file, 0, SEEK_SET); + stop_counters(time, resource); + fclose(file); + report_performance(__FILE__, "C unlocked", time, resource); + clear_counters(time, resource); + + // C++ + filebuf buf; + buf.pubsetbuf(0, 0); + buf.open(name, ios_base::in); + start_counters(time, resource); + for (int i = 0; i < iterations; ++i) + if (buf.sgetn(chunk, chunksize) < chunksize) + buf.pubseekoff(0, ios::beg); + stop_counters(time, resource); + report_performance(__FILE__, "C++", time, resource); + + delete [] chunk; + + return 0; +} |