diff options
author | Rong Xu <xur@google.com> | 2014-07-21 16:47:22 -0700 |
---|---|---|
committer | Rong Xu <xur@google.com> | 2014-07-29 15:31:03 -0700 |
commit | 38a8aecfb882072900434499696b5c32a2274515 (patch) | |
tree | 2aac97f0ae24b03cd98c1a06e989c031c173f889 /gcc-4.9/gcc/testsuite/g++.dg | |
parent | c231900e5dcc14d8296bd9f62b45997a49d4d5e7 (diff) | |
download | toolchain_gcc-38a8aecfb882072900434499696b5c32a2274515.tar.gz toolchain_gcc-38a8aecfb882072900434499696b5c32a2274515.tar.bz2 toolchain_gcc-38a8aecfb882072900434499696b5c32a2274515.zip |
[4.9] Switch gcc-4.9 to use google/gcc-4_9 branch.
This source drop uses svn version r212828 of google/gcc-4.9 branch.
We also cherry-picked r213062, r213063 and r213064 to fix windows
build issues.
All gcc-4.9 patches before July 3rd are ported to google/gcc-4.9.
The following prior commits has not been merged to google branch yet.
(They are included in this commit).
e7af147f979e657fe2df00808e5b4319b0e088c6,
baf87df3cb2683649ba7e9872362a7e721117c23, and
c231900e5dcc14d8296bd9f62b45997a49d4d5e7.
Change-Id: I4bea3ea470387ff751c2be4cb0d4a12059b9299b
Diffstat (limited to 'gcc-4.9/gcc/testsuite/g++.dg')
108 files changed, 2959 insertions, 95 deletions
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/constexpr-aggr1.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/constexpr-aggr1.C new file mode 100644 index 000000000..7e4da11a2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/constexpr-aggr1.C @@ -0,0 +1,17 @@ +// PR c++/60951 +// { dg-do compile { target c++11 } } + +struct Foo { + constexpr Foo(int x = 0) : memb(x) {} + int memb; +}; + +struct FooContainer { + Foo foo[2]; +}; + +void fubar() { + int nonConst = 0; + FooContainer fooContainer; + fooContainer = { { 0, nonConst } }; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem2.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem2.C new file mode 100644 index 000000000..86859aa12 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem2.C @@ -0,0 +1,13 @@ +// PR c++/61661 +// { dg-do compile { target c++11 } } + +struct Outer { + + void Bar(); + + struct Foo { + void (Outer::*ptr)() ; + }; + + static constexpr Foo foo = { &Outer::Bar }; +}; diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/constexpr-template7.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/constexpr-template7.C new file mode 100644 index 000000000..e835dbf4d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/constexpr-template7.C @@ -0,0 +1,32 @@ +// PR c++/61556 +// { dg-do compile { target c++11 } } + +class ValueType { +public: + constexpr operator int() const {return m_ID;}; + constexpr ValueType(const int v) + : m_ID(v) {} +private: + int m_ID; +}; + +class ValueTypeEnum { +public: + static constexpr ValueType doubleval = ValueType(1); +}; + +template <int format> +class ValueTypeInfo { +}; + +template <typename Format> +class FillFunctor { +public: + FillFunctor() { + ValueTypeInfo<ValueTypeEnum::doubleval> v; + } +}; + +int main() { + ValueTypeInfo<ValueTypeEnum::doubleval> v; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/defaulted49.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/defaulted49.C new file mode 100644 index 000000000..357be419d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/defaulted49.C @@ -0,0 +1,15 @@ +// PR c++/60980 +// { dg-do compile { target c++11 } } + +struct x0 +{ + x0 () = default; +}; +struct x1 +{ + x0 x2[2]; + void x3 () + { + x1 (); + } +}; diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/initlist84.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/initlist84.C new file mode 100644 index 000000000..4d46746c5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/initlist84.C @@ -0,0 +1,17 @@ +// PR c++/61242 +// { dg-do compile { target c++11 } } + +struct Foo +{ + struct A + { + const int &container; + const int &args; + }; + static void Create (const A &); +}; + +int main () +{ + Foo::Create ({{}, {}}); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/initlist86.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/initlist86.C new file mode 100644 index 000000000..ace2ef928 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/initlist86.C @@ -0,0 +1,18 @@ +// PR c++/61382 +// { dg-do run { target c++11 } } + +struct A +{ + int i,j; + A(int i,int j):i(i),j(j){} +}; + +extern "C" int printf (const char *, ...); + +int main() +{ + int i = 0; + A a{i++,i++}; + if (a.i != 0 || a.j != 1) + __builtin_abort(); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const3.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const3.C new file mode 100644 index 000000000..a1ffaddc4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const3.C @@ -0,0 +1,38 @@ +// PR c++/60992 +// { dg-do compile { target c++11 } } + +struct ScopeGuardGenerator { }; + +struct FF +{ + template < class F, class ... Ts > + void + operator () (F & ...) + { + const int n = sizeof ... (Ts) + 1; + void *mutexes[n]; + auto _on_scope_exit_var_0 = + ScopeGuardGenerator () + [&mutexes] { }; + } +}; + +template < class F > +int operator+ (ScopeGuardGenerator, F) { return 1; } + +struct D +{ + template < class T0, class T1, class T2, class ... T > + void + operator () (T0, T1, const T2 & t2, T & ... t) + { + base (t2, t ...); + } + FF base; +}; + +D run_with_locks; + +void Fn () +{ + run_with_locks ([] { }, 0, 0); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template13.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template13.C new file mode 100644 index 000000000..adbb4dbca --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template13.C @@ -0,0 +1,20 @@ +// PR c++/61566 +// { dg-do compile { target c++11 } } + +struct function +{ + template < typename _Functor> + function (_Functor); +}; + +struct C +{ + template <typename T> + void foo (T, function = [] {}); +}; + +void bar () +{ + C c; + c.foo (1); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this18.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this18.C new file mode 100644 index 000000000..fec2da615 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this18.C @@ -0,0 +1,30 @@ +// PR c++/61151 +// { dg-do compile { target c++11 } } + +struct B +{ + void foo () {} +}; + +template <class> +struct A +{ + template <class> void bar (); + B a; +}; + +template <class T> +template <class U> +void +A<T>::bar () +{ + auto f = [this] () { auto g = [=] () { a.foo (); }; g (); }; + f (); +} + +int +main () +{ + A<int> a; + a.bar <int> (); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/nsdmi-template10.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/nsdmi-template10.C new file mode 100644 index 000000000..4a8c87e6d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/nsdmi-template10.C @@ -0,0 +1,14 @@ +// PR c++/60999 +// { dg-do compile { target c++11 } } + +struct B +{ + template<int N, int M> + struct A; + + template<int M> + struct A<1, M> + { + int X = M; + }; +}; diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/nsdmi-template11.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/nsdmi-template11.C new file mode 100644 index 000000000..60e53c419 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/nsdmi-template11.C @@ -0,0 +1,15 @@ +// PR c++/58930 +// { dg-do compile { target c++11 } } + +struct SampleModule +{ + explicit SampleModule (int); +}; + +template < typename > +struct BaseHandler +{ + SampleModule module_ { 0 }; +}; + +BaseHandler<int> a; diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/nsdmi-template12.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/nsdmi-template12.C new file mode 100644 index 000000000..52ae25720 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/nsdmi-template12.C @@ -0,0 +1,17 @@ +// PR c++/58753 +// { dg-do compile { target c++11 } } + +#include <initializer_list> + +template <class T> +struct X {X(std::initializer_list<int>) {}}; + +template <class zomg> +class T { + X<T> x{1}; +}; + +int main() +{ + T<int> t; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/nsdmi-template13.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/nsdmi-template13.C new file mode 100644 index 000000000..65ccd0aaa --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/nsdmi-template13.C @@ -0,0 +1,11 @@ +// PR c++/58704 +// { dg-do compile { target c++11 } } + +struct A {}; + +template<typename> struct B +{ + A a[1] = { }; +}; + +B<int> b; diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/nsdmi-template9.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/nsdmi-template9.C new file mode 100644 index 000000000..0cfbb9044 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/nsdmi-template9.C @@ -0,0 +1,16 @@ +// PR c++/60999 +// { dg-do compile { target c++11 } } + +template <typename A> +struct foo +{ +}; + +template<> +struct foo<int> +{ + static constexpr int code = 42; + unsigned int bar = static_cast<unsigned int>(code); +}; + +foo<int> a; diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/pr58155.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/pr58155.C new file mode 100644 index 000000000..60b02ab65 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/pr58155.C @@ -0,0 +1,13 @@ +// { dg-do compile { target c++11 } } + +#define BAZ "baz" + +#if 0 + +"bar"BAZ + +R"( + bar +)"BAZ + +#endif diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/pr58781.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/pr58781.C new file mode 100644 index 000000000..58c972f90 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/pr58781.C @@ -0,0 +1,18 @@ +// PR c++/58781 +// { dg-do compile { target c++11 } } + +#include <cstddef> + +int +operator""_s(const char32_t *a, size_t b) +{ + return 0; +} + +int +f() +{ + using a = decltype(U"\x1181"_s); + using b = decltype(U"\x8111"_s); + using c = decltype(U" \x1181"_s); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/pr60249.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/pr60249.C new file mode 100644 index 000000000..e650dcb45 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/pr60249.C @@ -0,0 +1,6 @@ +// PR c++/60249 +// { dg-do compile { target c++11 } } + +decltype(""_) x; // { dg-error "unable to find string literal operator" } + +// { dg-error "invalid type in declaration before" "invalid" { target *-*-* } 4 } diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/ref-qual15.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/ref-qual15.C new file mode 100644 index 000000000..ca333c2e2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/ref-qual15.C @@ -0,0 +1,13 @@ +// PR c++/59296 +// { dg-do compile { target c++11 } } + +struct Type +{ + void get() const& { } + void get() const&& { } +}; + +int main() +{ + Type{}.get(); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/sfinae50.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/sfinae50.C new file mode 100644 index 000000000..e8d90ca76 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/sfinae50.C @@ -0,0 +1,41 @@ +// PR c++/61083 +// { dg-do compile { target c++11 } } + +template<typename T> T declval(); + +template<typename T, typename U> +struct is_same { + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> { + static const bool value = true; +}; + +struct true_type {}; +struct false_type {}; + +template <typename T> +struct is_foo { +private: + template<typename U, U> struct helper {}; + + template <typename Z> static auto + test(Z z) -> decltype(helper<void (Z::*)() const, &Z::foo>(), true_type()); + + template <typename> static auto test(...) -> false_type; + +public: + enum { value = is_same<decltype(test<T>(declval<T>())), true_type>::value }; +}; + +struct A { + int foo(); + void foo() const; +}; + +struct A1 : public A {}; + +static_assert (is_foo<A>::value == 1, ""); +static_assert (is_foo<A1>::value == 0, ""); diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/variadic158.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/variadic158.C new file mode 100644 index 000000000..cc5c24ddc --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/variadic158.C @@ -0,0 +1,24 @@ +// PR c++/61134 +// { dg-do compile { target c++11 } } + +struct Base { }; + +template <typename> +struct Fixed { + typedef const char* name; +}; + +template <typename VT, typename... Fields> +void New(const char* name, + typename Fixed<Fields>::name... field_names); + +template <typename VT, typename... Fields> +void CreateMetric(const char* name, + typename Fixed<Fields>::name... field_names, + const Base&) { } + + +void Fn() +{ + CreateMetric<int, const char*>("abcd", "def", Base()); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/variadic159.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/variadic159.C new file mode 100644 index 000000000..2b14d3005 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/variadic159.C @@ -0,0 +1,14 @@ +// PR c++/61507 +// { dg-do compile { target c++11 } } + +struct A { + void foo(const int &); + void foo(float); +}; + +template <typename... Args> +void bar(void (A::*memfun)(Args...), Args... args); + +void go(const int& i) { + bar<const int &>(&A::foo, i); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/variadic160.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/variadic160.C new file mode 100644 index 000000000..20fcd5b4f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/variadic160.C @@ -0,0 +1,49 @@ +// PR c++/61539 +// { dg-do compile { target c++11 } } + +template <typename _CharT> class A; +template <typename> class B; +template <class charT> class C; +template <> class C<char> +{ + virtual void xparse (int &, const B<A<char> > &) const; +}; +template <class T, class charT = char> class G : C<charT> +{ +public: + G (void *) {} + void default_value (const T &); + void xparse (int &, const B<A<charT> > &) const; +}; +template <class T, class charT> +void validate (int &, const B<A<charT> > &, T *, int); +template <class T, class charT> +void G<T, charT>::xparse (int &p1, const B<A<charT> > &p2) const +{ + validate (p1, p2, (T *)0, 0); +} +template <class T> G<T> *value (T *) { return new G<T>(0); } +namespace Eigen +{ +template <typename T> struct D; +template <typename, int, int, int = 0, int = 0, int = 0 > class F; +template <typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, + int _MaxCols> +struct D<F<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > +{ + typedef _Scalar Scalar; +}; +template <typename, int, int, int, int, int _MaxCols> class F +{ +public: + typedef typename Eigen::D<F>::Scalar Scalar; + F (const Scalar &, const Scalar &, const Scalar &); +}; +template <class... T> +void validate (int &, const B<A<char> > &, Eigen::F<T...> *); +} +int main (int, char *[]) +{ + Eigen::F<double, 3, 1> a (0, 0, 0); + value (&a)->default_value (Eigen::F<double, 3, 1>(0, 0, 0)); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp1y/pr59867.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp1y/pr59867.C new file mode 100644 index 000000000..91d025964 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp1y/pr59867.C @@ -0,0 +1,52 @@ +// PR c++/59867 +// { dg-do compile { target c++1y } } + +#include <iostream> +using namespace std; + +// constant +template<typename T, T x> + struct meta_value + { + typedef meta_value type; + typedef T value_type; + static const T value = x; + }; + +// array +template<typename T, T... data> + struct meta_array + { + typedef meta_array type; + typedef T item_type; + }; + +// static array -> runtime array conversion utility +template<typename T> + struct array_gen; + +template<typename T, T... xs> + struct array_gen<meta_array<T, xs...>> + { + static const T value[sizeof...(xs)]; + }; + +template<typename T, T... xs> + const T + array_gen<meta_array<T, xs...>>::value[sizeof...(xs)] = {xs...}; + +// static string +template<typename T, T... xs> + constexpr meta_array<T, xs...> + operator""_s() + { + static_assert(sizeof...(xs) == 3, "What's wrong with you?"); + return meta_array<T, xs...>(); + } + +int +main() +{ + auto a = "123"_s; + const char (& xs)[3] = array_gen<decltype("123"_s)>::value; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C b/gcc-4.9/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C index e3bddab0e..bfa5d9292 100644 --- a/gcc-4.9/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C +++ b/gcc-4.9/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C @@ -14,4 +14,4 @@ main() K k; } -// { dg-final {scan-assembler-times " DW_AT_\[MIPS_\]*linkage_name" 2 } } +// { dg-final {scan-assembler-times " DW_AT_\[MIPS_\]*linkage_name" 4 } } diff --git a/gcc-4.9/gcc/testsuite/g++.dg/debug/dwarf2/dwarf4-nested.C b/gcc-4.9/gcc/testsuite/g++.dg/debug/dwarf2/dwarf4-nested.C new file mode 100644 index 000000000..160694c3c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/debug/dwarf2/dwarf4-nested.C @@ -0,0 +1,55 @@ +// { dg-do compile } +// { dg-options "--std=c++11 -dA -gdwarf-4 -fdebug-types-section -fno-merge-debug-strings" } + +// Check that -fdebug-types-sections does not copy a full referenced type +// into a type unit. + +// Checks that at least one type unit is generated. +// +// { dg-final { scan-assembler "DIE \\(\[^\n\]*\\) DW_TAG_type_unit" } } +// +// Check that func is declared exactly once in the debug info (in the +// compile unit). +// +// { dg-final { scan-assembler-times "\\.ascii \"func\\\\0\"\[^\n\]*DW_AT_name" 1 } } +// +// Check to make sure that no type unit contains a DIE with DW_AT_low_pc +// or DW_AT_ranges. These patterns assume that the compile unit is always +// emitted after all type units. +// +// { dg-final { scan-assembler-not "\\.quad\[^\n\]*DW_AT_low_pc.*DIE \\(\[^\n\]*\\) DW_TAG_compile_unit" } } +// { dg-final { scan-assembler-not "\\.quad\[^\n\]*DW_AT_ranges.*DIE \\(\[^\n\]*\\) DW_TAG_compile_unit" } } + +struct A { + A(); + virtual ~A(); + virtual void foo(); + private: + int data; +}; + +struct B { + B(); + virtual ~B(); +}; + +extern B* table[]; + +struct D { + template <typename T> + T* get(int i) + { + B*& cell = table[i]; + if (cell == 0) + cell = new T(); + return static_cast<T*>(cell); + } +}; + +void func(D* d) +{ + struct C : B { + A a; + }; + d->get<C>(0)->a.foo(); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/debug/dwarf2/dwarf4-typedef.C b/gcc-4.9/gcc/testsuite/g++.dg/debug/dwarf2/dwarf4-typedef.C index c5520fa72..89a6bb44e 100644 --- a/gcc-4.9/gcc/testsuite/g++.dg/debug/dwarf2/dwarf4-typedef.C +++ b/gcc-4.9/gcc/testsuite/g++.dg/debug/dwarf2/dwarf4-typedef.C @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-gdwarf-4" } */ +/* { dg-options "-gdwarf-4 -fdebug-types-section" } */ /* Regression test for an ICE in output_die when using -gdwarf-4. */ diff --git a/gcc-4.9/gcc/testsuite/g++.dg/debug/dwarf2/imported-decl-2.C b/gcc-4.9/gcc/testsuite/g++.dg/debug/dwarf2/imported-decl-2.C new file mode 100644 index 000000000..ce01f7238 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/debug/dwarf2/imported-decl-2.C @@ -0,0 +1,32 @@ +// { dg-do compile } +// { dg-options "-gdwarf-2 -dA -O0 -fno-merge-debug-strings" } + +class AAAA +{ + public: + int method (void); + int a; +}; + +int +AAAA::method (void) +{ + return a; +} + +class BBBB : public AAAA +{ + public: + using AAAA::method; + + int method (int b); +}; + +int +BBBB::method (int b) +{ + return a + b; +} + +// { dg-final { scan-assembler-not "ascii \"BBBB\\\\0\".*ascii \"AAAA\\\\0\".*DW_TAG_imported_declaration" } } +// { dg-final { scan-assembler-times "ascii \"AAAA\\\\0\".*ascii \"BBBB\\\\0\".*DIE .0x\[0-9a-f\]*. DW_TAG_imported_declaration" 1 } } diff --git a/gcc-4.9/gcc/testsuite/g++.dg/debug/dwarf2/pr61433.C b/gcc-4.9/gcc/testsuite/g++.dg/debug/dwarf2/pr61433.C new file mode 100644 index 000000000..a63b8a9ef --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/debug/dwarf2/pr61433.C @@ -0,0 +1,23 @@ +// PR c++/61433 +// { dg-do compile { target c++11 } } +// { dg-options "-O -fcompare-debug -fno-inline -fno-ipa-pure-const -fipa-sra" } + +template <class T> +struct A +{ + template <class V> + struct B + { + int MEM; + }; +}; +struct D {}; +struct C: public A<int>::B<D> +{}; +template <class T, class U, class V> +auto k(T t, U u, V v) -> decltype (t.U::template B<V>::MEM) +{} +int main() +{ + k( C(), A<int>(), D() ); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/eh/spec3-static.C b/gcc-4.9/gcc/testsuite/g++.dg/eh/spec3-static.C deleted file mode 100644 index 15408effa..000000000 --- a/gcc-4.9/gcc/testsuite/g++.dg/eh/spec3-static.C +++ /dev/null @@ -1,25 +0,0 @@ -// PR c++/4381 -// Test that exception-specs work properly for classes with virtual bases. - -// { dg-do run } -// { dg-options "-static" } - -class Base {}; - -struct A : virtual public Base -{ - A() {} -}; - -struct B {}; - -void func() throw (B,A) -{ - throw A(); -} - -int main(void) -{ - try { func(); } - catch (A& a) { } -} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/ext/complit14.C b/gcc-4.9/gcc/testsuite/g++.dg/ext/complit14.C new file mode 100644 index 000000000..aed765dc5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/ext/complit14.C @@ -0,0 +1,11 @@ +// PR c++/61614 +// { dg-options "" } + +int Fn (...); + +void +Test () +{ + int j = Fn ((const int[]) { 0 }); // OK + unsigned long sz = sizeof Fn ((const int[]) { 0 }); // Error +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/gcov/gcov-7.C b/gcc-4.9/gcc/testsuite/g++.dg/gcov/gcov-7.C deleted file mode 100644 index db3e95a07..000000000 --- a/gcc-4.9/gcc/testsuite/g++.dg/gcov/gcov-7.C +++ /dev/null @@ -1,28 +0,0 @@ -/* Check that Exception handler specification is not - mapped to the curly braces below the function - declaration. */ - -/* { dg-options "-fprofile-arcs -ftest-coverage" } */ -/* { dg-do run { target native } } */ - -struct foo -{ - foo () throw (int) - { /* count (-) */ - throw (1); - } -}; - -int main () -{ - try - { - foo f; - } - catch ( ...) - { - return 0; - } -} - -/* { dg-final { run-gcov gcov-7.C } } */ diff --git a/gcc-4.9/gcc/testsuite/g++.dg/guality/guality.exp b/gcc-4.9/gcc/testsuite/g++.dg/guality/guality.exp index 3ff7f2f77..215f6f80f 100644 --- a/gcc-4.9/gcc/testsuite/g++.dg/guality/guality.exp +++ b/gcc-4.9/gcc/testsuite/g++.dg/guality/guality.exp @@ -1,5 +1,8 @@ # This harness is for tests that should be run at all optimisation levels. +# Disable everywhere. These tests are very flaky. +return + load_lib g++-dg.exp load_lib gcc-gdb-test.exp diff --git a/gcc-4.9/gcc/testsuite/g++.dg/init/copy7.C b/gcc-4.9/gcc/testsuite/g++.dg/init/copy7.C new file mode 100644 index 000000000..655fae21e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/init/copy7.C @@ -0,0 +1,9 @@ +// CWG 5 + +struct C { }; +C c; +struct A { + A(const A&); + A(const C&); +}; +const volatile A a = c; // Okay diff --git a/gcc-4.9/gcc/testsuite/g++.dg/ipa/devirt-11.C b/gcc-4.9/gcc/testsuite/g++.dg/ipa/devirt-11.C index ca8ea4cc2..e31832b87 100644 --- a/gcc-4.9/gcc/testsuite/g++.dg/ipa/devirt-11.C +++ b/gcc-4.9/gcc/testsuite/g++.dg/ipa/devirt-11.C @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-ipa-inline -fno-devirtualize-speculatively" } */ +/* { dg-options "-O2 -fdump-ipa-inline --param=early-inlining-insns-comdat=0 -fno-devirtualize-speculatively" } */ int baz (); struct A { @@ -45,5 +45,5 @@ bar () /* While inlining function called once we should devirtualize a new call to fn2 and two to fn3. While doing so the new symbol for fn2 needs to be introduced. */ -/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target" 1 "inline" } } */ +/* { dg-final { scan-ipa-dump "Discovered a virtual call to a known target" "inline" } } */ /* { dg-final { cleanup-ipa-dump "inline" } } */ diff --git a/gcc-4.9/gcc/testsuite/g++.dg/ipa/devirt-25.C b/gcc-4.9/gcc/testsuite/g++.dg/ipa/devirt-25.C index 751647957..1da44f5d1 100644 --- a/gcc-4.9/gcc/testsuite/g++.dg/ipa/devirt-25.C +++ b/gcc-4.9/gcc/testsuite/g++.dg/ipa/devirt-25.C @@ -22,5 +22,5 @@ void dpr_run(ebs_Object& objectA) { dpr_Job jobL; dpr_run(jobL); } -/* { dg-final { scan-ipa-dump "Type inconsident devirtualization" "cp" } } */ +/* { dg-final { scan-ipa-dump "Type inconsistent devirtualization" "cp" } } */ /* { dg-final { cleanup-ipa-dump "cp" } } */ diff --git a/gcc-4.9/gcc/testsuite/g++.dg/ipa/devirt-31.C b/gcc-4.9/gcc/testsuite/g++.dg/ipa/devirt-31.C new file mode 100644 index 000000000..64c44ba1e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/ipa/devirt-31.C @@ -0,0 +1,23 @@ +/* { dg-options "-O2 -std=c++11 -fdump-ipa-inline" } */ +#include <new> + +class EmbeddedObject { +public: + virtual int val() { return 2; } +}; + +class Container { + alignas(EmbeddedObject) char buffer[sizeof(EmbeddedObject)]; +public: + EmbeddedObject *obj() { return (EmbeddedObject*)buffer; } + Container() { new (buffer) EmbeddedObject(); } +}; + +Container o; + +int main() +{ + __builtin_printf("%d\n", o.obj()->val()); +} +/* { dg-final { scan-ipa-dump-not "__builtin_unreachable" "inline" } } */ +/* { dg-final { cleanup-ipa-dump "inline" } } */ diff --git a/gcc-4.9/gcc/testsuite/g++.dg/ipa/devirt-9.C b/gcc-4.9/gcc/testsuite/g++.dg/ipa/devirt-9.C index 7fd0bf5f5..dc6c6c940 100644 --- a/gcc-4.9/gcc/testsuite/g++.dg/ipa/devirt-9.C +++ b/gcc-4.9/gcc/testsuite/g++.dg/ipa/devirt-9.C @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-ipa-whole-program" } */ +/* { dg-options "-O2 -fdump-ipa-whole-program --param=early-inlining-insns-comdat=0" } */ double foo (); struct B { diff --git a/gcc-4.9/gcc/testsuite/g++.dg/ipa/pr60600.C b/gcc-4.9/gcc/testsuite/g++.dg/ipa/pr60600.C index 00c368e63..b9039cb85 100644 --- a/gcc-4.9/gcc/testsuite/g++.dg/ipa/pr60600.C +++ b/gcc-4.9/gcc/testsuite/g++.dg/ipa/pr60600.C @@ -14,7 +14,7 @@ struct intermediate: top { }; struct child1: top { - void childf() + __attribute__((noinline)) void childf() { data d(topf()); } @@ -30,5 +30,5 @@ void test(top& t) test(d); } -/* { dg-final { scan-ipa-dump "Type inconsident devirtualization" "cp" } } */ +/* { dg-final { scan-ipa-dump "Type inconsistent devirtualization" "cp" } } */ /* { dg-final { cleanup-ipa-dump "cp" } } */ diff --git a/gcc-4.9/gcc/testsuite/g++.dg/ipa/pr61085.C b/gcc-4.9/gcc/testsuite/g++.dg/ipa/pr61085.C new file mode 100644 index 000000000..531f59d53 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/ipa/pr61085.C @@ -0,0 +1,33 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-early-inlining" } */ + +struct A {}; +struct B : virtual A { + unsigned m_i; + B() : m_i () {} + virtual A *m_virt () + { + return 0; + } + ~B () + { + m_foo (); + while (m_i) + ; + } + void m_foo () + { + m_virt (); + } +}; + +class C : B { + A *m_virt () { + __builtin_abort (); + } +}; + +int main () +{ + C c; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/ipa/pr61160-1.C b/gcc-4.9/gcc/testsuite/g++.dg/ipa/pr61160-1.C new file mode 100644 index 000000000..a0fbb5f42 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/ipa/pr61160-1.C @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +struct CBase { + virtual void BaseFunc () {} +}; + +struct MMixin { + virtual void * MixinFunc (int, void *) = 0; +}; + +struct CExample: CBase, public MMixin +{ + void *MixinFunc (int arg, void *arg2) + { + if (arg != 1 || arg2) + return 0; + return this; + } +}; + +void *test (MMixin & anExample) +{ + return anExample.MixinFunc (1, 0); +} + +int main () +{ + CExample c; + return (test (c) != &c); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/ipa/pr61160-2.C b/gcc-4.9/gcc/testsuite/g++.dg/ipa/pr61160-2.C new file mode 100644 index 000000000..1011bd1ef --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/ipa/pr61160-2.C @@ -0,0 +1,43 @@ +/* { dg-do run } */ +/* { dg-options "-O3 --param ipa-cp-eval-threshold=1" } */ + +extern "C" void abort (void); + +struct CBase { + virtual void BaseFunc () {} +}; + +struct MMixin { + virtual void * MixinFunc (int, void *) = 0; +}; + +struct CExample: CBase, public MMixin +{ + int stuff, magic, more_stuff; + + CExample () + { + stuff = 0; + magic = 0xbeef; + more_stuff = 0; + } + void *MixinFunc (int arg, void *arg2) + { + if (arg != 1 || arg2) + return 0; + if (magic != 0xbeef) + abort(); + return this; + } +}; + +void *test (MMixin & anExample) +{ + return anExample.MixinFunc (1, 0); +} + +int main () +{ + CExample c; + return (test (c) != &c); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/ipa/pr61160-3.C b/gcc-4.9/gcc/testsuite/g++.dg/ipa/pr61160-3.C new file mode 100644 index 000000000..8184ec2cd --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/ipa/pr61160-3.C @@ -0,0 +1,37 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +struct A { + void *p; + A (void *q) : p (q) {} + A (const A &) : p () {} +}; + +struct CBase { + virtual void BaseFunc () {} +}; + +struct MMixin { + virtual A MixinFunc (int, A) = 0; +}; + +struct CExample: CBase, public MMixin +{ + A MixinFunc (int arg, A arg2) + { + if (arg != 1 || arg2.p) + return 0; + return this; + } +}; + +void *test (MMixin & anExample) +{ + return anExample.MixinFunc (1, (0)).p; +} + +int main () +{ + CExample c; + return (test (c) != &c); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/ipa/pr61540.C b/gcc-4.9/gcc/testsuite/g++.dg/ipa/pr61540.C new file mode 100644 index 000000000..e7dee7262 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/ipa/pr61540.C @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-early-inlining" } */ + +struct data { + data(int) {} +}; + +struct top { + virtual int topf() {} +}; + +struct intermediate: top { + int topf() /* override */ { return 0; } +}; + +struct child1: top { + void childf() + { + data d(topf()); + } +}; + +struct child2: intermediate {}; + +void test(top& t) +{ + child1& c = static_cast<child1&>(t); + c.childf(); + child2 d; + test(d); +} + +int main (int argc, char **argv) +{ + child1 c; + test (c); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/opt/pr60849.C b/gcc-4.9/gcc/testsuite/g++.dg/opt/pr60849.C new file mode 100644 index 000000000..52d8826b0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/opt/pr60849.C @@ -0,0 +1,13 @@ +// { dg-do compile } +// { dg-options "-O2" } + +int g; + +extern "C" int isnan (); + +void foo(float a) { + int (*xx)(...); + xx = isnan; + if (xx(a)) + g++; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/opt/pr60912.C b/gcc-4.9/gcc/testsuite/g++.dg/opt/pr60912.C new file mode 100644 index 000000000..ad51ba725 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/opt/pr60912.C @@ -0,0 +1,18 @@ +// { dg-do run } +// { dg-options "-O -fno-inline -fipa-pta" } + +struct IFoo +{ + virtual void Foo () = 0; +}; + +struct Bar:IFoo +{ + void Foo () {} +}; + +int main () +{ + (new Bar ())->Foo (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/opt/pr61456.C b/gcc-4.9/gcc/testsuite/g++.dg/opt/pr61456.C new file mode 100644 index 000000000..14a118b57 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/opt/pr61456.C @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-O2 -std=c++11 -Werror=uninitialized" } + +int rand (); + +class Funcs +{ +public: + int *f1 (); + int *f2 (); +}; +typedef decltype (&Funcs::f1) pfunc; + +static int Set (Funcs * f, const pfunc & fp) +{ + (f->*fp) (); +} + +void +Foo () +{ + pfunc fp = &Funcs::f1; + if (rand ()) + fp = &Funcs::f2; + Set (0, fp); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/opt/pr61654.C b/gcc-4.9/gcc/testsuite/g++.dg/opt/pr61654.C new file mode 100644 index 000000000..78dc0c14c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/opt/pr61654.C @@ -0,0 +1,27 @@ +// PR middle-end/61654 +// { dg-do compile } + +class A +{ + virtual int a (int, int = 0) = 0; + int b (const int &); + int c; +}; + +class B : virtual A +{ + int d; + int a (int, int); +}; + +int +A::b (const int &) +{ + return a ('\0'); +} + +int +B::a (int, int) +{ + return 0 ? 0 : d; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/opt/typeinfo1.C b/gcc-4.9/gcc/testsuite/g++.dg/opt/typeinfo1.C new file mode 100644 index 000000000..efac4cbd1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/opt/typeinfo1.C @@ -0,0 +1,27 @@ +// PR c++/61020 +// { dg-options "-O2" } +// { dg-do run } + +#include <typeinfo> + +struct Base { + virtual ~Base() { } +}; + +struct Derived : public Base { +}; + +int compare(const Base& base) +{ + return typeid(base) == typeid(typeid(Derived)); +} + +int main() +{ + Base base; + Derived derived; + + if (compare(base)) return 1; + if (compare(derived)) return 2; + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/other/no-strict-enum-precision-1.C b/gcc-4.9/gcc/testsuite/g++.dg/other/no-strict-enum-precision-1.C new file mode 100644 index 000000000..2115627ef --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/other/no-strict-enum-precision-1.C @@ -0,0 +1,35 @@ +/* { dg-do run } */ +/* { dg-options "-fno-strict-enums" } */ + +extern "C" void abort (void); + +enum zero_one +{ zero = 0, one = 1 }; + +int * +allocate_bool (zero_one e) +{ + int *v = 0; + switch (e) + { + case zero: + v = new int (0); + case one: + v = new int (1); + } + return v; +} + +int +main () +{ + if (allocate_bool (static_cast < zero_one > (999))) + { + /* Error: should not have matched any case label. */ + abort (); + } + else + { + return 0; + } +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/other/no-strict-enum-precision-2.C b/gcc-4.9/gcc/testsuite/g++.dg/other/no-strict-enum-precision-2.C new file mode 100644 index 000000000..086989c51 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/other/no-strict-enum-precision-2.C @@ -0,0 +1,37 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-strict-enums" } */ + +extern "C" void abort (void); + +enum X +{ + X1, + X2 +}; + +int +foo (enum X x) +{ + switch (x) + { + case X1: + return 0; + case X2: + return 1; + } + return x; +} + +int +main (int argc, char *argv[]) +{ + int n = argc + 999; + if (n == foo (static_cast < X > (n))) + { + return 0; + } + else + { + abort (); + } +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/other/no-strict-enum-precision-3.C b/gcc-4.9/gcc/testsuite/g++.dg/other/no-strict-enum-precision-3.C new file mode 100755 index 000000000..673601a41 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/other/no-strict-enum-precision-3.C @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-strict-enums" } */ + +extern "C" void abort (void); + +enum X +{ + X1, + X2 +}; + +int +main (int argc, char *argv[]) +{ + X x = static_cast < X > (argc + 999); + if (x == X1) + abort (); + if (x == X2) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/other/sized-delete-1.C b/gcc-4.9/gcc/testsuite/g++.dg/other/sized-delete-1.C new file mode 100644 index 000000000..76f861af3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/other/sized-delete-1.C @@ -0,0 +1,14 @@ +// { dg-do link} +// { dg-options "-O -fsized-delete" } +// { dg-final { scan-assembler "_ZdlPv\[mj\]" } } +struct A +{ + int a[100]; +}; + +int main(void) +{ + A *a = new A; + delete a; + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/plugin/selfassign.c b/gcc-4.9/gcc/testsuite/g++.dg/plugin/selfassign.c index 041f25dce..9a0c620dd 100644 --- a/gcc-4.9/gcc/testsuite/g++.dg/plugin/selfassign.c +++ b/gcc-4.9/gcc/testsuite/g++.dg/plugin/selfassign.c @@ -211,7 +211,7 @@ compare_and_warn (gimple stmt, tree lhs, tree rhs) /* Check and warn if STMT is a self-assign statement. */ static void -warn_self_assign (gimple stmt) +check_self_assign (gimple stmt) { tree rhs, lhs; @@ -264,7 +264,7 @@ execute_warn_self_assign (void) FOR_EACH_BB_FN (bb, cfun) { for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) - warn_self_assign (gsi_stmt (gsi)); + check_self_assign (gsi_stmt (gsi)); } return 0; diff --git a/gcc-4.9/gcc/testsuite/g++.dg/pr60969.C b/gcc-4.9/gcc/testsuite/g++.dg/pr60969.C new file mode 100644 index 000000000..4012e2ce7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/pr60969.C @@ -0,0 +1,32 @@ +/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-options "-O2 -ftree-vectorize -march=pentium4 -mfpmath=387" } */ + +struct A +{ + float f, g, h, k; + A () {} + A (float v0, float x, float y) : f(v0), g(x), h(y), k(0.0f) {} + A bar (A &a, float t) { return A (f + a.f * t, g + a.g * t, h + a.h * t); } +}; + +A +baz (A &x, A &y, float t) +{ + return x.bar (y, t); +} + +A * +foo (A &s, A &t, A &u, A &v, int y, int z) +{ + A *x = new A[y * z]; + for (int i = 0; i < 7; i++) + { + A s = baz (s, u, i / (float) z); + A t = baz (t, v, i / (float) z); + for (int j = 0; j < 7; j++) + x[i * y + j] = baz (s, t, j / (float) y); + } + return x; +} + +/* { dg-final { scan-assembler-not "%mm" } } */ diff --git a/gcc-4.9/gcc/testsuite/g++.dg/pr61094.C b/gcc-4.9/gcc/testsuite/g++.dg/pr61094.C new file mode 100644 index 000000000..35adc256c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/pr61094.C @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +template <typename> struct A { + unsigned _width, _height, _depth, _spectrum; + template <typename t> A(t p1) { + int a = p1.size(); + if (a) { + _width = p1._width; + _depth = _height = _spectrum = p1._spectrum; + } + } + long size() { return (long)_width * _height * _depth * _spectrum; } +}; + +int d; +void fn1(void *); +A<int> *fn2(); +void fn3() { + int b; + for (;;) { + A<char> c(*fn2()); + fn1(&c); + if (d || !b) + throw; + } +} + + + + diff --git a/gcc-4.9/gcc/testsuite/g++.dg/pr61289-2.c b/gcc-4.9/gcc/testsuite/g++.dg/pr61289-2.c new file mode 100644 index 000000000..4cc3ebe46 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/pr61289-2.c @@ -0,0 +1,62 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-exceptions" } */ +struct S +{ + inline int fn1 () const { return s; } + __attribute__ ((noinline, noclone)) S *fn2 (int); + __attribute__ ((noinline, noclone)) void fn3 (); + __attribute__ ((noinline, noclone)) static S *fn4 (int); + S (int i) : s (i) {} + int s; +}; + +int a = 0; +S *b = 0; + +S * +S::fn2 (int i) +{ + a++; + if (a == 1) + return b; + if (a > 3) + __builtin_abort (); + b = this; + return new S (i + s); +} + +S * +S::fn4 (int i) +{ + b = new S (i); + return b; +} + +void +S::fn3 () +{ + delete this; +} + +void +foo () +{ + S *c = S::fn4 (20); + for (int i = 0; i < 2;) + { + S *d = c->fn2 (c->fn1 () + 10); + if (c != d) +{ + c->fn3 (); + c = d; + ++i; +} + } + c->fn3 (); +} + +int +main () +{ + foo (); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/pr61289.C b/gcc-4.9/gcc/testsuite/g++.dg/pr61289.C new file mode 100644 index 000000000..ea7ccea30 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/pr61289.C @@ -0,0 +1,63 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-exceptions" } */ + +struct S +{ + inline int fn1 () const { return s; } + __attribute__ ((noinline, noclone)) S *fn2 (int); + __attribute__ ((noinline, noclone)) void fn3 (); + __attribute__ ((noinline, noclone)) static S *fn4 (int); + S (int i) : s (i) {} + int s; +}; + +int a = 0; +S *b = 0; + +S * +S::fn2 (int i) +{ + a++; + if (a == 1) + return b; + if (a > 3) + __builtin_abort (); + b = this; + return new S (i + s); +} + +S * +S::fn4 (int i) +{ + b = new S (i); + return b; +} + +void +S::fn3 () +{ + delete this; +} + +void +foo () +{ + S *c = S::fn4 (20); + for (int i = 0; i < 2;) + { + S *d = c->fn2 (c->fn1 () + 10); + if (d != c) +{ + c->fn3 (); + c = d; + ++i; +} + } + c->fn3 (); +} + +int +main () +{ + foo (); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/rtti/repo1.C b/gcc-4.9/gcc/testsuite/g++.dg/rtti/repo1.C index f72a9730a..16dd3028e 100644 --- a/gcc-4.9/gcc/testsuite/g++.dg/rtti/repo1.C +++ b/gcc-4.9/gcc/testsuite/g++.dg/rtti/repo1.C @@ -2,6 +2,7 @@ // { dg-options "-frepo" } // { dg-require-host-local "" } // { dg-skip-if "dkms are not final links" { vxworks_kernel } } +// { dg-skip-if "-frepo not supported with --sysroot (as it is not passed to COLLECT_GCC_OPTIONS" { *-*-linux* } { "*" } { "" } } #include <typeinfo> template<int> diff --git a/gcc-4.9/gcc/testsuite/g++.dg/template/conv14.C b/gcc-4.9/gcc/testsuite/g++.dg/template/conv14.C new file mode 100644 index 000000000..509ae6a65 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/template/conv14.C @@ -0,0 +1,30 @@ +// PR c++/61647 + +class XX; + +template<typename Container, typename Key> +struct Accessor; + +template<typename Container, typename Key, typename KeyStore = Key> +class Variant { +protected: + KeyStore index; + Container state; +public: + Variant(Container st, const Key& i) : index(i), state(st) {} + + template<typename T> + operator T() const { + return Accessor<Container, KeyStore>::template get<T>(state, index); + } +}; + +class AutoCleanVariant : public Variant<XX*, int> { +public: + AutoCleanVariant(XX* st, int i) : Variant<XX*,int>(st,i) {} + + template<typename T> + operator T() const { + return Variant<XX*, int>::operator T(); + } +}; diff --git a/gcc-4.9/gcc/testsuite/g++.dg/template/local-fn1.C b/gcc-4.9/gcc/testsuite/g++.dg/template/local-fn1.C new file mode 100644 index 000000000..88acd17d7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/template/local-fn1.C @@ -0,0 +1,8 @@ +// PR c++/60605 + +template <typename T = int> +struct Foo { + void bar() { + void bug(); + } +}; diff --git a/gcc-4.9/gcc/testsuite/g++.dg/template/pr61537.C b/gcc-4.9/gcc/testsuite/g++.dg/template/pr61537.C new file mode 100644 index 000000000..12aaf58ef --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/template/pr61537.C @@ -0,0 +1,23 @@ +// PR c++/61537 +// { dg-do compile } + +struct A {}; + +template <typename T> +struct B +{ + template <typename U> + void f(U, struct A); +}; + +template <typename T> +template <typename U> +void B<T>::f(U, struct A) +{ +} + +int main() +{ + B<char> b; + b.f(42, A()); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/template/ptrmem27.C b/gcc-4.9/gcc/testsuite/g++.dg/template/ptrmem27.C new file mode 100644 index 000000000..8c63f9c29 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/template/ptrmem27.C @@ -0,0 +1,22 @@ +// PR c++/61500 + +struct X { + int i; + int j; + + int foo(int X::* ptr); + + template <int X::* ptr> + int bar(); +}; + +int X::foo(int X::* ptr) { + int* p = &(this->*ptr); // OK. + return *p; +} + +template <int X::* ptr> +int X::bar() { + int* p = &(this->*ptr); // gcc 4.9.0: OK in C++98 mode, fails in C++11 mode. + return *p; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/template/ptrmem28.C b/gcc-4.9/gcc/testsuite/g++.dg/template/ptrmem28.C new file mode 100644 index 000000000..037996087 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/template/ptrmem28.C @@ -0,0 +1,10 @@ +// PR c++/61488 + +struct A { + typedef int (A::*cont_func)(); + template <A::cont_func> void wait(int); + int notify(); + + void fix() { wait<&A::notify>(0); } // OK + template <int> void repair() { wait<&A::notify>(0); } +}; diff --git a/gcc-4.9/gcc/testsuite/g++.dg/thunk_section_name.C b/gcc-4.9/gcc/testsuite/g++.dg/thunk_section_name.C new file mode 100644 index 000000000..12c25c991 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/thunk_section_name.C @@ -0,0 +1,30 @@ +/* { dg-require-named-sections "" } */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-reorder-blocks-and-partition -ffunction-sections" } */ + +class base_class_1 +{ +public: + virtual void vfn () {} +}; + +class base_class_2 +{ +public: + virtual void vfn () {} +}; + +class need_thunk_class : public base_class_1, public base_class_2 +{ +public: + virtual void vfn () {} +}; + +int main (int argc, char *argv[]) +{ + base_class_1 *c = new need_thunk_class (); + c->vfn(); + return 0; +} + +/* { dg-final { scan-assembler "\.text\._ZThn\[4|8\]_N16need_thunk_class3vfnEv" } } */ diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tls/thread_local9.C b/gcc-4.9/gcc/testsuite/g++.dg/tls/thread_local9.C new file mode 100644 index 000000000..c75528a02 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tls/thread_local9.C @@ -0,0 +1,23 @@ +// PR c++/61343 + +// { dg-do run { target c++11 } } +// { dg-add-options tls } +// { dg-require-effective-target tls_runtime } + +struct Foo { + int value; + + Foo() noexcept { + value = 12; + } +}; + +static thread_local Foo a{}; + +static __attribute__((noinline)) void UseA() { + if (a.value != 12) __builtin_abort(); +} + +int main() { + UseA(); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/torture/pr60854.C b/gcc-4.9/gcc/testsuite/g++.dg/torture/pr60854.C new file mode 100644 index 000000000..fa4b2e71a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/torture/pr60854.C @@ -0,0 +1,13 @@ +template <typename T> +class MyClass +{ +public: + __attribute__ ((__always_inline__)) inline MyClass () { ; } +}; + +extern template class MyClass<double>; + +void Func() +{ + MyClass<double> x; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/torture/pr60895.C b/gcc-4.9/gcc/testsuite/g++.dg/torture/pr60895.C new file mode 100644 index 000000000..0edd36ada --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/torture/pr60895.C @@ -0,0 +1,32 @@ +// { dg-do compile } + +struct C +{ + double elems[3]; +}; + +C +foo () +{ + C a; + double *f = a.elems; + int b; + for (; b;) + { + *f = 0; + ++f; + } + return a; +} + +struct J +{ + C c; + __attribute__((always_inline)) J () : c (foo ()) {} +}; + +void +bar () +{ + J (); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_1.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_1.C new file mode 100644 index 000000000..c58f3ca94 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_1.C @@ -0,0 +1,45 @@ +/* Verify if call-graph profile sections are created with -freorder-functions=. + Check of edge profiles and node profiles are present in the profile + sections. Check if the segment splitting API is invoked. */ +/* { dg-require-section-exclude "" } */ +/* { dg-require-linker-function-reordering-plugin "" } */ +/* { dg-options "-O2 -freorder-functions=callgraph -ffunction-sections --save-temps -Wl,-plugin-opt,file=linker.dump -Wl,-plugin-opt,split_segment=yes" } */ + +int +notcalled () +{ + return 0; +} + +int __attribute__ ((noinline)) +foo () +{ + return 1; +} + +int __attribute__ ((noinline)) +bar () +{ + return 0; +} + +int main () +{ + int sum; + for (int i = 0; i< 1000; i++) + { + sum = foo () + bar(); + } + return sum * bar (); +} + +/* { dg-final-use { scan-assembler "\.gnu\.callgraph\.text\.main" } } */ +/* { dg-final-use { scan-assembler "\.string \"1000\"" } } */ +/* { dg-final-use { scan-assembler "\.string \"Weight 1000 1000\"" } } */ +/* { dg-final-use { scan-assembler "\.string \"Weight 1001 1001\"" } } */ +/* Check if main is next to foo or bar */ +/* { dg-final-use { scan-file linker.dump "Callgraph group : *\(_Z3foov main|main _Z3foov|_Z3barv main|main _Z3barv\).*\n" } } */ +/* { dg-final-use { scan-file linker.dump ".text\..*\._Z9notcalledv entry count = 0 computed = 0 max count = 0" } } */ +/* { dg-final-use { scan-file linker.dump "Moving .* section\\(s\\) to new segment" } } */ +/* { dg-final-use { cleanup-saved-temps } } */ +/* { dg-final-use { remove-build-file "linker.dump" } } */ diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_2.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_2.C new file mode 100644 index 000000000..5e238d8e2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_2.C @@ -0,0 +1,25 @@ +/* Check if the edge_cutoffa option to the function reordering plugin works as + expected. */ +/* { dg-require-section-exclude "" } */ +/* { dg-require-linker-function-reordering-plugin "" } */ +/* { dg-options "-O2 -freorder-functions=callgraph -ffunction-sections -Wl,-plugin-opt,file=linker.dump -Wl,-plugin-opt,edge_cutoff=a1000" } */ + +int __attribute__ ((noinline)) +foo () +{ + return 1; +} + +int main () +{ + int sum = 0; + for (int i = 0; i< 1000; i++) + { + sum += foo (); + } + return sum - 1000; +} + +/* { dg-final-use { scan-file linker.dump "Not considering edge with weight 1000 and below" } } */ +/* { dg-final-use { scan-file-not linker.dump "Callgraph group" } } */ +/* { dg-final-use { remove-build-file "linker.dump" } } */ diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_3.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_3.C new file mode 100644 index 000000000..f316701c8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_3.C @@ -0,0 +1,25 @@ +/* Check if the edge_cutoffp option to the function reordering plugin works as + expected. */ +/* { dg-require-section-exclude "" } */ +/* { dg-require-linker-function-reordering-plugin "" } */ +/* { dg-options "-O2 -freorder-functions=callgraph -ffunction-sections -Wl,-plugin-opt,file=linker.dump -Wl,-plugin-opt,edge_cutoff=p100" } */ + +int __attribute__ ((noinline)) +foo () +{ + return 1; +} + +int main () +{ + int sum = 0; + for (int i = 0; i< 1000; i++) + { + sum += foo (); + } + return sum - 1000; +} + +/* { dg-final-use { scan-file linker.dump "Not considering edge with weight 1000 and below" } } */ +/* { dg-final-use { scan-file-not linker.dump "Callgraph group" } } */ +/* { dg-final-use { remove-build-file "linker.dump" } } */ diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_4.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_4.C new file mode 100644 index 000000000..58e38ad35 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_4.C @@ -0,0 +1,41 @@ +/* Check if cutting off callgraph gets all functions laid out only according to + function profiles and not prefixes. foo_200 is as hot as the other foo's but + has a unlikely section prefix. This should not matter as sort_name_prefix + is turned off. */ +/* { dg-require-section-exclude "" } */ +/* { dg-require-linker-function-reordering-plugin "" } */ +/* { dg-options "-O2 -freorder-functions=callgraph -ffunction-sections -Wl,-plugin-opt,file=linker.dump,-plugin-opt,edge_cutoff=p100,-plugin-opt,sort_name_prefix=no" } */ + +int __attribute__ ((noinline, section(".text.unlikely._Z7foo_200v"))) +foo_200 () +{ + return 1; +} + +int __attribute__ ((noinline)) +foo_100 () +{ + return 1; +} + +int __attribute__ ((noinline)) +foo_300 () +{ + return 1; +} +int main () +{ + int sum = 0; + for (int i = 0; i< 200; i++) + sum += foo_200 (); + for (int i = 0; i< 100; i++) + sum += foo_100 (); + for (int i = 0; i< 300; i++) + sum += foo_300 (); + return sum - 600; +} + +/* { dg-final-use { scan-file-not linker.dump "Callgraph group" } } */ +/* { dg-final-use { scan-file linker.dump ".text.unlikely._Z7foo_200v entry count = 200 computed = 200 max count = 200" } } */ +/* { dg-final-use { scan-file linker.dump "\.text\.*\._Z7foo_100v.*\n\.text\.unlikely\._Z7foo_200v.*\n\.text\.*\._Z7foo_300v.*\n" } } */ +/* { dg-final-use { remove-build-file "linker.dump" } } */ diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_5.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_5.C new file mode 100644 index 000000000..dbae8d774 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_5.C @@ -0,0 +1,41 @@ +/* Check if cutting off callgraph and using sort_name_prefix gets all functions laid out + according to prefixes. foo_200 is almost as hot as the other foo's but should + not be grouped with them as it has a different section prefix and sort_name_prefix is + turned on. */ +/* { dg-require-section-exclude "" } */ +/* { dg-require-linker-function-reordering-plugin "" } */ +/* { dg-options "-O2 -freorder-functions=callgraph -ffunction-sections -Wl,-plugin-opt,file=linker.dump,-plugin-opt,edge_cutoff=p100,-plugin-opt,sort_name_prefix=yes" } */ + +int __attribute__ ((noinline, section(".text.unlikely._Z7foo_200v"))) +foo_200 () +{ + return 1; +} + +int __attribute__ ((noinline)) +foo_100 () +{ + return 1; +} + +int __attribute__ ((noinline)) +foo_300 () +{ + return 1; +} +int main () +{ + int sum = 0; + for (int i = 0; i< 200; i++) + sum += foo_200 (); + for (int i = 0; i< 100; i++) + sum += foo_100 (); + for (int i = 0; i< 300; i++) + sum += foo_300 (); + return sum - 600; +} + +/* { dg-final-use { scan-file-not linker.dump "Callgraph group" } } */ +/* { dg-final-use { scan-file linker.dump ".text.unlikely._Z7foo_200v entry count = 200 computed = 200 max count = 200" } } */ +/* { dg-final-use { scan-file linker.dump "\.text\.unlikely\._Z7foo_200v.*\n\.text\.*\._Z7foo_100v.*\n\.text\.*\._Z7foo_300v.*\n" } } */ +/* { dg-final-use { remove-build-file "linker.dump" } } */ diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_6.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_6.C new file mode 100644 index 000000000..1116a4f44 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_6.C @@ -0,0 +1,53 @@ +/* Check if use_maxcount works as expected. This makes the node profile weight to + be equal to the maximum count of any basic block in a function rather than the + entry count. foo_100's maxcount > foo_200's max count */ +/* { dg-require-section-exclude "" } */ +/* { dg-require-linker-function-reordering-plugin "" } */ +/* { dg-options "-O2 -freorder-functions=callgraph -ffunction-sections -Wl,-plugin-opt,file=linker.dump -Wl,-plugin-opt,edge_cutoff=p100,-plugin-opt,use_maxcount=yes" } */ + + +int __attribute__ ((noinline)) +bar (int *i) +{ + (*i)--; + if (*i >= 0) + return 1; + return 0; +} + +int __attribute__ ((noinline)) +foo_100 (int count) +{ + int sum = 0; + while (count > 0) + { + sum += bar(&count); + } + return sum; +} + +int __attribute__ ((noinline)) +foo_200 (int count) +{ + int sum = 0; + while (count > 0) + { + sum += bar(&count); + } + return sum; +} + +int main () +{ + int sum = 0; + for (int i = 0; i< 200; i++) + sum += foo_200 (100); + for (int i = 0; i< 100; i++) + sum += foo_100 (400); + return sum - 60000; +} +/* { dg-final-use { scan-file-not linker.dump "Callgraph group" } } */ +/* { dg-final-use { scan-file linker.dump "\.text\.*\._Z7foo_100i entry count = 100 computed = 100 max count = 40000" } } */ +/* { dg-final-use { scan-file linker.dump "\.text\.*\._Z7foo_200i entry count = 200 computed = 200 max count = 20000" } } */ +/* { dg-final-use { scan-file linker.dump "\.text\.*\._Z7foo_200i.*\n\.text\.*\._Z7foo_100i.*\n\.text\.*\._Z3barPi.*\n" } } */ +/* { dg-final-use { remove-build-file "linker.dump" } } */ diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_7.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_7.C new file mode 100644 index 000000000..3af8636ad --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_7.C @@ -0,0 +1,55 @@ +/* Check if turning off use_maxcount works as expected. This makes the node + profile weight to be equal to the entry count of any basic block in a + function rather than the max count. + foo_100's maxcount > foo_200's max count but + foo_100's entry count < foo_200's entry count. */ +/* { dg-require-section-exclude "" } */ +/* { dg-require-linker-function-reordering-plugin "" } */ +/* { dg-options "-O2 -freorder-functions=callgraph -ffunction-sections -Wl,-plugin-opt,file=linker.dump -Wl,-plugin-opt,edge_cutoff=p100,-plugin-opt,use_maxcount=no" } */ + + +int __attribute__ ((noinline)) +bar (int *i) +{ + (*i)--; + if (*i >= 0) + return 1; + return 0; +} + +int __attribute__ ((noinline)) +foo_100 (int count) +{ + int sum = 0; + while (count > 0) + { + sum += bar(&count); + } + return sum; +} + +int __attribute__ ((noinline)) +foo_200 (int count) +{ + int sum = 0; + while (count > 0) + { + sum += bar(&count); + } + return sum; +} + +int main () +{ + int sum = 0; + for (int i = 0; i< 200; i++) + sum += foo_200 (100); + for (int i = 0; i< 100; i++) + sum += foo_100 (400); + return sum - 60000; +} +/* { dg-final-use { scan-file-not linker.dump "Callgraph group" } } */ +/* { dg-final-use { scan-file linker.dump "\.text\.*\._Z7foo_100i entry count = 100 computed = 100 max count = 40000" } } */ +/* { dg-final-use { scan-file linker.dump "\.text\.*\._Z7foo_200i entry count = 200 computed = 200 max count = 20000" } } */ +/* { dg-final-use { scan-file linker.dump "\.text\.*\._Z7foo_100i.*\n\.text\.*\._Z7foo_200i.*\n\.text\.*\._Z3barPi.*\n" } } */ +/* { dg-final-use { remove-build-file "linker.dump" } } */ diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_8.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_8.C new file mode 100644 index 000000000..3f1a0156e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_8.C @@ -0,0 +1,19 @@ +/* Check if unlikely_cutoff works as expected. Function foo is unlikely because of the cutoff. */ +/* { dg-require-section-exclude "" } */ +/* { dg-require-linker-function-reordering-plugin "" } */ +/* { dg-options "-O2 -freorder-functions=callgraph -ffunction-sections -Wl,-plugin-opt,file=linker.dump -Wl,-plugin-opt,edge_cutoff=p100,-plugin-opt,unlikely_cutoff=1" } */ + +int __attribute__ ((noinline,section(".text.hot._Z3foov"))) +foo () +{ + return 0; +} + +int main() +{ + return foo (); +} + +/* { dg-final-use { scan-file-not linker.dump "Callgraph group" } } */ +/* { dg-final-use { scan-file linker.dump "=== Unlikely sections start ===\n.*\.text\.hot\._Z3foov.* entry count = 1 computed = 1 max count = 1 split = 0\n.*=== Unlikely sections end ===" } } */ +/* { dg-final-use { remove-build-file "linker.dump" } } */ diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_split_functions_1.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_split_functions_1.C new file mode 100644 index 000000000..2f184c3e8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_split_functions_1.C @@ -0,0 +1,63 @@ +/* Check if the gold function reordering plugin reorders split functions. + Check if foo is split and the cold section of foo is not next to its hot + section*/ +/* { dg-require-section-exclude "" } */ +/* { dg-require-linker-function-reordering-plugin "" } */ +/* { dg-require-effective-target freorder } */ +/* { dg-options "-O2 -freorder-functions=callgraph -ffunction-sections -freorder-blocks-and-partition --save-temps -Wl,-plugin-opt,file=linker.dump" } */ + + +#define SIZE 10000 + +const char *sarr[SIZE]; +const char *buf_hot; +const char *buf_cold; + +__attribute__ ((noinline)) +int bar (int *arg) +{ + (*arg)++; + return 0; +} + +__attribute__((noinline)) +void +foo (int path) +{ + int i; + bar (&path); + if (path) + { + for (i = 0; i < SIZE; i++) + sarr[i] = buf_hot; + } + else + { + for (i = 0; i < SIZE; i++) + sarr[i] = buf_cold; + } +} + +int +main (int argc, char *argv[]) +{ + buf_hot = "hello"; + buf_cold = "world"; + foo (argc); + return 0; +} + +/* { dg-final-use { scan-assembler "\.string \"ColdWeight 0\"" } } */ +/* { dg-final-use { scan-assembler "\.section.*\.text\.hot\._Z3fooi" } } */ +/* { dg-final-use { scan-assembler "\.section.*\.text\.unlikely\._Z3fooi" } } */ +/* { dg-final-use { cleanup-saved-temps } } */ +/* Check if foo and bar are together */ +/* { dg-final-use { scan-file linker.dump "Callgraph group :.*\(_Z3fooi _Z3barPi|_Z3barPi _Z3fooi\).*\n" } } */ +/* Check if foo and main are together */ +/* { dg-final-use { scan-file linker.dump "Callgraph group :.*\(_Z3fooi main|main _Z3fooi\).*\n" } } */ +/* { dg-final-use { scan-file linker.dump "\.text\.unlikely\._Z3fooi .* split = 1" } } */ +/* Check if unlikely sections of foo and bar are together */ +/* { dg-final-use { scan-file linker.dump "\(\.text\.unlikely\._Z3fooi\[^\n\]*\n\.text\.unlikely\._Z3barPi\[^\n\]*\n|\.text\.unlikely\._Z3barPi\[^\n\]*\n\.text\.unlikely\._Z3fooi\[^\n\]*\n\)" } } */ +/* Check if likely sections of hot foo and bar are together */ +/* { dg-final-use { scan-file linker.dump "\(\.text\._Z3barPi\[^\n\]*\n\.text\.hot\._Z3fooi|\.text\.hot\._Z3fooi\[^\n\]*\n\.text\._Z3barPi\)" } } */ +/* { dg-final-use { remove-build-file "linker.dump" } } */ diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/indir-call-prof-2_0.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/indir-call-prof-2_0.C new file mode 100644 index 000000000..e20cc64d3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/indir-call-prof-2_0.C @@ -0,0 +1,35 @@ +/* { dg-options "-O" } */ + +int foo1(void) { return 0; } +int bar1(void) { throw 1; } +void foo2(void) { } +void bar2(void) { throw 1; } +void __attribute__((noinline,noclone)) test1(void (*f)(void)) { (*f)(); } +void __attribute__((noinline,noclone)) test2(void (*f)(void)) { (*f)(); } +int __attribute__((noinline,noclone)) test3(int (*f)(void)) { return (*f)(); } +int __attribute__((noinline,noclone)) test4(int (*f)(void)) { return (*f)(); } +int __attribute__((noinline,noclone)) test5(int (*f)(void), int x) { return x ? x : (*f)(); } +int __attribute__((noinline,noclone)) test6(int (*f)(void), int x) { return x ? x : (*f)(); } +void __attribute__((noinline,noclone)) test7(void (*f)(void)) { try { (*f)(); } catch (...) {} } +void __attribute__((noinline,noclone)) test8(void (*f)(void)) { try { (*f)(); } catch (...) {}} +int __attribute__((noinline,noclone)) test9(int (*f)(void)) { try { return (*f)(); } catch (...) {return 0;} } +int __attribute__((noinline,noclone)) test10(int (*f)(void)) { try { return (*f)(); } catch (...) {return 0;} } +int __attribute__((noinline,noclone)) test11(int (*f)(void), int x) { try { return x ? x : (*f)(); } catch (...) {return 0;} } +int __attribute__((noinline,noclone)) test12(int (*f)(void), int x) { try { return x ? x : (*f)(); } catch (...) {return 0;} } + +int main() +{ + for (int i = 0; i < 100; ++i) test1(foo2); + for (int i = 0; i < 100; ++i) try { test2(bar2); } catch (...) {} + for (int i = 0; i < 100; ++i) test3(foo1); + for (int i = 0; i < 100; ++i) try { test4(bar1); } catch (...) {} + for (int i = 0; i < 100; ++i) test5(foo1, 0); + for (int i = 0; i < 100; ++i) try { test6(bar1, 0); } catch (...) {} + for (int i = 0; i < 100; ++i) test7(foo2); + for (int i = 0; i < 100; ++i) try { test8(bar2); } catch (...) {} + for (int i = 0; i < 100; ++i) test9(foo1); + for (int i = 0; i < 100; ++i) try { test10(bar1); } catch (...) {} + for (int i = 0; i < 100; ++i) test11(foo1, 0); + for (int i = 0; i < 100; ++i) try { test12(bar1, 0); } catch (...) {} + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/indir-call-prof_0.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/indir-call-prof_0.C new file mode 100644 index 000000000..b34b937fd --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/indir-call-prof_0.C @@ -0,0 +1,39 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */ + +struct A { + A () {} + + virtual int AA (void) + { return 0; } + +}; + +struct B : public A { + B () {} + + virtual int AA (void) + { return 1; } +}; + +void * __attribute__((noinline,noclone)) wrap (void *p) { return p; } +int +main (void) +{ + A a; + B b; + + A* p; + + p = (A *)wrap ((void *)&a); + p->AA (); + + p = (B *)wrap ((void *)&b); + p->AA (); + + return 0; +} + +/* { dg-final-use { scan-ipa-dump "Indirect call -> direct call.* AA " "profile" } } */ +/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized" } } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ +/* { dg-final-use { cleanup-ipa-dump "profile" } } */ diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/inline_mismatch_args_0.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/inline_mismatch_args_0.C new file mode 100644 index 000000000..e82a46ebf --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/inline_mismatch_args_0.C @@ -0,0 +1,36 @@ +/* { dg-options "-O2 -fdump-tree-einline" } */ +class DocId { + public: + DocId() { } + DocId(const DocId &other) { } +}; + +int g; +class Base { + public: + virtual void Foo(DocId id) { g++; } +}; + +class Super: public Base { + public: + void Foo(DocId id) { } + void Bar(Base *base, DocId id) __attribute__((noinline)); +}; + +void Super::Bar(Base *base, DocId id) { + Super::Foo(id); // direct call is inlined + base->Foo(id); // indirect call is marked do not inline +} + +int main(void) +{ + Base bah; + Super baz; + DocId gid; + + baz.Bar(&baz, gid); + return 0; +} +/* { dg-final-use { scan-tree-dump "Inlining .*Super::Foo" "einline" } } */ +/* { dg-final-use { scan-tree-dump-not "mismatched arguments" "einline" } } */ +/* { dg-final-use { cleanup-tree-dump "einline" } } */ diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/lipo.exp b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/lipo.exp new file mode 100644 index 000000000..2d1ddd7cd --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/lipo.exp @@ -0,0 +1,60 @@ +# Copyright (C) 2001, 2002, 2004, 2005, 2007, 2008 +# 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 3 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 GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# Test the functionality of programs compiled with profile-directed block +# ordering using -fprofile-generate followed by -fprofile-use. + +load_lib target-supports.exp + +# Some targets don't support tree profiling. +if { ![check_profiling_available ""] } { + return +} + +# The procedures in profopt.exp need these parameters. +set tool g++ +set prof_ext [list {gcda} {gcda.imports} ] + +# Override the list defined in profopt.exp. +set PROFOPT_OPTIONS [list {}] + +if $tracelevel then { + strace $tracelevel +} + +# Load support procs. +load_lib profopt.exp + +# These are globals used by profopt-execute. The first is options +# needed to generate profile data, the second is options to use the +# profile data. +set profile_option "-fprofile-generate -fripa" +set feedback_option "-fprofile-use -fripa" + +# Add -fno-section-anchors for powerpc. Workround for Google ref b/6663281 +if {[istarget powerpc*-*-*]} { + set profile_option "$profile_option -fno-section-anchors" + set feedback_option "$feedback_option -fno-section-anchors" +} + +foreach src [lsort [glob -nocomplain $srcdir/$subdir/*_0.C]] { + # If we're only testing specific files and this isn't one of them, skip it. + if ![runtest_file_p $runtests $src] then { + continue + } + profopt-execute $src +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition1_0.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition1_0.C new file mode 100644 index 000000000..108803997 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition1_0.C @@ -0,0 +1,54 @@ +/* { dg-require-effective-target freorder } */ +/* { dg-options "-O2 -freorder-blocks-and-partition" } */ +/* { dg-skip-if "PR target/47683" { mips-sgi-irix* } } */ + +struct A { A () __attribute__((noinline)); ~A () __attribute__((noinline)); }; +A::A () { asm volatile ("" : : : "memory"); } +A::~A () { asm volatile ("" : : : "memory"); } + +int bar () __attribute__((noinline)); +void foo () __attribute__((noinline)); + +volatile int k, l; + +int bar (int i) +{ + void *p = __builtin_alloca (i); + asm volatile ("" : : "r" (i), "r" (p) : "memory"); + if (k) throw 6; + return ++l; +} + +void foo () +{ + A a; + try { + A b; + int i = bar (5); + try { throw 6; } catch (int) {} + if (__builtin_expect (i < 4500, 0)) { + bar (7); + try { bar (8); } catch (long) {} + bar (10); + if (__builtin_expect (i < 0, 0)) { + try { bar (12); } catch (...) {} + bar (16); + bar (122); + } else { + try { bar (bar (7)); } catch (int) {} + } + } else { + try { bar (bar (bar (9))); } catch (...) {} + bar (5); + } + } catch (...) { + } +} + +int +main () +{ + int i; + for (i = 0; i < 10000; i++) + foo (); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition2_0.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition2_0.C new file mode 100644 index 000000000..6715da57e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition2_0.C @@ -0,0 +1,16 @@ +// PR middle-end/45458 +// { dg-require-effective-target freorder } +// { dg-options "-fnon-call-exceptions -freorder-blocks-and-partition" } +// { dg-skip-if "PR target/47683" { mips-sgi-irix* } } + +int +main () +{ + try + { + throw 6; + } + catch (...) + { + } +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition3_0.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition3_0.C new file mode 100644 index 000000000..784698369 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition3_0.C @@ -0,0 +1,18 @@ +// PR middle-end/45566 +// { dg-require-effective-target freorder } +// { dg-options "-O -fnon-call-exceptions -freorder-blocks-and-partition" } + +int k; + +int +main () +{ + try + { + if (k) + throw 6; + } + catch (...) + { + } +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_0.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_0.C new file mode 100644 index 000000000..3052344b5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_0.C @@ -0,0 +1,41 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */ +#include <stdio.h> +struct A { + A () {} + virtual int AA (void) { return 0; } +}; + +extern A* getB (void); +extern A* getC (void); + +int g; + +int +main (void) +{ + A* p; + int i; + int s = 0; + + p = getB(); + for (i = 0; i < 100; i++) + { + s += p->AA(); + } + + for (i = 0; i < 100; i++) + { + if (i%10 == 0) + p = getB(); + else + p = getC(); + + s += p->AA(); + } + printf ("result = %d\n",s); +} + +/* { dg-final-use { scan-ipa-dump-times "Indirect call -> direct call" 2 "profile" } } */ +/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized" } } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ +/* { dg-final-use { cleanup-ipa-dump "profile" } } */ diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_1.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_1.C new file mode 100644 index 000000000..6023024f4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_1.C @@ -0,0 +1,23 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */ + +struct A { + A () {} + + virtual int AA (void) + { return 0; } + +}; + +struct B : public A { + B () {} + + virtual int AA (void) + { return 1; } +}; + +B b; + +A* getB (void) +{ + return &b; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_2.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_2.C new file mode 100644 index 000000000..cc33d6a19 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_2.C @@ -0,0 +1,31 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */ + +struct A { + A () {} + + virtual int AA (void) + { return 0; } + +}; + +struct B : public A { + B () {} + + virtual int AA (void) + { return 1; } +}; + +struct C : public B { + C () {} + + virtual int AA (void) + { return 2; } + +}; + +C c; + +A* getC(void) +{ + return &c; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/morefunc.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/morefunc.C new file mode 100644 index 000000000..d5cee40cd --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/morefunc.C @@ -0,0 +1,55 @@ +/* { dg-options "-O2 -fno-devirtualize --param=profile-func-internal-id=0 -fdump-ipa-profile -Wno-attributes -Wno-coverage-mismatch" } */ +#include "reorder_class1.h" +#include "reorder_class2.h" + +int g; + +#ifdef _PROFILE_USE +/* Another function not existing + * in profile-gen */ + +__attribute__((noinline)) void +new_func (int i) +{ + g += i; +} +#endif + +static __attribute__((always_inline)) +void test1 (A *tc) +{ + int i; + for (i = 0; i < 1000; i++) + g += tc->foo(); + if (g<100) g++; +} + +static __attribute__((always_inline)) +void test2 (B *tc) +{ + int i; + for (i = 0; i < 1000; i++) + g += tc->foo(); +} + + +__attribute__((noinline)) void test_a(A *ap) { test1 (ap); } +__attribute__((noinline)) void test_b(B *bp) { test2 (bp); } + + +int main() +{ + A* ap = new A(); + B* bp = new B(); + + test_a(ap); + test_b(bp); + +#ifdef _PROFILE_USE + new_func(10); +#endif + +} + +/* { dg-final-use { scan-ipa-dump-times "Indirect call -> direct call" 2 "profile" } } */ + diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/reorder.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/reorder.C new file mode 100644 index 000000000..f0efc210a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/reorder.C @@ -0,0 +1,48 @@ +/* { dg-options "-O2 -fno-devirtualize --param=profile-func-internal-id=0 -fdump-ipa-profile -Wno-attributes" } */ + +#ifdef _PROFILE_USE +#include "reorder_class1.h" +#include "reorder_class2.h" +#else +#include "reorder_class2.h" +#include "reorder_class1.h" +#endif + +int g; +static __attribute__((always_inline)) +void test1 (A *tc) +{ + int i; + for (i = 0; i < 1000; i++) + g += tc->foo(); + if (g<100) g++; +} + +static __attribute__((always_inline)) +void test2 (B *tc) +{ + int i; + for (i = 0; i < 1000; i++) + g += tc->foo(); +} + + +#ifdef _PROFILE_USE +__attribute__((noinline)) void test_a(A *ap) { test1 (ap); } +__attribute__((noinline)) void test_b(B *bp) { test2 (bp); } +#else +__attribute__((noinline)) void test_b(B *bp) { test2 (bp); } +__attribute__((noinline)) void test_a(A *ap) { test1 (ap); } +#endif + +int main() +{ + A* ap = new A(); + B* bp = new B(); + + test_a(ap); + test_b(bp); +} + +/* { dg-final-use { scan-ipa-dump-times "Indirect call -> direct call" 2 "profile" } } */ + diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/reorder_class1.h b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/reorder_class1.h new file mode 100644 index 000000000..62a1e923c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/reorder_class1.h @@ -0,0 +1,11 @@ +struct A { + virtual int foo(); +}; + +int A::foo() +{ + return 1; +} + + + diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/reorder_class2.h b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/reorder_class2.h new file mode 100644 index 000000000..ee3ed109b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/reorder_class2.h @@ -0,0 +1,12 @@ + +struct B { + virtual int foo(); +}; + +int B::foo() +{ + return 2; +} + + + diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/tree-prof.exp b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/tree-prof.exp index 2c96ee38c..f12ddaf86 100644 --- a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/tree-prof.exp +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/tree-prof.exp @@ -42,8 +42,8 @@ set PROFOPT_OPTIONS [list {}] # These are globals used by profopt-execute. The first is options # needed to generate profile data, the second is options to use the # profile data. -set profile_option "-fprofile-generate" -set feedback_option "-fprofile-use" +set profile_option "-fprofile-generate -D_PROFILE_GENERATE" +set feedback_option "-fprofile-use -D_PROFILE_USE" foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.C]] { # If we're only testing specific files and this isn't one of them, skip it. diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-ssa/forwprop-switch.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-ssa/forwprop-switch.C new file mode 100644 index 000000000..c3f12ac45 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-ssa/forwprop-switch.C @@ -0,0 +1,24 @@ +// { dg-do compile } +// { dg-options "-O -fdump-tree-cddce1" } + +enum Scale { E1, E2, E3, E4, E5, E6, E7, E8 }; + +int Test(Scale s) +{ + switch(s) + { + case E1: return 12; + case E2: return 17; + case E3: return 22; + case E4: return 42; + default: break; + } + return 0; +} + +// tree forwprop should have eliminated the (int) s cast for the +// switch value and directly switch on the 's' parameter + +// { dg-final { scan-tree-dump-not "\\\(int\\\)" "cddce1" } } +// { dg-final { scan-tree-dump "switch \\\(s_.\\\(D\\\)\\\)" "cddce1" } } +// { dg-final { cleanup-tree-dump "cddce1" } } diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-ssa/pr61009.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-ssa/pr61009.C new file mode 100644 index 000000000..4e7bb1a1c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-ssa/pr61009.C @@ -0,0 +1,53 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-vrp -std=c++11 -fno-strict-aliasing -fdump-tree-dom1" } */ + +#include <stdio.h> +struct Field { + virtual int Compare(void*, void*); +}; +extern int NKF, NR; +extern int idxs[]; +extern Field* the_field; +extern int *incs; +extern char** fptrs; +inline int doCmp(int this_row_offset, int field_idx) { + void *p = fptrs[field_idx] + this_row_offset * incs[field_idx]; + return the_field->Compare(p,0); +} +bool Test(void) { + + int row_offset = 0; + + for (; row_offset < NR; ++row_offset) { + + bool is_different = false; + for (int j = 0; j < NKF ; ++j) { + int field_idx = idxs[j]; + int cmp = doCmp(row_offset, field_idx); + fprintf (stderr, "cmp=%d\n",cmp); + + if (cmp == 0) { + continue; + } + if (cmp > 0) { + is_different = true; + break; + } else { + fprintf (stderr, "Incorrect\n"); + return false; + } + } + if (!is_different) { + + return false; + } + } + + return true; +} + +// The block ending with cmp == 0 should not be threaded. ie, +// there should be a single == 0 comparison in the dump file. + +// { dg-final { scan-tree-dump-times "== 0" 1 "dom1" } } +// { dg-final { cleanup-tree-dump "dom1" } } diff --git a/gcc-4.9/gcc/testsuite/g++.dg/vect/pr60836.cc b/gcc-4.9/gcc/testsuite/g++.dg/vect/pr60836.cc new file mode 100644 index 000000000..83bb18375 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/vect/pr60836.cc @@ -0,0 +1,39 @@ +// { dg-do compile } + +int a, b; +typedef double (*NormFunc) (const int &); +int & +max (int &p1, int &p2) +{ + if (p1 < p2) + return p2; + return p1; +} + +struct A +{ + int operator () (int p1, int p2) + { + return max (p1, p2); + } +}; +template < class, class > double +norm_ (const int &) +{ + char c, d; + A e; + for (; a; a++) + { + b = e (b, d); + b = e (b, c); + } +} + +void +norm () +{ + static NormFunc f = norm_ < int, A >; + f = 0; +} + +// { dg-final { cleanup-tree-dump "vect" } } diff --git a/gcc-4.9/gcc/testsuite/g++.dg/warn/Weff1.C b/gcc-4.9/gcc/testsuite/g++.dg/warn/Weff1.C deleted file mode 100644 index a00dc29bf..000000000 --- a/gcc-4.9/gcc/testsuite/g++.dg/warn/Weff1.C +++ /dev/null @@ -1,5 +0,0 @@ -// { dg-options "-Weffc++" } - -struct S {}; -/* Base classes should have virtual destructors. */ -struct T : public S {}; // { dg-warning "" } diff --git a/gcc-4.9/gcc/testsuite/g++.dg/warn/Wnull-conversion-1.C b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wnull-conversion-1.C index 84a1d380b..ff82fd44a 100644 --- a/gcc-4.9/gcc/testsuite/g++.dg/warn/Wnull-conversion-1.C +++ b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wnull-conversion-1.C @@ -3,7 +3,7 @@ #include <stddef.h> -void func1(int* ptr); +void func1 (int *ptr); void func2() { int* t = false; // { dg-warning "converting 'false' to pointer" } diff --git a/gcc-4.9/gcc/testsuite/g++.dg/warn/Wnull-conversion-2.C b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wnull-conversion-2.C index 92a87d1e7..6ce7605c5 100644 --- a/gcc-4.9/gcc/testsuite/g++.dg/warn/Wnull-conversion-2.C +++ b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wnull-conversion-2.C @@ -3,43 +3,53 @@ #include <stddef.h> -class Foo { - public: - template <typename T1, typename T2> - static void Compare(const T1& expected, const T2& actual) { } +class Foo +{ +public: + template < typename T1, typename T2 > + static void Compare (const T1 & expected, const T2 & actual) + { + } - template <typename T1, typename T2> - static void Compare(const T1& expected, T2* actual) { } + template < typename T1, typename T2 > + static void Compare (const T1 & expected, T2 * actual) + { + } }; -template<typename T1> -class Foo2 { - public: - Foo2(int x); - template<typename T2> void Bar(T2 y); +template < typename T1 > class Foo2 +{ +public: + Foo2 (int x); + template < typename T2 > void Bar (T2 y); }; -template<typename T3> void func(T3 x) { } +template < typename T3 > void +func (T3 x) +{ +} -typedef Foo2<int> MyFooType; +typedef Foo2 < int >MyFooType; -void func1(long int a) { - MyFooType *foo2 = new MyFooType(NULL); // { dg-warning "passing NULL to" } - foo2->Bar(a); - func(NULL); - func<int>(NULL); // { dg-warning "passing NULL to" } - func<int *>(NULL); +void +func1 (long int a) +{ + MyFooType *foo2 = new MyFooType (NULL); // { dg-warning "passing NULL to" } + foo2->Bar (a); + func (NULL); + func < int >(NULL); // { dg-warning "passing NULL to" } + func < int *>(NULL); } int x = 1; -main() +main () { int *p = &x; - Foo::Compare(0, *p); - Foo::Compare<long int, int>(NULL, p); // { dg-warning "passing NULL to" } - Foo::Compare(NULL, p); - func1(NULL); // { dg-warning "passing NULL to" } + Foo::Compare (0, *p); + Foo::Compare < long int, int >(NULL, p); // { dg-warning "passing NULL to" } + Foo::Compare (NULL, p); + func1 (NULL); // { dg-warning "passing NULL to" } } diff --git a/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-1.C b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-1.C new file mode 100644 index 000000000..f15280501 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-1.C @@ -0,0 +1,54 @@ +// Test the self-assignemnt detection and warning. +// { dg-do compile } +// { dg-options "-Wself-assign" } + +class Foo { + private: + int a_; + + public: + Foo() : a_(a_) {} // { dg-warning "assigned to itself" } + + void setA(int a) { + a_ = a_; // { dg-warning "assigned to itself" } + } + + void operator=(Foo& rhs) { + this->a_ = rhs.a_; + } +}; + +struct Bar { + int b_; + int c_; +}; + +int g = g; // { dg-warning "assigned to itself" } +Foo foo = foo; // { dg-warning "assigned to itself" } + +int func() +{ + Bar *bar1, bar2; + Foo local_foo; + int x = x; // { dg-warning "assigned to itself" } + static int y = y; // { dg-warning "assigned to itself" } + float *f; + Bar bar_array[5]; + char n; + int overflow; + + *f = *f; // { dg-warning "assigned to itself" } + bar1->b_ = bar1->b_; // { dg-warning "assigned to itself" } + bar2.c_ = bar2.c_; // { dg-warning "assigned to itself" } + local_foo = local_foo; + foo = foo; + foo.setA(5); + bar_array[3].c_ = bar_array[3].c_; // { dg-warning "assigned to itself" } + bar_array[x+g].b_ = bar_array[x+g].b_; // { dg-warning "assigned to itself" } + y = x; + x = y; + x += 0; // should not warn + y -= 0; // should not warn + x /= x; // should not warn + y *= y; // should not warn +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-3.C b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-3.C new file mode 100644 index 000000000..bc5732de9 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-3.C @@ -0,0 +1,35 @@ +// Test how operands_equal_p handles a NULL operand. +// { dg-do compile } +// { dg-options "-Wself-assign" } + +#include <cstdio> + +namespace testing { + +class Foo { + int f; + public: + Foo() { printf("Construct Foo\n"); } +}; + +class Bar { + int b; + public: + Bar(int x) { printf("Construct Bar\n"); } + + void operator=(const Foo& foo) { + printf("Assign Foo to Bar\n"); + } +}; + +} + +template <class T> +void func(T t) { + ::testing::Bar(1) = ::testing::Foo(); // used to trigger a segfault + ::testing::Foo() = ::testing::Foo(); +} + +main() { + func(2); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-4.C b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-4.C new file mode 100644 index 000000000..abe96b55d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-4.C @@ -0,0 +1,48 @@ +// Test how self-assignment detection handles constant-folding happening +// when parsing the RHS or the initializer. +// { dg-do compile } +// { dg-options "-Wself-assign" } + +class Foo { + private: + int a_; + + public: + Foo() : a_(a_+0) {} // should not warn + + void setA(int a) { + a_ = a_ + 0; // should not warn + } + + void operator=(Foo& rhs) { + this->a_ = rhs.a_; + } +}; + +struct Bar { + int b_; + float c_; +}; + +int g = g * 1; // should not warn + +int func() +{ + Bar *bar1, bar2; + Foo foo; + int x = x - 0; // should not warn + static int y = y / 1; // should not warn + float *f; + Bar bar_array[5]; + + *f = *f / 1; // should not warn + bar1->b_ = bar1->b_ * 1; // should not warn + bar2.c_ = bar2.c_ - 0; // should not warn + foo.setA(5); + bar_array[3].c_ = bar_array[3].c_ * 1; // should not warn + bar_array[x+g].b_ = bar_array[x+g].b_ / 1; // should not warn + x += 0; + y -= 0; + foo = foo; + foo.operator=(foo); // should not warn +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-5.C b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-5.C new file mode 100644 index 000000000..20df214dd --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-5.C @@ -0,0 +1,38 @@ +// Test -Wself-assign does not warn on self-assignment of non-POD variables. +// { dg-do compile } +// { dg-options "-Wself-assign" } + +template<typename T> +class Foo { + private: + T a_; + public: + Foo() : a_(a_) {} // { dg-warning "assigned to itself" } + void Set() { a_ = a_; } +}; + +struct Bar { + int b_; + int c_; + void operator=(Bar& rhs) { + this->b_ = rhs.b_; + this->c_ = rhs.c_; + } +}; + +template <typename T> +void func() { + T a; + a = a; +} + +main() +{ + Foo<Bar> foo; + Bar *bar1, bar2; + func<int>(); + foo = foo; + bar2 = bar2; + bar1 = bar1; // { dg-warning "assigned to itself" } + bar2.b_ = bar2.b_; // { dg-warning "assigned to itself" } +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-non-pod-1.C b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-non-pod-1.C new file mode 100644 index 000000000..6f9dfb73c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-non-pod-1.C @@ -0,0 +1,54 @@ +// Test the self-assignemnt detection and warning. +// { dg-do compile } +// { dg-options "-Wself-assign -Wself-assign-non-pod" } + +class Foo { + private: + int a_; + + public: + Foo() : a_(a_) {} // { dg-warning "assigned to itself" } + + void setA(int a) { + a_ = a_; // { dg-warning "assigned to itself" } + } + + void operator=(Foo& rhs) { + this->a_ = rhs.a_; + } +}; + +struct Bar { + int b_; + int c_; +}; + +int g = g; // { dg-warning "assigned to itself" } +Foo foo = foo; // { dg-warning "assigned to itself" } + +int func() +{ + Bar *bar1, bar2; + Foo local_foo; + int x = x; // { dg-warning "assigned to itself" } + static int y = y; // { dg-warning "assigned to itself" } + float *f; + Bar bar_array[5]; + char n; + int overflow; + + *f = *f; // { dg-warning "assigned to itself" } + bar1->b_ = bar1->b_; // { dg-warning "assigned to itself" } + bar2.c_ = bar2.c_; // { dg-warning "assigned to itself" } + local_foo = local_foo; // { dg-warning "assigned to itself" } + foo = foo; // { dg-warning "assigned to itself" } + foo.setA(5); + bar_array[3].c_ = bar_array[3].c_; // { dg-warning "assigned to itself" } + bar_array[x+g].b_ = bar_array[x+g].b_; // { dg-warning "assigned to itself" } + y = x; + x = y; + x += 0; // should not warn + y -= 0; // should not warn + x /= x; // should not warn + y *= y; // should not warn +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-non-pod-3.C b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-non-pod-3.C new file mode 100644 index 000000000..4c37f5764 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-non-pod-3.C @@ -0,0 +1,35 @@ +// Test how operands_equal_p handles a NULL operand. +// { dg-do compile } +// { dg-options "-Wself-assign -Wself-assign-non-pod" } + +#include <cstdio> + +namespace testing { + +class Foo { + int f; + public: + Foo() { printf("Construct Foo\n"); } +}; + +class Bar { + int b; + public: + Bar(int x) { printf("Construct Bar\n"); } + + void operator=(const Foo& foo) { + printf("Assign Foo to Bar\n"); + } +}; + +} + +template <class T> +void func(T t) { + ::testing::Bar(1) = ::testing::Foo(); // used to trigger a segfault + ::testing::Foo() = ::testing::Foo(); // { dg-warning "assigned to itself" } +} + +main() { + func(2); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-non-pod-4.C b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-non-pod-4.C new file mode 100644 index 000000000..86db4e3c6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-non-pod-4.C @@ -0,0 +1,48 @@ +// Test how self-assignment detection handles constant-folding happening +// when parsing the RHS or the initializer. +// { dg-do compile } +// { dg-options "-Wself-assign -Wself-assign-non-pod" } + +class Foo { + private: + int a_; + + public: + Foo() : a_(a_+0) {} // should not warn + + void setA(int a) { + a_ = a_ + 0; // should not warn + } + + void operator=(Foo& rhs) { + this->a_ = rhs.a_; + } +}; + +struct Bar { + int b_; + float c_; +}; + +int g = g * 1; // should not warn + +int func() +{ + Bar *bar1, bar2; + Foo foo; + int x = x - 0; // should not warn + static int y = y / 1; // should not warn + float *f; + Bar bar_array[5]; + + *f = *f / 1; // should not warn + bar1->b_ = bar1->b_ * 1; // should not warn + bar2.c_ = bar2.c_ - 0; // should not warn + foo.setA(5); + bar_array[3].c_ = bar_array[3].c_ * 1; // should not warn + bar_array[x+g].b_ = bar_array[x+g].b_ / 1; // should not warn + x += 0; + y -= 0; + foo = foo; // { dg-warning "assigned to itself" } + foo.operator=(foo); // should not warn +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-non-pod-5.C b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-non-pod-5.C new file mode 100644 index 000000000..898ddecd7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-non-pod-5.C @@ -0,0 +1,38 @@ +// Test -Wself-assign and -Wself-assign-non-pod. +// { dg-do compile } +// { dg-options "-Wself-assign -Wself-assign-non-pod" } + +template<typename T> +class Foo { + private: + T a_; + public: + Foo() : a_(a_) {} // { dg-warning "assigned to itself" } + void Set() { a_ = a_; } // { dg-warning "assigned to itself" } +}; + +struct Bar { + int b_; + int c_; + void operator=(Bar& rhs) { + this->b_ = rhs.b_; + this->c_ = rhs.c_; + } +}; + +template <typename T> +void func() { + T a; + a = a; // { dg-warning "assigned to itself" } +} + +main() +{ + Foo<Bar> foo; + Bar *bar1, bar2; + func<int>(); + foo = foo; // { dg-warning "assigned to itself" } + bar2 = bar2; // { dg-warning "assigned to itself" } + bar1 = bar1; // { dg-warning "assigned to itself" } + bar2.b_ = bar2.b_; // { dg-warning "assigned to itself" } +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/warn/Wshadow-compatible-local-1.C b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wshadow-compatible-local-1.C new file mode 100644 index 000000000..e251b724e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wshadow-compatible-local-1.C @@ -0,0 +1,63 @@ +/* { dg-do compile } */ +/* { dg-options -Wshadow-compatible-local } */ + +class Bar { +}; + +class ChildBar : public Bar { +}; + +Bar bar; + +class Foo { + private: + int val; + + public: + int func1(int x) { + int val; + val = x; + return val; + } + + int func2(int i) { // { dg-warning "shadowed declaration" } + int a = 3; // { dg-warning "shadowed declaration" } + + for (int i = 0; i < 5; ++i) { // { dg-warning "shadows a parameter" } + for (int i = 0; i < 3; ++i) { // { dg-warning "shadows a previous local" } + int a = i; // { dg-warning "shadows a previous local" } + func1(a); + } + } + + return a; + } + + int func3() { + int bar; + float func1 = 0.3; + int f = 5; // { dg-warning "shadowed declaration" } + + if (func1 > 1) { + float f = 2.0; // { dg-warning "shadows a previous local" } + bar = f; + } + else + bar = 1; + return bar; + } + + void func4() { + Bar *bar; // { dg-bogus "shadowed declaration" } + ChildBar *cbp; // { dg-bogus "shadowed declaration" } + Bar *bp; // { dg-warning "shadowed declaration" } + if (val) { + int bar; // { dg-bogus "shadows a previous local" } + Bar *cbp; // { dg-bogus "shadows a previous local" } + ChildBar *bp; // { dg-warning "shadows a previous local" } + func1(bar); + } + } +}; + +// { dg-warning "shadowed declaration" "" { target *-*-* } 26 } diff --git a/gcc-4.9/gcc/testsuite/g++.dg/warn/Wshadow-local-1.C b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wshadow-local-1.C new file mode 100644 index 000000000..24a5bc223 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wshadow-local-1.C @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options -Wshadow-local } */ + +struct status +{ + int member; + void foo2 (); + + inline static int foo3 (int member) + { + return member; + } +}; + +int decl1; // { dg-bogus "shadowed declaration" } +int decl2; // { dg-bogus "shadowed declaration" } +void foo (struct status &status, + double decl1) // { dg-bogus "shadows a global" } +{ +} + +void foo1 (int d) +{ + double d; // { dg-error "shadows a parameter" } +} + +void status::foo2 () +{ + int member; // { dg-bogus "shadows a member" } + int decl2; // { dg-bogus "shadows a global" } + int local; // { dg-warning "shadowed declaration" } + { + int local; // { dg-warning "shadows a previous local" } + } +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/warn/Wshadow-local-2.C b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wshadow-local-2.C new file mode 100644 index 000000000..ac3951ebc --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wshadow-local-2.C @@ -0,0 +1,63 @@ +/* { dg-do compile } */ +/* { dg-options -Wshadow-local } */ + +class Bar { +}; + +class ChildBar : public Bar { +}; + +Bar bar; // { dg-bogus "shadowed declaration" } + +class Foo { + private: + int val; + + public: + int func1(int x) { + int val; // { dg-bogus "shadows a member" } + val = x; + return val; + } + + int func2(int i) { // { dg-warning "shadowed declaration" } + int a = 3; // { dg-warning "shadowed declaration" } + + for (int i = 0; i < 5; ++i) { // { dg-warning "shadows a parameter" } + for (int i = 0; i < 3; ++i) { // { dg-warning "shadows a previous local" } + int a = i; // { dg-warning "shadows a previous local" } + func1(a); + } + } + + return a; + } + + int func3() { + int bar; // { dg-bogus "shadows a global" } + float func1 = 0.3; // { dg-bogus "shadows a member" } + int f = 5; // { dg-warning "shadowed declaration" } + + if (func1 > 1) { + float f = 2.0; // { dg-warning "shadows a previous local" } + bar = f; + } + else + bar = 1; + return bar; + } + + void func4() { + Bar *bar; // { dg-warning "shadowed declaration" } + ChildBar *cbp; // { dg-warning "shadowed declaration" } + Bar *bp; // { dg-warning "shadowed declaration" } + if (val) { + int bar; // { dg-warning "shadows a previous local" } + Bar *cbp; // { dg-warning "shadows a previous local" } + ChildBar *bp; // { dg-warning "shadows a previous local" } + func1(bar); + } + } +}; + +// { dg-warning "shadowed declaration" "" { target *-*-* } 26 } |