diff options
author | Andrew Macleod <amacleod@redhat.com> | 2016-05-10 03:30:56 +0000 |
---|---|---|
committer | Andrew Macleod <amacleod@redhat.com> | 2016-05-10 03:30:56 +0000 |
commit | 357ceb7fe26970b6c6e12f0bb2ceecab6c6a2454 (patch) | |
tree | 48eb1f57289f4e995f069f38213ad5c8a16f0347 /gcc/testsuite | |
parent | 5ed230ef2005822d6402118e58a311db2a9cb0c7 (diff) | |
parent | 8a50780e586342528692744150d08651fb07fb43 (diff) |
update to 2016-05-09ttype-2016-05-03
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/ttype-2016-05-03@236057 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite')
62 files changed, 2309 insertions, 12 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3ff4ea4d8f8..29a9709e6ca 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,183 @@ +2016-05-09 Uros Bizjak <ubizjak@gmail.com> + + * gcc.target/i386/fabsneg-1.c New test. + +2016-05-09 Alan Modra <amodra@gmail.com> + + PR testsuite/70826 + * gcc.target/powerpc/savres.c: Compile with -fno-rename-registers. + +2016-05-09 Richard Biener <rguenther@suse.de> + + PR tree-optimization/70985 + * gcc.dg/torture/pr70985.c: New testcase. + +2016-05-09 Bin Cheng <bin.cheng@arm.com> + + * gcc.dg/tree-ssa/ifc-9.c: New test. + * gcc.dg/tree-ssa/ifc-10.c: New test. + * gcc.dg/tree-ssa/ifc-11.c: New test. + * gcc.dg/tree-ssa/ifc-12.c: New test. + * gcc.dg/vect/pr61194.c: Remove XFAIL. + * gcc.dg/vect/vect-23.c: Remove XFAIL. + * gcc.dg/vect/vect-mask-store-move-1.c: Revise test check. + +2016-05-09 Richard Biener <rguenther@suse.de> + + PR fortran/70937 + * gfortran.dg/pr70937.f90: New testcase. + +2016-05-08 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> + + * gcc.dg/ipa/pure-const-3.c: Scan local-pure-const1 dump. + +2016-05-07 Fritz Reese <fritzoreese@gmail.com> + + PR fortran/56226 + * gfortran.dg/dec_structure_1.f90: New testcase. + * gfortran.dg/dec_structure_2.f90: Ditto. + * gfortran.dg/dec_structure_3.f90: Ditto. + * gfortran.dg/dec_structure_4.f90: Ditto. + * gfortran.dg/dec_structure_5.f90: Ditto. + * gfortran.dg/dec_structure_6.f90: Ditto. + * gfortran.dg/dec_structure_7.f90: Ditto. + * gfortran.dg/dec_structure_8.f90: Ditto. + * gfortran.dg/dec_structure_9.f90: Ditto. + * gfortran.dg/dec_structure_10.f90: Ditto. + * gfortran.dg/dec_structure_11.f90: Ditto. + * gfortran.dg/dec_union_1.f90: Ditto. + * gfortran.dg/dec_union_2.f90: Ditto. + * gfortran.dg/dec_union_3.f90: Ditto. + * gfortran.dg/dec_union_4.f90: Ditto. + * gfortran.dg/dec_union_5.f90: Ditto. + * gfortran.dg/dec_union_6.f90: Ditto. + * gfortran.dg/dec_union_7.f90: Ditto. + +2016-05-07 Tom de Vries <tom@codesourcery.com> + + PR tree-optimization/70956 + * gcc.dg/graphite/pr70956.c: New test. + +2016-05-06 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/70941 + * gcc.dg/torture/pr70941.c (abort): Remove prototype. + (a, b, c, d): Change type from char to signed char. + (main): Compare against (signed char) -1634678893 instead of + hardcoded -109. Use __builtin_abort instead of abort. + + * gcc.target/i386/avx512bw-vpsraw-3.c: New test. + * gcc.target/i386/avx512vl-vpsrad-3.c: New test. + + * gcc.target/i386/avx512bw-vpmaddwd-3.c: New test. + +2016-05-06 Yuri Rumyantsev <ysrumyan@gmail.com> + + PR debug/70935 + * gcc.dg/torture/pr70935.c: New test. + +2016-05-06 Oleg Endo <olegendo@gcc.gnu.org> + + PR target/58219 + * gcc.target/sh/pr58219.c: New tests. + +2016-05-06 Richard Biener <rguenther@suse.de> + + PR tree-optimization/70960 + * gfortran.fortran-torture/compile/pr70960.f90: New testcase. + +2016-05-06 Oleg Endo <olegendo@gcc.gnu.org> + + PR target/52933 + * gcc.target/sh/pr52933-1.c (test_31, test_32, test_33, test_34, + test_35, test_36, test_37, test_38, test_39, test_40): New sub-tests. + Adjust expected instruction counts. + * gcc.target/sh/pr52933-2.c: Adjust expected instruction counts. + +2016-05-06 Marek Polacek <polacek@redhat.com> + + PR sanitizer/70875 + * gcc.dg/ubsan/bounds-3.c: New test. + +2016-05-06 Oleg Endo <olegendo@gcc.gnu.org> + + PR target/54089 + * gcc.target/sh/pr54089-1.c (test_24): Add new sub-test. + +2016-05-06 Richard Biener <rguenther@suse.de> + + PR middle-end/70931 + * gfortran.dg/pr70931.f90: New testcase. + +2016-05-06 Richard Biener <rguenther@suse.de> + + PR middle-end/70941 + * gcc.dg/torture/pr70941.c: New testcase. + +2016-05-05 Bin Cheng <bin.cheng@arm.com> + + PR tree-optimization/57206 + * gcc.dg/vect/pr57206.c: New test. + +2016-05-05 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> + + * gcc.dg/ipa/inline-8.c (isnanf): Declare. + +2016-05-05 Jakub Jelinek <jakub@redhat.com> + + * gcc.target/i386/avx512f-vfmadd-1.c: New test. + + * c-c++-common/Wdangling-else-4.c: New test. + +2016-05-04 Jakub Jelinek <jakub@redhat.com> + + PR c++/70906 + PR c++/70933 + * g++.dg/opt/pr70906.C: New test. + * g++.dg/opt/pr70933.C: New test. + + * gcc.target/i386/avx512vl-vmovq-1.c: New test. + +2016-05-04 Jan Hubicka <hubicka@ucw.cz> + + * gcc.dg/ipa/pure-const-3.c: New testcase. + +2016-05-04 Marek Polacek <polacek@redhat.com> + + * c-c++-common/Wdangling-else-1.c: New test. + * c-c++-common/Wdangling-else-2.c: New test. + * c-c++-common/Wdangling-else-3.c: New test. + +2016-05-04 Kwok Cheung Yeung <kcy@codesourcery.com> + + * gcc.target/mips/mips16-attributes.c: Skip if -mmicromips + flag is present. + +2016-05-04 Marek Polacek <polacek@redhat.com> + + PR c/48778 + * gcc.dg/Waddress-2.c: New test. + +2016-05-04 Alan Modra <amodra@gmail.com> + + * gcc.target/powerpc/pr70866.c: New. + +2016-05-03 Martin Sebor <msebor@redhat.com> + + PR c++/66561 + * c-c++-common/builtin_location.c: New test. + * g++.dg/cpp1y/builtin_location.C: New test. + +2016-05-03 Marek Polacek <polacek@redhat.com> + + PR c/70859 + * gcc.dg/pr70859.c: New test. + * gcc.dg/pr70859-2.c: New test. + +2016-05-03 Pierre-Marie de Rodat <derodat@adacore.com> + + * gnat.dg/debug5.adb: New testcase. + 2016-05-03 Dominik Vogt <vogt@linux.vnet.ibm.com> * gcc.target/s390/md/rXsbg_mode_sXl.c: New test. diff --git a/gcc/testsuite/c-c++-common/Wdangling-else-1.c b/gcc/testsuite/c-c++-common/Wdangling-else-1.c new file mode 100644 index 00000000000..28a5a8f53fb --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wdangling-else-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-Wdangling-else" } */ + +void bar (int); +void +foo (int a, int b) +{ + if (a) /* { dg-warning "suggest explicit braces to avoid ambiguous" } */ + if (b) + bar (1); + else + bar (2); +} diff --git a/gcc/testsuite/c-c++-common/Wdangling-else-2.c b/gcc/testsuite/c-c++-common/Wdangling-else-2.c new file mode 100644 index 00000000000..87ea1ab5687 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wdangling-else-2.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-Wparentheses" } */ + +void bar (int); +void +foo (int a, int b) +{ + if (a) /* { dg-warning "suggest explicit braces to avoid ambiguous" } */ + if (b) + bar (1); + else + bar (2); +} diff --git a/gcc/testsuite/c-c++-common/Wdangling-else-3.c b/gcc/testsuite/c-c++-common/Wdangling-else-3.c new file mode 100644 index 00000000000..0dae0d54ec8 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wdangling-else-3.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-Wparentheses -Wno-dangling-else" } */ + +void bar (int); +void +foo (int a, int b) +{ + if (a) /* { dg-bogus "suggest explicit braces to avoid ambiguous" } */ + if (b) + bar (1); + else + bar (2); +} diff --git a/gcc/testsuite/c-c++-common/Wdangling-else-4.c b/gcc/testsuite/c-c++-common/Wdangling-else-4.c new file mode 100644 index 00000000000..12cc1405a40 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wdangling-else-4.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-Wdangling-else" } */ + +void bar (int); + +void +foo (int a, int b, int c) +{ + if (a) /* { dg-warning "suggest explicit braces to avoid ambiguous .else." } */ + switch (b) + case 0: + if (c) + bar (1); + else + bar (2); +} + +void +baz (int a, int b, int c) +{ + if (a) + switch (b) + { + case 0: + if (c) + bar (1); + } + else + bar (2); +} + diff --git a/gcc/testsuite/c-c++-common/builtin_location.c b/gcc/testsuite/c-c++-common/builtin_location.c new file mode 100644 index 00000000000..f3bcd17d84d --- /dev/null +++ b/gcc/testsuite/c-c++-common/builtin_location.c @@ -0,0 +1,57 @@ +/* PR c++/66561 - __builtin_LINE at al. should yield constant expressions */ +/* { dg-do compile } */ + +#if __cplusplus >= 201103L +# define Assert(expr) static_assert ((expr), #expr) +#elif __STDC_VERSION__ >= 201112L +# define Assert(expr) _Static_assert ((expr), #expr) +#else +# define CONCAT(a, b) a ## b +# define CAT(a, b) CONCAT (a, b) +# define Assert(expr) typedef int CAT (Assert_, __LINE__) [1 - 2 * !(expr)] +#endif + +/* Verify (in C) that __builtin_FILE() yields an address constant. + This test is ineffective in C++ where initializers of global + objects need not be constant expressions. */ +const char* const file = __builtin_FILE (); + +/* Verify (in C) that __builtin_FUNCTION() yields an address constant. */ +const char* const function = __builtin_FUNCTION (); + +/* Also verify that __builtin_constant_p() returns true for both. */ +Assert (__builtin_constant_p (__builtin_FILE ())); +Assert (__builtin_constant_p (__builtin_FUNCTION ())); + +/* Verify (in both C and C++ 11 and later) that both __builtin_FILE () + and __builtin_FUNCTION() yield an address constant by making use + of a GCC extension that allows operands of arithmetic constant + expressions to be address constants. (Subtracting two literals + from one another is undefined in both C and C++ and should be + diagnosed. See c/70772.) */ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Waddress" + +enum E0 { + e0 = __FILE__ - __FILE__, + e1 = __builtin_FILE () - __builtin_FILE (), + +#if !__cplusplus || __cplusplus >= 201103L + /* Skip this test in C++ 98 where GCC rejects __FUNCTION__ in constant + expressions. */ + e2 = __FUNCTION__ - __FUNCTION__, + e3 = __builtin_FUNCTION () - __builtin_FUNCTION () + +#endif +}; + +#pragma GCC diagnostic pop + +/* Verify that __builtin_LINE () yields an integer constant expression. */ +#line 13 +int a [__builtin_LINE ()][__builtin_LINE ()]; +enum F { f0 = __builtin_LINE () }; +struct S { unsigned bitfield: __builtin_LINE (); } s; + +Assert (__builtin_constant_p (__builtin_LINE ())); diff --git a/gcc/testsuite/g++.dg/cpp1y/builtin_location.C b/gcc/testsuite/g++.dg/cpp1y/builtin_location.C new file mode 100644 index 00000000000..b3b9b435b2c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/builtin_location.C @@ -0,0 +1,175 @@ +// PR c++/66561 - __builtin_LINE at al. should yield constant expressions +// { dg-do compile { target c++11 } } +#define A(expr) static_assert ((expr), #expr) + +#define FILE_1 "file_name.suffix" +#define FILE_2 "some_other_file_name.suffix" + +#line 1 FILE_1 +constexpr const char* +file1 () +{ +#if __cplusplus >= 201402L + // Do extra checking in C++ 14 and later. + constexpr const char *f1 = __FILE__; + constexpr const char *f2 = __builtin_FILE (); + A (0 == __builtin_strcmp (f1, f2)); + return f1; +#else + // In C++ 11, a constexpr function body must consist of a single + // return statement and no declaratations. + return __builtin_FILE (); +#endif +} + +#line 1 FILE_2 +constexpr const char* +file2 () +{ +#if __cplusplus >= 201402L + constexpr const char *f1 = __FILE__; + constexpr const char *f2 = __builtin_FILE (); + A (0 == __builtin_strcmp (f1, f2)); + return f1; +#else + return __builtin_FILE (); +#endif +} + +#line 1 "bogus file name" +constexpr const char* +this_file (const char *fname = __builtin_FILE ()) +{ + return fname; +} + +constexpr const char* +function () +{ +#if __cplusplus >= 201402L + constexpr const char *f1 = __FUNCTION__; + constexpr const char *f2 = __builtin_FUNCTION (); + A (0 == __builtin_strcmp (f1, f2)); + return f1; +#else + return __builtin_FUNCTION (); +#endif +} + +constexpr const char* +this_function (const char *func = __builtin_FUNCTION ()) +{ + return func; +} + +constexpr int +line () +{ +#if __cplusplus >= 201402L +#line 123 + constexpr int n1 = __LINE__; + constexpr int n2 = __builtin_LINE (); + A (123 == n1); + A (n1 + 1 == n2); + return n2; +#else +#line 123 + // Newline. + return __builtin_LINE (); +#endif +} + +constexpr int +this_line (int line = __builtin_LINE ()) +{ + return line; +} + + +// Exercise __builtin_FILE(). +#line 1 "foobar" +constexpr const char* f1 = file1 (); +A (0 == __builtin_strcmp (f1, FILE_1)); + +#line 2 "foobar" +constexpr const char* f2 = file2 (); +A (0 == __builtin_strcmp (f2, FILE_2)); + +#define FILE_3 "this_file_name_right_here.this_suffix" +#line 1 FILE_3 +constexpr const char* f3 = this_file (); +A (0 == __builtin_strcmp (f3, FILE_3)); + +#define FILE_4 "next_file_name.another_suffix" +#line 1 "foobar" +constexpr const char* f4 = this_file + ( +#line 1 FILE_4 + ) +#line 1 "foobar" + ; +A (0 == __builtin_strcmp (f4, FILE_4)); + + +// Exercise __builtin_FUNCTION(). + +// Verify that __builtin_FUNCTION() returns the name of the function +// in which it is called. +constexpr const char* fun1 = function (); +A (0 == __builtin_strcmp (fun1, "function")); + +// Verify that __builtin_FUNCTION() returns the empty string when +// it's invoked to set the default argument value in a function +// called at file scope. +constexpr const char* fun2 = this_function (); +A (0 == __builtin_strcmp (fun2, "")); + +constexpr const char* +named_function () +{ + return this_function (); +} + +constexpr const char* fun3 = named_function (); +A (0 == __builtin_strcmp (fun3, "named_function")); + + +// Exercise __builtin_LINE(). +// Verify the line numbe returned by the built-in. +#line 4 +constexpr int n1 = __builtin_LINE (); +A (n1 == 4); + +// Verify the line number obtained by a constexpr function. +#line 5 +constexpr int n2 = line (); +A (n2 == 124); + +// Verify the line number determined by the default argument. +#line 6 +constexpr int n3 = this_line (); +A (n3 == 6); + +// Verify that the line number accounts for each of the calls. +#line 7 +constexpr int n4 = this_line () + this_line (); +A (n4 == 14); + +// Verify that the line number accounts for each of the calls when +// split over multiple lines. +#line 1 +constexpr int n5 = this_line () +#line 8 + + this_line (); +A (n5 == 9); + +// Verify that the line number corresponds to the closing parenthesis +// of the function call. +#line 1 +constexpr int n6 = this_line + ( +#line 99 + ) +#line 1 + ; +A (n6 == 99); diff --git a/gcc/testsuite/g++.dg/opt/pr70906.C b/gcc/testsuite/g++.dg/opt/pr70906.C new file mode 100644 index 00000000000..19c91cd6aec --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr70906.C @@ -0,0 +1,69 @@ +// PR c++/70906 +// { dg-do compile { target c++11 } } +// { dg-options "-Wall" } + +template <typename> struct B; +template <typename U> struct F { typedef U *t; }; +template <class> struct D {}; +template <class VP> struct L { + typedef VP np; + typedef typename F<D<VP>>::t cnp; +}; +struct P { typedef L<void *> nt; }; +template <class N> struct I { typedef typename N::template A<int> t; }; +template <class O1> struct Q { typedef typename I<O1>::t t; }; +template <class T, class Hook, Hook T::*> struct G; +template <typename P, typename M, M P::*PM> +struct mh { + template <class> struct A { typedef G<P, M, PM> pvt; }; +}; +template <typename T> struct B<T *> { static T pt(T); }; +struct R : public D<void *> { typedef P ht; }; +class lmh : public R {}; +template <class T, class Hook, Hook T::*P> struct G { + typedef Hook Ht; + typedef typename Ht::ht::nt nt; + typedef T vt; + typedef typename nt::np np; + typedef typename nt::cnp cnp; + static np tnp(T &); + static cnp tnp(const T &p1) { + B<cnp>::pt(static_cast<const Ht &>(p1.*P)); + return cnp (); + } +}; +template <class T, class S> struct K { + template <S> struct J; + template <class U> static int foo(J<U::tnp> *, int); + static const int c = sizeof(foo<T>(0, 0)); +}; +template <class V> struct W1 { + typedef typename V::vt vt; + static const bool value = K<V, typename V::np (*)(vt &)>::c == K<V, typename V::cnp (*)(const vt &)>::c; +}; +template <class V> struct O { + static const bool svt = W1<V>::value; +}; +template <bool> struct M {}; +template <class V> class C { + static const bool svt = O<V>::svt; + M<svt> m; +}; +template <class V> struct H { + C<V> bar(); +}; +template <class O1> struct ml { + typedef typename Q<O1>::t po; + typedef H<typename po::pvt> t; +}; +template <class O1> class list : public ml<O1>::t {}; +struct N { + struct IV { lmh hk; }; + typedef list<mh<IV, lmh, &IV::hk>> ISL; + friend void fn1(int &, N const &); +}; +void fn1(int &, N const &) { + N::ISL xl; + for (xl.bar();;) + ; +} diff --git a/gcc/testsuite/g++.dg/opt/pr70933.C b/gcc/testsuite/g++.dg/opt/pr70933.C new file mode 100644 index 00000000000..f664d45777c --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr70933.C @@ -0,0 +1,29 @@ +// PR c++/70933 +// { dg-do compile } +// { dg-options "-Wsequence-point" } + +struct A +{ + A (const char *); +}; + +template <class T> +struct B +{ + typedef T U; + U &baz (const A &); +}; + +template <class T> +void +bar () +{ + B<T> b; + T &p = b.baz ("p1") = T(4); +} + +void +foo () +{ + bar<unsigned> (); +} diff --git a/gcc/testsuite/gcc.dg/Waddress-2.c b/gcc/testsuite/gcc.dg/Waddress-2.c new file mode 100644 index 00000000000..4d927f67694 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Waddress-2.c @@ -0,0 +1,24 @@ +/* PR c/48778 */ +/* { dg-do compile } */ +/* { dg-options "-Waddress" } */ + +#define NULL ((void *) 0) + +#define M1(b) ((b) != NULL ? 0 : (b)) +#define M2(b) ((b) == NULL ? 0 : (b)) +#define M3(b) (NULL != (b) ? 0 : (b)) +#define M4(b) (NULL == (b) ? 0 : (b)) + +int +func (int b) +{ + if (M1 (&b) > 0) + return 1; + if (M2 (&b) > 0) + return 2; + if (M3 (&b) > 0) + return 3; + if (M4 (&b) > 0) + return 4; + return 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr70956.c b/gcc/testsuite/gcc.dg/graphite/pr70956.c new file mode 100644 index 00000000000..31fc25f4638 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr70956.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fgraphite-identity" } */ + +#include "../tree-ssa/vrp66.c" diff --git a/gcc/testsuite/gcc.dg/ipa/inline-8.c b/gcc/testsuite/gcc.dg/ipa/inline-8.c index 962906443c9..df4a64deff9 100644 --- a/gcc/testsuite/gcc.dg/ipa/inline-8.c +++ b/gcc/testsuite/gcc.dg/ipa/inline-8.c @@ -5,6 +5,7 @@ /* { dg-options "-O2" } */ /* { dg-add-options c99_runtime } */ #include <math.h> +extern int isnanf (float); /* Can't be inlined because isnanf will be optimized out. */ int cmp (float a) diff --git a/gcc/testsuite/gcc.dg/ipa/pure-const-3.c b/gcc/testsuite/gcc.dg/ipa/pure-const-3.c new file mode 100644 index 00000000000..e3d27c10f33 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pure-const-3.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-require-alias "" } */ +/* { dg-options "-O2 -fdump-tree-local-pure-const1" } */ + +__attribute__ ((weak)) +__attribute__ ((noinline)) +int a(int v) +{ + return v; +} +__attribute__ ((noinline)) +static int b(int v) __attribute__ ((alias("a"))); +int +main() +{ + int c = a(1)==a(1); + int d = b(1)==b(1); + if (__builtin_constant_p (c)) + __builtin_abort (); + if (!__builtin_constant_p (d)) + __builtin_abort (); + return 0; +} +/* { dg-final { scan-tree-dump "found to be const" "local-pure-const1"} } */ diff --git a/gcc/testsuite/gcc.dg/pr70859-2.c b/gcc/testsuite/gcc.dg/pr70859-2.c new file mode 100644 index 00000000000..4817852a955 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr70859-2.c @@ -0,0 +1,18 @@ +/* PR c/70859 */ +/* { dg-do compile } */ + +#include <stdint.h> +#define MAX __SIZE_MAX__ +#define MAX2 SIZE_MAX +#define FIVE 5 + +static void *p; + +void +fn0 (int n) +{ + p = __builtin_alloca_with_align (n, SIZE_MAX); /* { dg-error "39:must be a constant integer" } */ + p = __builtin_alloca_with_align (n, MAX); /* { dg-error "39:must be a constant integer" } */ + p = __builtin_alloca_with_align (n, MAX2); /* { dg-error "39:must be a constant integer" } */ + p = __builtin_alloca_with_align (n, FIVE); /* { dg-error "39:must be a constant integer" } */ +} diff --git a/gcc/testsuite/gcc.dg/pr70859.c b/gcc/testsuite/gcc.dg/pr70859.c new file mode 100644 index 00000000000..0a3c8437c66 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr70859.c @@ -0,0 +1,69 @@ +/* PR c/70859 */ +/* { dg-do compile } */ + +static void *p; +static double *d; +static int r; +__extension__ static _Bool b; + +void +fn0 (int n) +{ + p = __builtin_alloca_with_align (n, 6); /* { dg-error "39:must be a constant integer" } */ + + r += __builtin_isfinite (0); /* { dg-error "28:non-floating-point argument in call" } */ + r += __builtin_isinf (0); /* { dg-error "25:non-floating-point argument in call" } */ + r += __builtin_isinf_sign (0); /* { dg-error "30:non-floating-point argument in call" } */ + r += __builtin_isnan (0); /* { dg-error "25:non-floating-point argument in call" } */ + r += __builtin_isnormal (0); /* { dg-error "28:non-floating-point argument in call" } */ + r += __builtin_signbit (0); /* { dg-error "27:non-floating-point argument in call" } */ + + r += __builtin_isgreater (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */ + r += __builtin_isgreaterequal (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */ + r += __builtin_isless (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */ + r += __builtin_islessequal (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */ + r += __builtin_islessgreater (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */ + r += __builtin_isunordered (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */ + + r += __builtin_fpclassify (1, 2, n, 4, 5, n); /* { dg-error "36:non-const integer argument 3 in call" } */ + r += __builtin_fpclassify (1, 2, 3, 4, 5, 6); /* { dg-error "45:non-floating-point argument in call" } */ + + d = __builtin_assume_aligned (p, n, p); /* { dg-error "39:non-integer argument 3 in call" } */ + + b = __builtin_add_overflow (n, *d, &r); /* { dg-error "34:argument 2 in call to function" } */ + b = __builtin_add_overflow (n, 5, d); /* { dg-error "37:argument 3 in call" } */ + b = __builtin_sub_overflow (n, *d, &r); /* { dg-error "34:argument 2 in call to function" } */ + b = __builtin_sub_overflow (n, 5, d); /* { dg-error "37:argument 3 in call" } */ + b = __builtin_mul_overflow (n, *d, &r); /* { dg-error "34:argument 2 in call to function" } */ + b = __builtin_mul_overflow (n, 5, d); /* { dg-error "37:argument 3 in call" } */ +} + +int +fn1 (void) +{ + if (__builtin_constant_p ()) /* { dg-error "7:not enough" } */ + return 0; + if (__builtin_constant_p (1, 2)) /* { dg-error "7:too many" } */ + return 1; + if (__builtin_isfinite ()) /* { dg-error "7:not enough" } */ + return 3; + if (__builtin_isfinite (1, 2)) /* { dg-error "7:too many" } */ + return 4; + if (__builtin_isless (0)) /* { dg-error "7:not enough" } */ + return 5; + if (__builtin_isless (1, 2, 3)) /* { dg-error "7:too many" } */ + return 6; + if (__builtin_fpclassify (1, 2, 3, 4, 5)) /* { dg-error "7:not enough" } */ + return 7; + if (__builtin_fpclassify (1, 2, 3, 4, 5, r, 6)) /* { dg-error "7:too many" } */ + return 8; + if (__builtin_assume_aligned (p)) /* { dg-error "7:too few" } */ + return 9; + if (__builtin_assume_aligned (p, r, p, p)) /* { dg-error "7:too many" } */ + return 10; + if (__builtin_add_overflow ()) /* { dg-error "7:not enough" } */ + return 11; + if (__builtin_add_overflow (1, 2, 3, &r)) /* { dg-error "7:too many" } */ + return 12; + return -1; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr70935.c b/gcc/testsuite/gcc.dg/torture/pr70935.c new file mode 100644 index 00000000000..eb7f034ce83 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr70935.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */
+/* { dg-options "-O3 -g" } */
+
+int d0, sj, v0, rp, zi;
+
+void
+zn(void)
+{
+ if (v0 != 0)
+ {
+ int *js, *r3;
+ int pm, gc;
+
+ for (gc = 0; gc < 1; ++gc)
+ {
+ sj = 1;
+ while (sj != 0)
+ ;
+ }
+ r3 = ±
+ *js = (long)&gc;
+ka:
+ for (d0 = 0; d0 < 2; ++d0)
+ {
+ d0 = zi;
+ if (zi)
+ for (pm = 2; pm != 0; --pm)
+ ;
+ }
+ while (*r3 != 0)
+ {
+ while (pm)
+ ;
+ ++r3;
+ }
+ }
+ rp = 0;
+ goto ka;
+} diff --git a/gcc/testsuite/gcc.dg/torture/pr70941.c b/gcc/testsuite/gcc.dg/torture/pr70941.c new file mode 100644 index 00000000000..eb37a1fb293 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr70941.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ + +signed char a = 0, b = 0, c = 0, d = 0; + +int main() +{ + a = -(b - 405418259) - ((d && c) ^ 2040097152); + if (a != (signed char) -1634678893) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr70985.c b/gcc/testsuite/gcc.dg/torture/pr70985.c new file mode 100644 index 00000000000..17273b029a4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr70985.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target int32plus } */ + +struct +{ + int f0:24; +} a, c, d; + +int b; + +int +fn1 () +{ + return 0; +} + +void +fn2 () +{ + int e; + if (b) + for (; e;) + { + d = c; + if (fn1 (b)) + b = a.f0; + } +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ifc-10.c b/gcc/testsuite/gcc.dg/tree-ssa/ifc-10.c new file mode 100644 index 00000000000..70b74223892 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ifc-10.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-ifcvt-stats" } */ +/* { dg-require-visibility "" } */ + +int b[256] = {0}, y; +void bar (int *); +int foo (int x, int n) +{ + int i; + int a[128]; + + for (i = 0; i < n; i++) + { + a[i] = i; + if (x > i) + b[i] = y; + } + bar (a); + return 0; +} + +/* { dg-final { scan-tree-dump-times "Applying if-conversion" 1 "ifcvt" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ifc-11.c b/gcc/testsuite/gcc.dg/tree-ssa/ifc-11.c new file mode 100644 index 00000000000..bacf428ec03 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ifc-11.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-ifcvt-stats" } */ +/* { dg-require-visibility "" } */ + +int a[1024] = {0.0}; +int b[1024] = {0.0}; +int c[1024] = {0.0}; +int foo (float *x) +{ + int i = 0; + + for (i = 0; i < 1024; i++) + { + c[i] = (x[i] > 0.0) ? a[i] : b[i]; + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "Applying if-conversion" 1 "ifcvt" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ifc-12.c b/gcc/testsuite/gcc.dg/tree-ssa/ifc-12.c new file mode 100644 index 00000000000..89d42b4d6fd --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ifc-12.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-ifcvt-stats" } */ +/* { dg-require-visibility "" } */ + +struct st +{ + int a[1024]; + int b[1024]; +}; + +struct st s = {0}; +int foo (int x) +{ + int i; + struct st *p = &s; + + for (i = 0; i < 1024; i++) + { + if (x > i) + p->a[i] = p->b[i]; + } + + return 0; +} +/* { dg-final { scan-tree-dump-times "Applying if-conversion" 1 "ifcvt" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ifc-9.c b/gcc/testsuite/gcc.dg/tree-ssa/ifc-9.c new file mode 100644 index 00000000000..24c19c064f4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ifc-9.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-ifcvt-stats" } */ +/* { dg-require-visibility "" } */ + +extern int b[256], y; +void bar (int *, int); +int foo (int x, int n) +{ + int i; + int a[128]; + + for (i = 0; i < n; i++) + { + a[i] = i; + if (x > i) + y = b[i]; + } + bar (a, y); + return 0; +} + +/* { dg-final { scan-tree-dump-times "Applying if-conversion" 1 "ifcvt" } } */ diff --git a/gcc/testsuite/gcc.dg/ubsan/bounds-3.c b/gcc/testsuite/gcc.dg/ubsan/bounds-3.c new file mode 100644 index 00000000000..50ad67389f8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ubsan/bounds-3.c @@ -0,0 +1,22 @@ +/* PR sanitizer/70875 */ +/* { dg-do run } */ +/* { dg-options "-fsanitize=bounds" } */ + +int +foo (int n, int k) +{ + struct S + { + int i[n]; + int value; + } s[2]; + return s[k].value = 0; +} + +int +main () +{ + return foo (2, 2); +} + +/* { dg-output "index 2 out of bounds for type 'S \\\[2\\\]'" } */ diff --git a/gcc/testsuite/gcc.dg/vect/pr57206.c b/gcc/testsuite/gcc.dg/vect/pr57206.c new file mode 100644 index 00000000000..009688e93b0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr57206.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ + +void bad0(float * d, unsigned int n) +{ + unsigned int i; + for (i=n; i>0; --i) + d[n-i] = 0.0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/pr61194.c b/gcc/testsuite/gcc.dg/vect/pr61194.c index 8d74e009694..f7c71b91b48 100644 --- a/gcc/testsuite/gcc.dg/vect/pr61194.c +++ b/gcc/testsuite/gcc.dg/vect/pr61194.c @@ -38,4 +38,4 @@ int main() return 0; } -/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-23.c b/gcc/testsuite/gcc.dg/vect/vect-23.c index 44bed755fd3..e463f1b5cc9 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-23.c +++ b/gcc/testsuite/gcc.dg/vect/vect-23.c @@ -123,5 +123,5 @@ int main (void) return main1 (); } -/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */ /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-mask-store-move-1.c b/gcc/testsuite/gcc.dg/vect/vect-mask-store-move-1.c index f5cae4fcf75..f928dbf4c21 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-mask-store-move-1.c +++ b/gcc/testsuite/gcc.dg/vect/vect-mask-store-move-1.c @@ -15,4 +15,4 @@ void foo (int n) } } -/* { dg-final { scan-tree-dump-times "Move stmt to created bb" 6 "vect" { target { i?86-*-* x86_64-*-* } } } } */ +/* { dg-final { scan-tree-dump-times "Move stmt to created bb" 4 "vect" { target { i?86-*-* x86_64-*-* } } } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-vpmaddwd-3.c b/gcc/testsuite/gcc.target/i386/avx512bw-vpmaddwd-3.c new file mode 100644 index 00000000000..d0c7c38e195 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512bw-vpmaddwd-3.c @@ -0,0 +1,24 @@ +/* { dg-do assemble { target { avx512bw && { avx512vl && { ! ia32 } } } } } */ +/* { dg-options "-O2 -mavx512bw -mavx512vl" } */ + +#include <x86intrin.h> + +void +f1 (__m128i x, __m128i y) +{ + register __m128i a __asm ("xmm16"), b __asm ("xmm17"); + a = x; b = y; + asm volatile ("" : "+v" (a), "+v" (b)); + a = _mm_madd_epi16 (a, b); + asm volatile ("" : "+v" (a)); +} + +void +f2 (__m256i x, __m256i y) +{ + register __m256i a __asm ("xmm16"), b __asm ("xmm17"); + a = x; b = y; + asm volatile ("" : "+v" (a), "+v" (b)); + a = _mm256_madd_epi16 (a, b); + asm volatile ("" : "+v" (a)); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-vpsraw-3.c b/gcc/testsuite/gcc.target/i386/avx512bw-vpsraw-3.c new file mode 100644 index 00000000000..305dbccb9a0 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512bw-vpsraw-3.c @@ -0,0 +1,44 @@ +/* { dg-do assemble { target { avx512bw && { avx512vl && { ! ia32 } } } } } */ +/* { dg-options "-O2 -mavx512bw -mavx512vl" } */ + +#include <x86intrin.h> + +void +f1 (__m128i x, int y) +{ + register __m128i a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = _mm_srai_epi16 (a, y); + asm volatile ("" : "+v" (a)); +} + +void +f2 (__m128i x) +{ + register __m128i a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = _mm_srai_epi16 (a, 16); + asm volatile ("" : "+v" (a)); +} + +void +f3 (__m256i x, int y) +{ + register __m256i a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = _mm256_srai_epi16 (a, y); + asm volatile ("" : "+v" (a)); +} + +void +f4 (__m256i x) +{ + register __m256i a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = _mm256_srai_epi16 (a, 16); + asm volatile ("" : "+v" (a)); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vfmadd-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vfmadd-1.c new file mode 100644 index 00000000000..f317ec66a3a --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vfmadd-1.c @@ -0,0 +1,27 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -mavx512f" } */ + +#include <x86intrin.h> + +void +f1 (__m512d x, __m512d y, __m512d z, __mmask8 m) +{ + register __m512d a __asm ("xmm16"), b __asm ("xmm17"), c __asm ("xmm18"); + a = x; b = y; c = z; + asm volatile ("" : "+v" (a), "+v" (b), "+v" (c)); + a = _mm512_mask3_fmadd_round_pd (c, b, a, m, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); + asm volatile ("" : "+v" (a)); +} + +void +f2 (__m512 x, __m512 y, __m512 z, __mmask8 m) +{ + register __m512 a __asm ("xmm16"), b __asm ("xmm17"), c __asm ("xmm18"); + a = x; b = y; c = z; + asm volatile ("" : "+v" (a), "+v" (b), "+v" (c)); + a = _mm512_mask3_fmadd_round_ps (c, b, a, m, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler "vfmadd231pd\[^\n\r\]*zmm16" } } */ +/* { dg-final { scan-assembler "vfmadd231ps\[^\n\r\]*zmm16" } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-vmovq-1.c b/gcc/testsuite/gcc.target/i386/avx512vl-vmovq-1.c new file mode 100644 index 00000000000..8f3d3460a6c --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512vl-vmovq-1.c @@ -0,0 +1,16 @@ +/* { dg-do assemble { target { avx512vl && { ! ia32 } } } } */ +/* { dg-options "-O2 -mavx512vl" } */ + +#include <x86intrin.h> + +void +foo (__m128i x, __m128i *y) +{ + register __m128i a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = _mm_move_epi64 (a); + asm volatile ("" : "+v" (a)); + a = _mm_move_epi64 (*y); + asm volatile ("" : "+v" (a)); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-vpsrad-3.c b/gcc/testsuite/gcc.target/i386/avx512vl-vpsrad-3.c new file mode 100644 index 00000000000..2e3f92b58b7 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512vl-vpsrad-3.c @@ -0,0 +1,44 @@ +/* { dg-do assemble { target { avx512vl && { ! ia32 } } } } */ +/* { dg-options "-O2 -mavx512vl" } */ + +#include <x86intrin.h> + +void +f1 (__m128i x, int y) +{ + register __m128i a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = _mm_srai_epi32 (a, y); + asm volatile ("" : "+v" (a)); +} + +void +f2 (__m128i x) +{ + register __m128i a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = _mm_srai_epi32 (a, 16); + asm volatile ("" : "+v" (a)); +} + +void +f3 (__m256i x, int y) +{ + register __m256i a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = _mm256_srai_epi32 (a, y); + asm volatile ("" : "+v" (a)); +} + +void +f4 (__m256i x) +{ + register __m256i a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = _mm256_srai_epi32 (a, 16); + asm volatile ("" : "+v" (a)); +} diff --git a/gcc/testsuite/gcc.target/i386/fabsneg-1.c b/gcc/testsuite/gcc.target/i386/fabsneg-1.c new file mode 100644 index 00000000000..3cdf4566864 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/fabsneg-1.c @@ -0,0 +1,36 @@ +/* { dg-do run } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O2 -mtune=nocona" } */ + +double x; + +void +__attribute__ ((noinline, noclone)) +test_fabs (double a) +{ + asm volatile ("" : "+r" (a)); + x = __builtin_fabs (a); +} + +void +__attribute__ ((noinline, noclone)) +test_neg (double a) +{ + asm volatile ("" : "+r" (a)); + x = -a; +} + +int main () +{ + test_fabs (-1.0); + + if (x != 1.0) + __builtin_abort (); + + test_neg (-1.0); + + if (x != 1.0) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/mips/mips16-attributes.c b/gcc/testsuite/gcc.target/mips/mips16-attributes.c index 28bb9aae7fa..d90ec66d037 100644 --- a/gcc/testsuite/gcc.target/mips/mips16-attributes.c +++ b/gcc/testsuite/gcc.target/mips/mips16-attributes.c @@ -3,6 +3,7 @@ function. */ /* { dg-do run } */ /* { dg-options "(-mips16)" } */ +/* { dg-skip-if "" { *-*-* } { "-mmicromips" } { "" } } */ #include <stdlib.h> diff --git a/gcc/testsuite/gcc.target/powerpc/pr70866.c b/gcc/testsuite/gcc.target/powerpc/pr70866.c new file mode 100644 index 00000000000..25fd05a1deb --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr70866.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-ffixed-cr2 -ffixed-cr3 -ffixed-cr4" } */ + +#define SET_CR(R,V) __asm__ __volatile__ ("mtcrf %0,%1" : : "n" (1<<(7-R)), "r" (V<<(4*(7-R))) : "cr" #R) + +void foo (void) +{ + SET_CR (2, 7); + SET_CR (3, 8); + SET_CR (4, 9); +} diff --git a/gcc/testsuite/gcc.target/powerpc/savres.c b/gcc/testsuite/gcc.target/powerpc/savres.c index f472f23e728..f724f308094 100644 --- a/gcc/testsuite/gcc.target/powerpc/savres.c +++ b/gcc/testsuite/gcc.target/powerpc/savres.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-fno-inline -fomit-frame-pointer" } */ +/* { dg-options "-fno-inline -fomit-frame-pointer -fno-rename-registers" } */ /* { dg-additional-options "-mdynamic-no-pic" { target *-*-darwin* } } */ /* -fno-inline -maltivec -m32/-m64 -mmultiple/no-multiple -Os/-O2. */ @@ -10,6 +10,13 @@ #define SET_GPR(R,V) SET (long, R, V) #define SET_FPR(R,V) SET (double, R, V) #define SET_VR(R,V) SET (__attribute__ ((vector_size (16))) int, R, V) +/* There doesn't seem to be a way of letting gcc know that cr2, cr3 + and cr4 are being used, and therefore should not be touched by + gcc. Unlike gpr, fpr and vr we can't do something like + register __attribute__ ((__mode__ ("__CC__"))) int cr2 __asm__ ("cr2"); + This makes the test somewhat fragile, dependent on gcc not using + any of cr2, cr3 and cr4 in main(), and is why -fno-rename-registers + is required. */ #define SET_CR(R,V) __asm__ __volatile__ ("mtcrf %0,%1" : : "n" (1<<(7-R)), "r" (V<<(4*(7-R))) : "cr" #R) #define TRASH_GPR(R) SET_GPR (R, 0) #define TRASH_FPR(R) SET_FPR (R, 0) @@ -1063,7 +1070,18 @@ void ws_0 (void) abort (); } -int main (void) +/* We'd like to compile main with + __attribute__ ((__optimize__ ("fixed-cr2,fixed-cr3,fixed-cr4"))) + but that doesn't do anything currently. Obviously we don't want to + compile the whole file with -ffixed-cr2 -ffixed-cr3 -ffixed-cr4 as + that would also tell gcc not to save/restore cr, and we're trying + to check that the above functions do save/restore cr. + __attribute__ ((__optimize__ ("no-rename-registers,omit-frame-pointer"))) + works, but it seems odd to need omit-frame-pointer and raises the + question of whether darwin would need -mdynamic-no-pic. + So for now use -fno-rename-registers over the whole test. */ +int +main (void) { INIT_REGS; USE_ALL_CR; diff --git a/gcc/testsuite/gcc.target/sh/pr52933-1.c b/gcc/testsuite/gcc.target/sh/pr52933-1.c index 138de7f4914..81aa94fc8f0 100644 --- a/gcc/testsuite/gcc.target/sh/pr52933-1.c +++ b/gcc/testsuite/gcc.target/sh/pr52933-1.c @@ -4,13 +4,13 @@ logic usually show up as redundant tst insns. */ /* { dg-do compile } */ /* { dg-options "-O2" } */ -/* { dg-final { scan-assembler-times "div0s" 32 } } */ +/* { dg-final { scan-assembler-times "div0s" 42 } } */ /* { dg-final { scan-assembler-not "tst" } } */ /* { dg-final { scan-assembler-not "not\t" } } */ /* { dg-final { scan-assembler-not "nott" } } */ -/* { dg-final { scan-assembler-times "negc" 9 { target { ! sh2a } } } } */ -/* { dg-final { scan-assembler-times "movrt" 9 { target { sh2a } } } } */ +/* { dg-final { scan-assembler-times "negc" 10 { target { ! sh2a } } } } */ +/* { dg-final { scan-assembler-times "movrt" 10 { target { sh2a } } } } */ typedef unsigned char bool; @@ -212,3 +212,75 @@ test_30 (int a, int b) { return ((a >> 31) ^ (b >> 31)) & 1; } + +// ------------------------------------------------------- + +bool +test_31 (int a, int b) +{ + /* 2x exts.w, div0s */ + return ((a & 0x8000) ^ (b & 0x8000)) != 0; +} + +bool +test_32 (int a, int b) +{ + /* 2x exts.w, div0s */ + return (a & 0x8000) != (b & 0x8000); +} + +bool +test_33 (int a, int b) +{ + /* 2x add/shll, div0s */ + return ((a & (1<<30)) ^ (b & (1<<30))) != 0; +} + +bool +test_34 (int a, int b) +{ + /* 2x exts.b, div0s */ + return (a & 0x80) != (b & 0x80); +} + +bool +test_35 (signed char a, signed char b) +{ + /* 2x exts.b, div0s */ + return (a < 0) != (b < 0); +} + +bool +test_36 (short a, short b) +{ + /* 2x exts.w, div0s */ + return (a < 0) != (b < 0); +} + +int +test_37 (short a, short b) +{ + /* 2x exts.w, div0s */ + return (a < 0) != (b < 0) ? 40 : -10; +} + +bool +test_38 (int a, int b) +{ + /* 2x shll8, div0s */ + return ((a & (1<<23)) ^ (b & (1<<23))) != 0; +} + +bool +test_39 (int a, int b) +{ + /* 2x shll2, div0s */ + return ((a & (1<<29)) ^ (b & (1<<29))) != 0; +} + +bool +test_40 (short a, short b) +{ + /* 2x exts.w, div0s, negc */ + return (a < 0) == (b < 0); +} diff --git a/gcc/testsuite/gcc.target/sh/pr52933-2.c b/gcc/testsuite/gcc.target/sh/pr52933-2.c index 4637f0ea17e..2b5d09ad0bb 100644 --- a/gcc/testsuite/gcc.target/sh/pr52933-2.c +++ b/gcc/testsuite/gcc.target/sh/pr52933-2.c @@ -5,12 +5,12 @@ logic usually show up as redundant tst insns. */ /* { dg-do compile } */ /* { dg-options "-O2 -mpretend-cmove" } */ -/* { dg-final { scan-assembler-times "div0s" 32 } } */ +/* { dg-final { scan-assembler-times "div0s" 42 } } */ /* { dg-final { scan-assembler-not "tst" } } */ /* { dg-final { scan-assembler-not "not\t" } } */ /* { dg-final { scan-assembler-not "nott" } } */ -/* { dg-final { scan-assembler-times "negc" 9 { target { ! sh2a } } } } */ -/* { dg-final { scan-assembler-times "movrt" 9 { target { sh2a } } } } */ +/* { dg-final { scan-assembler-times "negc" 10 { target { ! sh2a } } } } */ +/* { dg-final { scan-assembler-times "movrt" 10 { target { sh2a } } } } */ #include "pr52933-1.c" diff --git a/gcc/testsuite/gcc.target/sh/pr54089-1.c b/gcc/testsuite/gcc.target/sh/pr54089-1.c index 64f79ebc737..8b6a729f64c 100644 --- a/gcc/testsuite/gcc.target/sh/pr54089-1.c +++ b/gcc/testsuite/gcc.target/sh/pr54089-1.c @@ -1,7 +1,8 @@ /* Check that the rotcr instruction is generated. */ /* { dg-do compile } */ /* { dg-options "-O2" } */ -/* { dg-final { scan-assembler-times "rotcr" 24 } } */ +/* { dg-final { scan-assembler-times "rotcr" 25 } } */ +/* { dg-final { scan-assembler-times "sett" 1 } } */ /* { dg-final { scan-assembler-times "shll\t" 1 } } */ /* { dg-final { scan-assembler-not "and\t#1" } } */ /* { dg-final { scan-assembler-not "cmp/pl" } } */ @@ -173,3 +174,9 @@ test_23 (unsigned int a, int b, int c) bool r = b != c; return ((a >> 31) | (r << 31)); } + +unsigned int +test_24 (unsigned int a) +{ + return (a >> 1) | (1 << 31); +} diff --git a/gcc/testsuite/gcc.target/sh/pr58219.c b/gcc/testsuite/gcc.target/sh/pr58219.c new file mode 100644 index 00000000000..d900f72eae8 --- /dev/null +++ b/gcc/testsuite/gcc.target/sh/pr58219.c @@ -0,0 +1,60 @@ +/* Check that move instructions have the correct length on SH2A. */ +/* { dg-do compile } */ +/* { dg-options "-O1 -dp" } */ + +/* { dg-final { scan-assembler-times "length = 4" 10 { target { "sh2a" && any_fpu } } } } */ +/* { dg-final { scan-assembler-times "length = 4" 8 { target { "sh2a" && no_fpu } } } } */ + +int +test_00 (int* x) +{ + return x[0]; +} + +int +test_01 (int* x) +{ + return x[1]; +} + +int +test_02 (int* x) +{ + return x[100]; +} + +int +test_03 (int* x, unsigned int y) +{ + return *(int*)((unsigned int)x + y); +} + +float +test_04 (float* x) +{ + return x[0]; +} + +float +test_05 (float* x) +{ + return x[5]; +} + +float +test_06 (float* x) +{ + return x[100]; +} + +int +test_07 (void) +{ + return 1230; +} + +int +test_08 (void) +{ + return 0xFF0000; +} diff --git a/gcc/testsuite/gfortran.dg/dec_structure_1.f90 b/gcc/testsuite/gfortran.dg/dec_structure_1.f90 new file mode 100644 index 00000000000..4dfee3c602e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_structure_1.f90 @@ -0,0 +1,56 @@ +! { dg-do run } +! { dg-options "-fdec-structure" } +! +! Basic STRUCTURE test. +! + +subroutine aborts (s) + character(*), intent(in) :: s + print *, s + call abort() +end subroutine + +! Basic structure +structure /s1/ ! type s1 + integer i1 + logical l1 + real r1 + character c1 +end structure ! end type s1 + +record /s1/ r1 ! type (s1) r1 +record /s1/ r1_a(3) ! type (s1) r1_a(3) + +! Basic records +r1.i1 = 13579 ! r1%i1 = ... +r1.l1 = .true. +r1.r1 = 13.579 +r1.c1 = 'F' +r1_a(2) = r1 +r1_a(3).r1 = 135.79 + +if (r1.i1 .ne. 13579) then + call aborts("r1.i1") +endif + +if (r1.l1 .neqv. .true.) then + call aborts("r1.l1") +endif + +if (r1.r1 .ne. 13.579) then + call aborts("r1.r1") +endif + +if (r1.c1 .ne. 'F') then + call aborts("r1.c1") +endif + +if (r1_a(2).i1 .ne. 13579) then + call aborts("r1_a(2).i1") +endif + +if (r1_a(3).r1 .ne. 135.79) then + call aborts("r1_a(3).r1") +endif + +end diff --git a/gcc/testsuite/gfortran.dg/dec_structure_10.f90 b/gcc/testsuite/gfortran.dg/dec_structure_10.f90 new file mode 100644 index 00000000000..2d92b1ad8fd --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_structure_10.f90 @@ -0,0 +1,119 @@ +! { dg-do run } +! { dg-options "-fdec-structure" } +! +! Runtime tests for rules governing dot ('.') as a member accessor, including +! voodoo with aliased user-defined vs. intrinsic operators and nested members. +! See gcc/fortran/match.c (gfc_match_member_sep). +! + +module dec_structure_10 + ! Operator overload tests with .ne. and constant member + structure /s1/ + integer i + integer ne + logical b + end structure + + ! Operator overload tests with .eq., .test. and nested members + structure /s2/ + record /s1/ eq + record /s1/ test + record /s1/ and + integer i + end structure + + ! Deep nested access tests + structure /s3/ + record /s2/ r2 + end structure + structure /s4/ + record /s3/ r3 + end structure + structure /s5/ + record /s4/ r4 + end structure + structure /s6/ + record /s5/ r5 + end structure + structure /s7/ + record /s6/ r6 + end structure + + ! Operator overloads to mess with nested member accesses + interface operator (.ne.) + module procedure ne_func + end interface operator (.ne.) + interface operator (.eq.) + module procedure eq_func + end interface operator (.eq.) + interface operator (.test.) + module procedure tstfunc + end interface operator (.test.) + contains + ! ne_func will be called on (x) .ne. (y) + function ne_func (r, i) + integer, intent(in) :: i + type(s1), intent(in) :: r + integer ne_func + ne_func = r%i + i + end function + ! eq_func will be called on (x) .eq. (y) + function eq_func (r, i) + integer, intent(in) :: i + type(s2), intent(in) :: r + integer eq_func + eq_func = r%eq%i + i + end function eq_func + ! tstfunc will be called on (x) .test. (y) + function tstfunc (r, i) + integer, intent(in) :: i + type(s2), intent(in) :: r + integer tstfunc + tstfunc = r%i + i + end function tstfunc +end module + +use dec_structure_10 + +record /s1/ r +record /s2/ struct +record /s7/ r7 +integer i, j +logical l +struct%eq%i = 5 +i = -5 + +! Nested access: struct has a member and which has a member b +l = struct .and. b ! struct%and%b +l = struct .and. b .or. .false. ! (struct%and%b) .or. (.false.) + +! Intrinsic op: r has no member 'ne' +j = r .ne. i ! <intrinsic> ne(r, i) +j = (r) .ne. i ! <intrinsic> ne(r, i) + +! Intrinsic op; r has a member 'ne' but it is not a record +j = r .ne. i ! <intrinsic> ne(r, i) +j = (r) .ne. i ! <intrinsic> ne(r, i) + +! Nested access: struct has a member eq which has a member i +j = struct .eq. i ! struct%eq%i +if ( j .ne. struct%eq%i ) call abort() + +! User op: struct is compared to i with eq_func +j = (struct) .eq. i ! eq_func(struct, i) -> struct%eq%i + i +if ( j .ne. struct%eq%i + i ) call abort() + +! User op: struct has a member test which has a member i, but test is a uop +j = struct .test. i ! tstfunc(struct, i) -> struct%i + i +if ( j .ne. struct%i + i ) call abort() + +! User op: struct is compared to i with eq_func +j = (struct) .test. i ! tstfunc(struct, i) -> struct%i + i +if ( j .ne. struct%i + i ) call abort() + +! Deep nested access tests +r7.r6.r5.r4.r3.r2.i = 1337 +j = r7.r6.r5.r4.r3.r2.i +if ( j .ne. 1337 ) call abort() + +end diff --git a/gcc/testsuite/gfortran.dg/dec_structure_11.f90 b/gcc/testsuite/gfortran.dg/dec_structure_11.f90 new file mode 100644 index 00000000000..f6f5b6f9d13 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_structure_11.f90 @@ -0,0 +1,20 @@ +! { dg-do compile } +! { dg-options "-fdec-structure" } +! +! Tests for what CAN'T be done with dot ('.') as a member accessor. +! + +structure /s1/ + integer eq +end structure + +record /s1/ r +integer i, j, k + +j = i.j ! { dg-error "nonderived-type variable" } +j = r .eq. i ! { dg-error "Operands of comparison" } +j = r.i ! { dg-error "is not a member of" } +j = r. ! { dg-error "Expected structure component or operator name" } +j = .i ! { dg-error "Invalid character in name" } + +end diff --git a/gcc/testsuite/gfortran.dg/dec_structure_2.f90 b/gcc/testsuite/gfortran.dg/dec_structure_2.f90 new file mode 100644 index 00000000000..18db719c149 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_structure_2.f90 @@ -0,0 +1,41 @@ +! { dg-do run } +! { dg-options "-fdec-structure" } +! +! Test STRUCTUREs containin other STRUCTUREs. +! + +subroutine aborts (s) + character(*), intent(in) :: s + print *, s + call abort() +end subroutine + +! Basic structure +structure /s1/ + integer i1 + logical l1 + real r1 + character c1 +end structure + +structure /s2/ + integer i + record /s1/ r1 +endstructure + +record /s1/ r1 +record /s2/ r2, r2_a(10) + +! Nested and array records +r2.r1.r1 = 135.79 +r2_a(3).r1.i1 = -13579 + +if (r2.r1.r1 .ne. 135.79) then + call aborts("r1.r1.r1") +endif + +if (r2_a(3).r1.i1 .ne. -13579) then + call aborts("r2_a(3).r1.i1") +endif + +end diff --git a/gcc/testsuite/gfortran.dg/dec_structure_3.f90 b/gcc/testsuite/gfortran.dg/dec_structure_3.f90 new file mode 100644 index 00000000000..9cb7adb6719 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_structure_3.f90 @@ -0,0 +1,52 @@ +! { dg-do run } +! { dg-options "-fdec-structure" } +! +! Test nested STRUCTURE definitions. +! + +subroutine aborts (s) + character(*), intent(in) :: s + print *, s + call abort() +end subroutine + +structure /s3/ + real p + structure /s4/ recrd, recrd_a(3) + integer i, j + end structure + real q +end structure + +record /s3/ r3 +record /s4/ r4 + +r3.p = 1.3579 +r4.i = 0 +r4.j = 1 +r3.recrd = r4 +r3.recrd_a(1) = r3.recrd +r3.recrd_a(2).i = 1 +r3.recrd_a(2).j = 0 + +if (r3.p .ne. 1.3579) then + call aborts("r3.p") +endif + +if (r4.i .ne. 0) then + call aborts("r4.i") +endif + +if (r4.j .ne. 1) then + call aborts("r4.j") +endif + +if (r3.recrd.i .ne. 0 .or. r3.recrd.j .ne. 1) then + call aborts("r3.recrd") +endif + +if (r3.recrd_a(2).i .ne. 1 .or. r3.recrd_a(2).j .ne. 0) then + call aborts("r3.recrd_a(2)") +endif + +end diff --git a/gcc/testsuite/gfortran.dg/dec_structure_4.f90 b/gcc/testsuite/gfortran.dg/dec_structure_4.f90 new file mode 100644 index 00000000000..a941c220b7e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_structure_4.f90 @@ -0,0 +1,43 @@ +! { dg-do run } +! { dg-options "-fdec-structure" } +! +! Test anonymous STRUCTURE definitions. +! + +subroutine aborts (s) + character(*), intent(in) :: s + print *, s + call abort() +end subroutine + +structure /s5/ + structure recrd, recrd_a(3) + real x, y + end structure +end structure + +record /s5/ r5 + +r5.recrd.x = 1.3 +r5.recrd.y = 5.7 +r5.recrd_a(1) = r5.recrd +r5.recrd_a(2).x = 5.7 +r5.recrd_a(2).y = 1.3 + +if (r5.recrd.x .ne. 1.3) then + call aborts("r5.recrd.x") +endif + +if (r5.recrd.y .ne. 5.7) then + call aborts("r5.recrd.y") +endif + +if (r5.recrd_a(1).x .ne. 1.3 .or. r5.recrd_a(1).y .ne. 5.7) then + call aborts("r5.recrd_a(1)") +endif + +if (r5.recrd_a(2).x .ne. 5.7 .or. r5.recrd_a(2).y .ne. 1.3) then + call aborts("r5.recrd_a(2)") +endif + +end diff --git a/gcc/testsuite/gfortran.dg/dec_structure_5.f90 b/gcc/testsuite/gfortran.dg/dec_structure_5.f90 new file mode 100644 index 00000000000..abda3c3e9fb --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_structure_5.f90 @@ -0,0 +1,49 @@ +! { dg-do run } +! { dg-options "-fdec-structure" } +! +! Test STRUCTUREs which share names with variables. +! + +subroutine aborts (s) + character(*), intent(in) :: s + print *, s + call abort() +end subroutine + +! Special regression where shared names within a module caused an ICE +! from gfc_get_module_backend_decl +module dec_structure_5m + structure /s6/ + integer i + end structure + + record /s6/ s6 +end module + +program dec_structure_5 + use dec_structure_5m + + structure /s7/ + real r + end structure + + record /s7/ s7(3) + + s6.i = 0 + s7(1).r = 1.0 + s7(2).r = 2.0 + s7(3).r = 3.0 + + if (s6.i .ne. 0) then + call aborts("s6.i") + endif + + if (s7(1).r .ne. 1.0) then + call aborts("s7(1).r") + endif + + if (s7(2).r .ne. 2.0) then + call aborts("s7(2).r") + endif + +end diff --git a/gcc/testsuite/gfortran.dg/dec_structure_6.f90 b/gcc/testsuite/gfortran.dg/dec_structure_6.f90 new file mode 100644 index 00000000000..6494d71fd1c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_structure_6.f90 @@ -0,0 +1,46 @@ +! { dg-do run } +! { dg-options "-fdec-structure" } +! +! Test old-style CLIST initializers in STRUCTURE. +! + +subroutine aborts (s) + character(*), intent(in) :: s + print *, s + call abort() +end subroutine + +integer, parameter :: as = 3 +structure /s8/ + character*20 c /"HELLO"/ ! ok + integer*2 j /300_4/ ! ok, converted + integer k /65536_8/ ! ok, implicit + integer*4 l /200000/ ! ok, types match + integer m(5) /5,4,3,2,1/! ok + integer n(5) /1,3*2,1/ ! ok, with repeat spec (/1,2,2,2,1/) + integer o(as) /as*9/ ! ok, parameter array spec + integer p(2,2) /1,2,3,4/! ok + real q(3) /1_2,3.5,2.4E-12_8/ ! ok, with some implicit conversions + integer :: canary = z'3D3D3D3D' +end structure + +record /s8/ r8 + +! Old-style (clist) initializers in structures +if ( r8.c /= "HELLO" ) call aborts ("r8.c") +if ( r8.j /= 300 ) call aborts ("r8.j") +if ( r8.k /= 65536 ) call aborts ("r8.k") +if ( r8.l /= 200000 ) call aborts ("r8.l") +if ( r8.m(1) /= 5 .or. r8.m(2) /= 4 .or. r8.m(3) /= 3 & + .or. r8.m(4) /= 2 .or. r8.m(5) /= 1) & + call aborts ("r8.m") +if ( r8.n(1) /= 1 .or. r8.n(2) /= 2 .or. r8.n(3) /= 2 .or. r8.n(4) /= 2 & + .or. r8.n(5) /= 1) & + call aborts ("r8.n") +if ( r8.o(1) /= 9 .or. r8.o(2) /= 9 .or. r8.o(3) /= 9 ) call aborts ("r8.o") +if ( r8.p(1,1) /= 1 .or. r8.p(2,1) /= 2 .or. r8.p(1,2) /= 3 & + .or. r8.p(2,2) /= 4) & + call aborts ("r8.p") +if ( r8.canary /= z'3D3D3D3D' ) call aborts ("r8.canary") + +end diff --git a/gcc/testsuite/gfortran.dg/dec_structure_7.f90 b/gcc/testsuite/gfortran.dg/dec_structure_7.f90 new file mode 100644 index 00000000000..baba1ef2b5f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_structure_7.f90 @@ -0,0 +1,75 @@ +! { dg-do run } +! { dg-options "-fdec-structure" } +! +! Test passing STRUCTUREs through functions and subroutines. +! + +subroutine aborts (s) + character(*), intent(in) :: s + print *, s + call abort() +end subroutine + +module dec_structure_7m + structure /s1/ + integer i1 + logical l1 + real r1 + character c1 + end structure + + structure /s2/ + integer i + record /s1/ r1 + endstructure + +contains + ! Pass structure through subroutine + subroutine sub (rec1, i) + implicit none + integer, intent(in) :: i + record /s1/ rec1 + rec1.i1 = i + end subroutine + + ! Pass structure through function + function func (rec2, r) + implicit none + real, intent(in) :: r + record /s2/ rec2 + real func + rec2.r1.r1 = r + func = rec2.r1.r1 + return + end function +end module + +program dec_structure_7 + use dec_structure_7m + + implicit none + record /s1/ r1 + record /s2/ r2 + real junk + + ! Passing through functions and subroutines + r1.i1 = 0 + call sub (r1, 10) + + r2.r1.r1 = 0.0 + junk = func (r2, -20.14) + + if (r1.i1 .ne. 10) then + call aborts("sub(r1, 10)") + endif + + if (r2.r1.r1 .ne. -20.14) then + call aborts("func(r2, -20.14)") + endif + + if (junk .ne. -20.14) then + print *, junk + call aborts("junk = func()") + endif + +end program diff --git a/gcc/testsuite/gfortran.dg/dec_structure_8.f90 b/gcc/testsuite/gfortran.dg/dec_structure_8.f90 new file mode 100644 index 00000000000..160b92a8b96 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_structure_8.f90 @@ -0,0 +1,60 @@ +! { dg-do compile } +! { dg-options "-fdec-structure -fmax-errors=0" } +! +! Comprehensive compile tests for what structures CAN'T do. +! + +! Old-style (clist) initialization +integer,parameter :: as = 3 +structure /t1/ + integer*1 a /300_2/ ! { dg-error "Arithmetic overflow" } + integer b // ! { dg-error "Empty old style initializer list" } + integer c /2*3/ ! { dg-error "Repeat spec invalid in scalar" } + integer d /1,2,3/ ! { dg-error "End of scalar initializer expected" } + integer e /"HI"/ ! { dg-error "Can't convert" } + integer f(as) /4*9/ ! { dg-error "Too many elements" } + integer g(3) /1,3/ ! { dg-error "Not enough elements" } + integer h(3) /1,3,5,7/ ! { dg-error "Too many elements" } + integer i(3) /2*1/ ! { dg-error "Not enough elements" } + integer j(3) /10*1/ ! { dg-error "Too many elements" } + integer k(3) /2.5*3/ ! { dg-error "Repeat spec must be an integer" } + integer l(2) /2*/ ! { dg-error "Expected data constant" } + integer m(1) / ! { dg-error "Syntax error in old style" } + integer n(2) /1 ! { dg-error "Syntax error in old style" } + integer o(2) /1, ! { dg-error "Syntax error in old style" } + integer p(1) /x/ ! { dg-error "must be a PARAMETER" } +end structure + +structure ! { dg-error "Structure name expected" } +structure / ! { dg-error "Structure name expected" } +structure // ! { dg-error "Structure name expected" } +structure /.or./ ! { dg-error "Structure name expected" } +structure /integer/ ! { dg-error "Structure name.*cannot be the same" } +structure /foo/ bar ! { dg-error "Junk after" } +structure /t1/ ! { dg-error "Type definition.*T1" } + +record ! { dg-error "Structure name expected" } +record bar ! { dg-error "Structure name expected" } +record / bar ! { dg-error "Structure name expected" } +record // bar ! { dg-error "Structure name expected" } +record foo/ bar ! { dg-error "Structure name expected" } +record /foo bar ! { dg-error "Structure name expected" } +record /foo/ bar ! { dg-error "used before it is defined" } +record /t1/ ! { dg-error "Invalid character in name" } + +structure /t2/ + ENTRY here ! { dg-error "ENTRY statement.*cannot appear" } + integer a + integer a ! { dg-error "Component.*already declared" } + structure $z ! { dg-error "Invalid character in name" } + structure // ! { dg-error "Invalid character in name" } + structure // x ! { dg-error "Invalid character in name" } + structure /t3/ ! { dg-error "Invalid character in name" } + structure /t3/ x,$y ! { dg-error "Invalid character in name" } + structure /t4/ y + integer i, j, k + end structure + structure /t4/ z ! { dg-error "Type definition.*T4" } +end structure + +end diff --git a/gcc/testsuite/gfortran.dg/dec_structure_9.f90 b/gcc/testsuite/gfortran.dg/dec_structure_9.f90 new file mode 100644 index 00000000000..34c46c61c1c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_structure_9.f90 @@ -0,0 +1,42 @@ +! { dg-do compile } +! { dg-options "-fdec-structure" } +! +! Basic compile tests for what CAN be done with dot ('.') as a member accessor. +! + +logical :: l, l2 = .true., l3 = .false., and +integer i +character(5) s +real r + +structure /s1/ + integer i + character(5) s + real r +end structure + +record /s1/ r1 + +! Basic +l = l .and. l2 .or. l3 +l = and .and. and .and. and +l = l2 .eqv. l3 +l = (l2) .eqv. l3 + +! Integers +l = .not. (i .eq. 0) +l = .not. (0 .eq. i) +l = .not. (r1.i .eq. 0) +l = .not. (0 .eq. r1.i) +! Characters +l = .not. (s .eq. "hello") +l = .not. ("hello" .eq. s) +l = .not. (r1.s .eq. "hello") +l = .not. ("hello" .eq. r1.s) +! Reals +l = .not. (r .eq. 3.14) +l = .not. (3.14 .eq. r) +l = .not. (r1.r .eq. 3.14) +l = .not. (3.14 .eq. r1.r) + +end diff --git a/gcc/testsuite/gfortran.dg/dec_union_1.f90 b/gcc/testsuite/gfortran.dg/dec_union_1.f90 new file mode 100644 index 00000000000..36af53adfe1 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_union_1.f90 @@ -0,0 +1,66 @@ +! { dg-do run } +! { dg-options "-fdec-structure" } +! +! Test whether union backend declarations are corrently _not_ copied when they +! are not in fact equal. The structure defined in sub() is seen later, but +! where siz has a different value. +! + +subroutine aborts (s) + character(*), intent(in) :: s + print *, s + call abort() +end subroutine + +subroutine sub () + integer, parameter :: siz = 1024 + structure /s6/ + union ! U0 + map ! M0 + integer ibuf(siz) + end map + map ! M1 + character(8) cbuf(siz) + end map + map ! M2 + real rbuf(siz) + end map + end union + end structure + record /s6/ r6 + r6.ibuf(1) = z'badbeef' + r6.ibuf(2) = z'badbeef' +end subroutine + +! Repeat definition from subroutine sub with different size parameter. +! If the structure definition is copied here the stack may get messed up. +integer, parameter :: siz = 65536 +structure /s6/ + union ! U12 + map + integer ibuf(siz) + end map + map + character(8) cbuf(siz) + end map + map + real rbuf(siz) + end map + end union +end structure + +record /s6/ r6 +integer :: r6_canary = 0 + +! Copied type declaration - this should not cause problems +i = 1 +do while (i < siz) + r6.ibuf(i) = z'badbeef' + i = i + 1 +end do + +if ( r6_canary .ne. 0 ) then + call aborts ('copied decls: overflow') +endif + +end diff --git a/gcc/testsuite/gfortran.dg/dec_union_2.f90 b/gcc/testsuite/gfortran.dg/dec_union_2.f90 new file mode 100644 index 00000000000..61e4fd8bd80 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_union_2.f90 @@ -0,0 +1,60 @@ +! { dg-do run } +! { dg-options "-fdec-structure" } +! +! Test basic UNION implementation. +! + +subroutine aborts (s) + character(*), intent(in) :: s + print *, s + call abort() +end subroutine + +! Empty union +structure /s0/ + union ! U0 + map ! M0 + end map + map ! M1 + end map + end union +end structure + +! Basic unions +structure /s1/ + union ! U1 + map ! M2 + integer(4) a + end map + map ! M3 + real(4) b + end map + end union +end structure +structure /s2/ + union ! U2 + map ! M4 + integer(2) w1, w2 + end map + map ! M5 + integer(4) long + end map + end union +end structure + +record /s1/ r1 +record /s2/ r2 + +! Basic unions +r1.a = 0 +r1.b = 1.33e7 +if ( r1.a .eq. 0 ) call aborts ("basic union 1") + +! Endian-agnostic runtime check +r2.long = z'12345678' +if (.not. ( (r2.w1 .eq. z'1234' .and. r2.w2 .eq. z'5678') & + .or. (r2.w1 .eq. z'5678' .and. r2.w2 .eq. z'1234')) ) then + call aborts ("basic union 2") +endif + +end diff --git a/gcc/testsuite/gfortran.dg/dec_union_3.f90 b/gcc/testsuite/gfortran.dg/dec_union_3.f90 new file mode 100644 index 00000000000..ce5ae797859 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_union_3.f90 @@ -0,0 +1,35 @@ +! { dg-do run } +! { dg-options "-fdec-structure" } +! +! Test UNIONs with initializations. +! + +subroutine aborts (s) + character(*), intent(in) :: s + print *, s + call abort() +end subroutine + +! Initialization expressions +structure /s3/ + integer(4) :: i = 8 + union ! U7 + map + integer(4) :: x = 1600 + integer(4) :: y = 1800 + end map + map + integer(2) a, b, c + end map + end union +end structure + +record /s3/ r3 + +! Initialized unions +if ( r3.x .ne. 1600 .or. r3.y .ne. 1800) then + r3.x = r3.y ! If r3 isn't used the initializations are optimized out + call aborts ("union initialization") +endif + +end diff --git a/gcc/testsuite/gfortran.dg/dec_union_4.f90 b/gcc/testsuite/gfortran.dg/dec_union_4.f90 new file mode 100644 index 00000000000..3bf6d618a8e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_union_4.f90 @@ -0,0 +1,62 @@ +! { dg-do run } +! { dg-options "-fdec-structure" } +! +! Test nested UNIONs. +! + +subroutine aborts (s) + character(*), intent(in) :: s + print *, s + call abort() +end subroutine + +! Nested unions +structure /s4/ + union ! U0 ! rax + map + integer(8) rx + end map + map + integer(4) rh ! rah + union ! U1 + map + integer(4) rl ! ral + end map + map + integer(4) ex ! eax + end map + map + integer(2) eh ! eah + union ! U2 + map + integer(2) el ! eal + end map + map + integer(2) x ! ax + end map + map + integer(1) h ! ah + integer(1) l ! al + end map + end union + end map + end union + end map + end union +end structure +record /s4/ r4 + + +! Nested unions +r4.rx = z'7A7B7CCC7FFFFFFF' +if ( r4.rx .ne. z'7A7B7CCC7FFFFFFF' ) call aborts ("rax") +if ( r4.rh .ne. z'7FFFFFFF' ) call aborts ("rah") +if ( r4.rl .ne. z'7A7B7CCC' ) call aborts ("ral") +if ( r4.ex .ne. z'7A7B7CCC' ) call aborts ("eax") +if ( r4.eh .ne. z'7CCC' ) call aborts ("eah") +if ( r4.el .ne. z'7A7B' ) call aborts ("eal") +if ( r4.x .ne. z'7A7B' ) call aborts ("ax") +if ( r4.h .ne. z'7B' ) call aborts ("ah") +if ( r4.l .ne. z'7A' ) call aborts ("al") + +end diff --git a/gcc/testsuite/gfortran.dg/dec_union_5.f90 b/gcc/testsuite/gfortran.dg/dec_union_5.f90 new file mode 100644 index 00000000000..bb1611a0289 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_union_5.f90 @@ -0,0 +1,41 @@ +! { dg-do run } +! { dg-options "-fdec-structure" } +! +! Test UNIONs with array components. +! + +subroutine aborts (s) + character(*), intent(in) :: s + print *, s + call abort() +end subroutine + +! Unions with arrays +structure /s5/ + union + map + character :: s(5) + end map + map + integer(1) :: a(5) + end map + end union +end structure + +record /s5/ r5 + +! Unions with arrays +r5.a(1) = z'41' +r5.a(2) = z'42' +r5.a(3) = z'43' +r5.a(4) = z'44' +r5.a(5) = z'45' +if ( r5.s(1) .ne. 'A' & + .or. r5.s(2) .ne. 'B' & + .or. r5.s(3) .ne. 'C' & + .or. r5.s(4) .ne. 'D' & + .or. r5.s(5) .ne. 'E') then + call aborts ("arrays") +endif + +end diff --git a/gcc/testsuite/gfortran.dg/dec_union_6.f90 b/gcc/testsuite/gfortran.dg/dec_union_6.f90 new file mode 100644 index 00000000000..31059c46880 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_union_6.f90 @@ -0,0 +1,59 @@ +! { dg-do run } +! { dg-options "-fdec-structure" } +! +! sub0 and sub1 test a regression where calling gfc_use_derived from +! gfc_find_component on the structure type symbol being parsed caused the +! symbol to be freed and swapped for the previously seen type symbol, leaving +! dangling pointers and causing all sorts of mayhem. +! + +subroutine sub0 (u) + structure /s/ + union ! U0 + map ! M0 + integer i + end map + end union + end structure + record /s/ u + u.i = 0 +end subroutine sub0 + +subroutine sub1 () + structure /s/ + union ! U1 + map ! M1 + integer i + end map + end union + end structure + record /s/ u + interface ! matches the declaration of sub0 above + subroutine sub0 (u) + structure /s/ + union ! U2 + map ! M2 + integer i ! gfc_find_component should not call gfc_use_derived + end map ! here, otherwise this structure's type symbol is freed + end union ! out from under it + end structure + record /s/ u + end subroutine sub0 + end interface + call sub0(u) +end subroutine + +! If sub0 and sub1 aren't used they may be omitted +structure /s/ + union ! U1 + map ! M3 + integer i + end map + end union +end structure +record /s/ u + +call sub0(u) +call sub1() + +end diff --git a/gcc/testsuite/gfortran.dg/dec_union_7.f90 b/gcc/testsuite/gfortran.dg/dec_union_7.f90 new file mode 100644 index 00000000000..270f0fbd415 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_union_7.f90 @@ -0,0 +1,38 @@ +! { dg-do compile } +! { dg-options "-fdec-structure" } +! +! Comprehensive compile tests for what unions CAN'T do. +! + +! Syntax errors +structure /s0/ + union a b c ! { dg-error "Junk after UNION" } + union + map a b c ! { dg-error "Junk after MAP" } + integer x ! { dg-error "Unexpected" } + structure /s2/ ! { dg-error "Unexpected" } + map + map ! { dg-error "Unexpected" } + end map + end union +end structure + +! Initialization expressions +structure /s1/ + union + map + integer(4) :: x = 1600 ! { dg-error "Conflicting initializers" } + integer(4) :: y = 1800 + end map + map + integer(2) a, b, c, d + integer :: e = 0 ! { dg-error "Conflicting initializers" } + end map + map + real :: p = 1.3, q = 3.7 ! { dg-error "Conflicting initializers" } + end map + end union +end structure +record /s1/ r1 + +end diff --git a/gcc/testsuite/gfortran.dg/pr70931.f90 b/gcc/testsuite/gfortran.dg/pr70931.f90 new file mode 100644 index 00000000000..08ecd687752 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr70931.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! { dg-options "-g" } +program p + type t + integer :: a + integer :: b(0) + end type + type(t), parameter :: z = t(1, [2]) + print *, z +end diff --git a/gcc/testsuite/gfortran.dg/pr70937.f90 b/gcc/testsuite/gfortran.dg/pr70937.f90 new file mode 100644 index 00000000000..3fb17bd227e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr70937.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! { dg-options "-flto" } + SUBROUTINE dbcsr_test_read_args(narg, args) + CHARACTER(len=*), DIMENSION(:), & + INTENT(out) :: args + CHARACTER(len=80) :: line + DO + args(narg) = line + ENDDO + END SUBROUTINE dbcsr_test_read_args diff --git a/gcc/testsuite/gfortran.fortran-torture/compile/pr70960.f90 b/gcc/testsuite/gfortran.fortran-torture/compile/pr70960.f90 new file mode 100644 index 00000000000..675fb56ad6c --- /dev/null +++ b/gcc/testsuite/gfortran.fortran-torture/compile/pr70960.f90 @@ -0,0 +1,10 @@ + SUBROUTINE calbrec(a,ai,error) + REAL(KIND=8) :: a(3,3), ai(3,3) + DO i = 1, 3 + il = 1 + IF (i==1) il = 2 + DO j = 1, 3 + ai(j,i) = (-1.0_8)**(i+j)*det*(a(il,jl)*a(iu,ju)-a(il,ju)*a(iu,jl)) + END DO + END DO + END SUBROUTINE calbrec diff --git a/gcc/testsuite/gnat.dg/debug5.adb b/gcc/testsuite/gnat.dg/debug5.adb new file mode 100644 index 00000000000..6569a158029 --- /dev/null +++ b/gcc/testsuite/gnat.dg/debug5.adb @@ -0,0 +1,22 @@ +-- { dg-do compile } +-- { dg-options "-g" } + +procedure Debug5 is + + type Record_Type (L1, L2 : Natural) is record + S1 : String (1 .. L1); + case L2 is + when 0 => null; + when others => S2 : String (L1 .. L2); + end case; + end record; + + procedure Discard (R : Record_Type) is + begin + null; + end Discard; + + R : constant Record_Type := (0, 0, others => <>); +begin + Discard (R); +end Debug5; |