aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg')
-rw-r--r--gcc/testsuite/g++.dg/asan/pr85081.C20
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/extern_template-4.C23
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-dependent1.C19
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/range-for35.C8
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/range-for9.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/decomp10.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/decomp37.C62
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/decomp38.C48
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/decomp4.C4
-rw-r--r--gcc/testsuite/g++.dg/diagnostic/pr85464.C5
-rw-r--r--gcc/testsuite/g++.dg/ext/visibility/lambda1.C14
-rw-r--r--gcc/testsuite/g++.dg/ipa/pr84658.C30
-rw-r--r--gcc/testsuite/g++.dg/torture/pr85496.C18
13 files changed, 251 insertions, 4 deletions
diff --git a/gcc/testsuite/g++.dg/asan/pr85081.C b/gcc/testsuite/g++.dg/asan/pr85081.C
new file mode 100644
index 00000000000..d7dec311450
--- /dev/null
+++ b/gcc/testsuite/g++.dg/asan/pr85081.C
@@ -0,0 +1,20 @@
+/* PR sanitizer/85081 */
+/* { dg-do run } */
+/* { dg-options "-fopenmp-simd" } */
+/* { dg-require-effective-target fopenmp } */
+
+inline const int& max(const int& a, const int& b)
+{
+ return a < b ? b : a;
+}
+
+int main()
+{
+ #pragma omp simd
+ for ( int i = 0; i < 20; ++i )
+ {
+ const int j = max(i, 1);
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/extern_template-4.C b/gcc/testsuite/g++.dg/cpp0x/extern_template-4.C
new file mode 100644
index 00000000000..9f0c7d720ab
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/extern_template-4.C
@@ -0,0 +1,23 @@
+// PR c++/85470
+// { dg-do compile { target c++11 } }
+
+template <class T>
+struct StaticObject
+{
+ static T& create()
+ {
+ static T t;
+ return t;
+ }
+
+ static T & instance;
+};
+
+template <class T> T & StaticObject<T>::instance = StaticObject<T>::create();
+
+extern template class StaticObject<int>;
+
+void test()
+{
+ StaticObject<int>::instance;
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-dependent1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-dependent1.C
new file mode 100644
index 00000000000..6fd2bb379bf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-dependent1.C
@@ -0,0 +1,19 @@
+// PR c++/85815
+// { dg-do compile { target c++11 } }
+
+template<class T>
+class A {
+ static A* INSTANCE;
+ void foobar();
+ void moo() {}
+};
+
+template<class T>
+A<T>* A<T>::INSTANCE = nullptr;
+
+template<class T>
+void A<T>::foobar() {
+ auto x = []() {
+ INSTANCE->moo();
+ };
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for35.C b/gcc/testsuite/g++.dg/cpp0x/range-for35.C
new file mode 100644
index 00000000000..c77a5af5a44
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/range-for35.C
@@ -0,0 +1,8 @@
+// PR c++/86060
+// { dg-options -Wpedantic }
+
+template <typename T> void foo(T (&a)[8]) {
+ for (int i : a) // { dg-warning "range-based" "" { target c++98_only } }
+ i;
+}
+void fn1() { foo<int>; }
diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for9.C b/gcc/testsuite/g++.dg/cpp0x/range-for9.C
index 6a50ec36c14..eaa5b406880 100644
--- a/gcc/testsuite/g++.dg/cpp0x/range-for9.C
+++ b/gcc/testsuite/g++.dg/cpp0x/range-for9.C
@@ -5,6 +5,6 @@
void test()
{
int a[] = {0,1,2};
- for (int x : a) // { dg-error "range-based 'for'" }
+ for (int x : a) // { dg-error "range-based 'for'|forming reference" }
;
}
diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp10.C b/gcc/testsuite/g++.dg/cpp1z/decomp10.C
index f27cbfbc0d9..95d8bf6364e 100644
--- a/gcc/testsuite/g++.dg/cpp1z/decomp10.C
+++ b/gcc/testsuite/g++.dg/cpp1z/decomp10.C
@@ -20,7 +20,7 @@ void f3() { auto [ x ] = a3; } // { dg-error "get" }
struct A3a { int i,j; int get(); } a3a;
template<> struct std::tuple_size<A3a> { enum { value = 1 }; };
-void f3a() { auto [ x ] = a3a; } // { dg-error "get<0>" }
+void f3a() { auto [ x ] = a3a; } // { dg-error "get" }
struct A3b { int i,j; } a3b;
int get(A3b&&);
diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp37.C b/gcc/testsuite/g++.dg/cpp1z/decomp37.C
new file mode 100644
index 00000000000..dc47908cddf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/decomp37.C
@@ -0,0 +1,62 @@
+// { dg-additional-options -std=c++17 }
+// { dg-do compile }
+
+#include <memory>
+#include <tuple>
+#include <string>
+
+struct X : private std::shared_ptr<int>
+{
+ std::string fun_payload;
+};
+
+template<int N> std::string& get(X& x)
+{
+ if constexpr(N==0) return x.fun_payload;
+}
+
+namespace std {
+ template<> class tuple_size<X> : public std::integral_constant<int, 1> {};
+ template<> class tuple_element<0, X> {public: using type = std::string;};
+}
+
+struct X2 : private std::shared_ptr<int>
+{
+ int fun_payload;
+ template <class T> void get();
+};
+
+template<int N> int& get(X2& x)
+{
+ if constexpr(N==0) return x.fun_payload;
+}
+
+namespace std {
+ template<> class tuple_size<X2> : public std::integral_constant<int, 1> {};
+ template<> class tuple_element<0, X2> {public: using type = int;};
+}
+
+class X3
+{
+ double fun_payload;
+public:
+ template <int N> double& get()
+ {
+ if constexpr(N==0) return fun_payload;
+ }
+};
+
+namespace std {
+ template<> class tuple_size<X3> : public std::integral_constant<int, 1> {};
+ template<> class tuple_element<0, X3> {public: using type = double;};
+}
+
+int main()
+{
+ X x;
+ auto& [b1] = x;
+ X2 x2;
+ auto& [b2] = x2;
+ X3 x3;
+ auto& [b3] = x3;
+}
diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp38.C b/gcc/testsuite/g++.dg/cpp1z/decomp38.C
new file mode 100644
index 00000000000..fc69c02e4d3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/decomp38.C
@@ -0,0 +1,48 @@
+// { dg-additional-options -std=c++17 }
+// { dg-do compile }
+
+class X
+{
+ int a, b;
+ void f()
+ {
+ auto[x,y] = *this;
+ }
+};
+
+class X2
+{
+ int a, b;
+ void f(X2& other)
+ {
+ auto[x,y] = other;
+ }
+};
+
+struct X3
+{
+ friend void foo();
+private:
+ int a;
+};
+
+void foo()
+{
+ X3 x;
+ auto [a] = x;
+}
+
+struct X4
+{
+ int a;
+};
+
+struct X5 : private X4
+{
+ friend void foo2();
+};
+
+void foo2() {
+ X5 x;
+ auto [a] = x;
+}
diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp4.C b/gcc/testsuite/g++.dg/cpp1z/decomp4.C
index bc85263e986..30068592553 100644
--- a/gcc/testsuite/g++.dg/cpp1z/decomp4.C
+++ b/gcc/testsuite/g++.dg/cpp1z/decomp4.C
@@ -18,10 +18,10 @@ test (A &a, B &b, C &c, D &d, E &e, F &f, G &g, H &h, I &i)
// { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
auto [ k ] { b }; // { dg-error "cannot decompose class type 'B' because it has an anonymous union member" }
// { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
- auto [ l, l2 ] = c; // { dg-error "cannot decompose non-public member 'C::b' of 'C'" }
+ auto [ l, l2 ] = c; // { dg-error "cannot decompose inaccessible member 'C::b' of 'C'" }
// { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
auto [ m ] = d; // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } }
- auto [ n ] { e }; // { dg-error "cannot decompose non-public member 'E::a' of 'E'" }
+ auto [ n ] { e }; // { dg-error "cannot decompose inaccessible member 'E::a' of 'E'" }
// { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
auto [ o ] { f }; // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } }
auto & [ p ] { g }; // { dg-error "cannot decompose class type 'G': both it and its base class 'F' have non-static data members" }
diff --git a/gcc/testsuite/g++.dg/diagnostic/pr85464.C b/gcc/testsuite/g++.dg/diagnostic/pr85464.C
new file mode 100644
index 00000000000..ee8b65185e5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/diagnostic/pr85464.C
@@ -0,0 +1,5 @@
+// { dg-options "-Wignored-qualifiers" }
+struct Test {
+ operator int const(); // { dg-warning "type qualifiers ignored" }
+ operator int const() const; // { dg-warning "type qualifiers ignored" }
+};
diff --git a/gcc/testsuite/g++.dg/ext/visibility/lambda1.C b/gcc/testsuite/g++.dg/ext/visibility/lambda1.C
new file mode 100644
index 00000000000..359f8e4af5a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/visibility/lambda1.C
@@ -0,0 +1,14 @@
+// PR c++/85646
+// { dg-do compile { target c++11 } }
+// { dg-additional-options -fvisibility=hidden }
+
+template<typename T>
+void foo() {
+ struct inner {
+ inner() {
+ (void)([this] { });
+ }
+ };
+}
+
+int main() { foo<int>(); }
diff --git a/gcc/testsuite/g++.dg/ipa/pr84658.C b/gcc/testsuite/g++.dg/ipa/pr84658.C
new file mode 100644
index 00000000000..6846e1832bd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr84658.C
@@ -0,0 +1,30 @@
+/* PR ipa/84658 */
+/* { dg-do run } */
+/* { dg-options "-O2 -fmerge-all-constants -std=c++11" } */
+
+const int kTestCasesFoo[] = { 0, 1, 2, 3, 4, 5, 8, 15, 16, 17, 512, 1020, 1021, 1022, 1023, 1024 };
+const int kTestCasesBar[] = { 0, 1, 2, 3, 4, 5, 8, 15, 16, 17, 512, 1020, 1021, 1022, 1023, 1024 };
+
+void Foo() {
+ __builtin_printf("foo:");
+ for (int count : kTestCasesFoo) {
+ __builtin_printf("%d,", count);
+ }
+ __builtin_printf(";\n");
+}
+
+void Bar() {
+ __builtin_printf("bar:");
+ for (int count : kTestCasesBar) {
+ __builtin_printf("%d,", count);
+ }
+ __builtin_printf(";\n");
+}
+
+int main() {
+ Foo();
+ Bar();
+}
+
+/* { dg-output "foo:0,1,2,3,4,5,8,15,16,17,512,1020,1021,1022,1023,1024,;(\n|\n\r|\r)*" } */
+/* { dg-output "bar:0,1,2,3,4,5,8,15,16,17,512,1020,1021,1022,1023,1024,;(\n|\n\r|\r)*" } */
diff --git a/gcc/testsuite/g++.dg/torture/pr85496.C b/gcc/testsuite/g++.dg/torture/pr85496.C
new file mode 100644
index 00000000000..3f504a37791
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr85496.C
@@ -0,0 +1,18 @@
+// PR middle-end/85496
+// Reported by Marek Polacek <mpolacek@gcc.gnu.org>
+
+template <typename> class complex;
+template <typename _Tp> complex<_Tp> operator*(complex<_Tp>, complex<_Tp>);
+template <> struct complex<float> { _Complex float _M_value; };
+class A {
+ complex<float> _f0, _f1;
+
+public:
+ complex<float> &m_fn1() { return _f1; }
+};
+complex<float> a;
+void cos() {
+ A b;
+ complex<float> c;
+ b.m_fn1() = c * a;
+}