summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp0x')
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-105321.C18
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-array28.C21
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-fno-elide-ctors1.C89
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/decltype81.C15
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/friend7.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist-new6.C39
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist-nrv1.C34
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist129.C6
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-current-inst1.C18
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/pr105256.C18
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/ref-bind4.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/ref-bind8.C10
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/trailing15.C14
13 files changed, 284 insertions, 2 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-105321.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-105321.C
new file mode 100644
index 00000000000..adb6830ff22
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-105321.C
@@ -0,0 +1,18 @@
+// PR c++/105321
+// { dg-do compile { target c++11 } }
+
+bool handle_error();
+
+constexpr int echo(int value, bool yes = true) noexcept
+{
+ return (yes || handle_error()), value;
+}
+
+static_assert(echo(10) == 10, "");
+
+constexpr int echo2(int value, bool no = false) noexcept
+{
+ return (!no || handle_error()), value;
+}
+
+static_assert(echo2(10) == 10, "");
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array28.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array28.C
new file mode 100644
index 00000000000..d7706b9f0b4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array28.C
@@ -0,0 +1,21 @@
+// PR c++/105191
+// { dg-do compile { target c++11 } }
+
+struct A {
+ const char* message = "";
+};
+
+enum class B { };
+
+struct C {
+ A a;
+ B b;
+};
+
+struct D {
+ C cs[1];
+};
+
+constexpr D ds[4] = {
+ D{},
+};
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-fno-elide-ctors1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-fno-elide-ctors1.C
new file mode 100644
index 00000000000..71c76fa0247
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-fno-elide-ctors1.C
@@ -0,0 +1,89 @@
+// PR c++/104646
+// { dg-do compile { target c++11 } }
+// { dg-additional-options -fno-elide-constructors }
+
+template <typename _T1> struct pair {
+ _T1 first;
+ int second;
+};
+template <typename _Iterator> class __normal_iterator {
+ _Iterator __traits_type;
+
+public:
+ constexpr __normal_iterator() {}
+};
+template <typename> class allocator;
+template <typename> struct allocator_traits;
+template <typename _Tp> struct allocator_traits<allocator<_Tp>> {
+ using value_type = _Tp;
+ template <typename _Up> using rebind_alloc = allocator<_Up>;
+};
+template <typename _Alloc> struct __alloc_traits {
+ typedef allocator_traits<_Alloc> _Base_type;
+ typedef typename _Base_type::value_type &const_reference;
+ template <typename _Tp> struct rebind {
+ typedef typename _Base_type::template rebind_alloc<_Tp> other;
+ };
+};
+template <typename _Tp, typename _Alloc> struct _Vector_base {
+ typedef typename __alloc_traits<_Alloc>::template rebind<_Tp>::other _Tp_alloc_type;
+};
+template <typename _Tp, typename _Alloc = allocator<_Tp>> class vector {
+public:
+ typename __alloc_traits<
+ typename _Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_reference
+ operator[](long);
+};
+enum match_flag_type {};
+template <typename, typename> class Trans_NS___cxx11_basic_regex;
+class Trans_NS___cxx11_match_results;
+enum _RegexExecutorPolicy { _S_auto };
+template <typename, typename, typename _CharT, typename _TraitsT,
+ _RegexExecutorPolicy, bool>
+bool __regex_algo_impl(Trans_NS___cxx11_match_results &,
+ const Trans_NS___cxx11_basic_regex<_CharT, _TraitsT> &);
+template <typename, typename, typename, bool> class _Executor;
+template <typename _Ch_type, typename = _Ch_type>
+class Trans_NS___cxx11_basic_regex {};
+class Trans_NS___cxx11_match_results : vector<int> {
+ template <typename, typename, typename _Cp, typename _Rp,
+ _RegexExecutorPolicy, bool>
+ friend bool __regex_algo_impl(Trans_NS___cxx11_match_results &,
+ const Trans_NS___cxx11_basic_regex<_Cp, _Rp> &);
+};
+template <typename _Bi_iter, typename _Alloc, typename _Ch_type,
+ typename _Rx_traits>
+void regex_search(_Bi_iter, _Alloc,
+ Trans_NS___cxx11_basic_regex<_Ch_type, _Rx_traits>) {
+ __regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits, _S_auto, false>;
+}
+match_flag_type __regex_algo_impl___flags;
+template <typename, typename, typename _CharT, typename _TraitsT,
+ _RegexExecutorPolicy, bool>
+bool __regex_algo_impl(
+ Trans_NS___cxx11_match_results &__m,
+ const Trans_NS___cxx11_basic_regex<_CharT, _TraitsT> &__re) {
+ __normal_iterator<const char *> __e, __s;
+ _Executor<int, int, _TraitsT, false> __executor(__s, __e, __m, __re,
+ __regex_algo_impl___flags);
+ __executor._M_match();
+ return false;
+}
+template <typename, typename, typename, bool> class _Executor {
+public:
+ _Executor(__normal_iterator<const char *>, __normal_iterator<const char *>,
+ vector<int>, Trans_NS___cxx11_basic_regex<char>, match_flag_type);
+ void _M_match() { _M_dfs(); }
+ void _M_dfs();
+ vector<pair<__normal_iterator<char *>>> _M_rep_count;
+};
+long _M_rep_once_more___i;
+template <typename _BiIter, typename _Alloc, typename _TraitsT, bool __dfs_mode>
+void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>::_M_dfs() {
+ auto __rep_count = _M_rep_count[_M_rep_once_more___i];
+}
+char main___trans_tmp_1;
+void main___trans_tmp_2() {
+ Trans_NS___cxx11_basic_regex<char> re;
+ regex_search(main___trans_tmp_1, main___trans_tmp_2, re);
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype81.C b/gcc/testsuite/g++.dg/cpp0x/decltype81.C
new file mode 100644
index 00000000000..7d25db39d9c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/decltype81.C
@@ -0,0 +1,15 @@
+// PR c++/105386
+// { dg-do compile { target c++11 } }
+
+template<class T> struct NoInst {
+ static_assert(sizeof(T) == 9999, "NoInst instantiated");
+};
+
+template<class T> NoInst<T> f(T);
+
+template<class>
+struct A {
+ using type = decltype(f(0));
+};
+
+A<int> a;
diff --git a/gcc/testsuite/g++.dg/cpp0x/friend7.C b/gcc/testsuite/g++.dg/cpp0x/friend7.C
index e1d5f449f5c..4d0961c0397 100644
--- a/gcc/testsuite/g++.dg/cpp0x/friend7.C
+++ b/gcc/testsuite/g++.dg/cpp0x/friend7.C
@@ -21,7 +21,7 @@ struct S {
friend class __attribute__((deprecated)) N3;
[[deprecated]] friend void foo<>(int, int); // { dg-warning "attribute ignored" }
[[deprecated]] friend void ::foo(int, int); // { dg-warning "attribute ignored" }
- // { dg-bogus "should have" "PR100339" { xfail *-*-* } .-1 }
+ // { dg-bogus "should have" "PR100339" }
};
template<typename T>
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-new6.C b/gcc/testsuite/g++.dg/cpp0x/initlist-new6.C
new file mode 100644
index 00000000000..0ef27806acf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-new6.C
@@ -0,0 +1,39 @@
+// PR c++/105265
+// { dg-do run { target c++11 } }
+
+int c;
+
+class Block
+{
+public:
+ Block(int n) : data{new char[n]}, size{n}
+ {
+ ++c;
+ }
+
+ ~Block()
+ {
+ --c;
+ delete[] data;
+ }
+
+private:
+ char* data;
+ int size;
+};
+
+struct Cargo
+{
+ Block const& block;
+};
+
+int main()
+{
+ {
+ Cargo* c = new Cargo{{4000}};
+ delete c;
+ }
+ if (c != 0)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-nrv1.C b/gcc/testsuite/g++.dg/cpp0x/initlist-nrv1.C
new file mode 100644
index 00000000000..e44dbecfece
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-nrv1.C
@@ -0,0 +1,34 @@
+// PR c++/101442
+// { dg-do run { target c++11 } }
+
+bool destroyed = false;
+
+struct A
+{
+ A() {}
+ A(const A &) = delete;
+ A &operator=(const A &) = delete;
+ ~A() {destroyed = true;}
+};
+
+struct B
+{
+ const A &a;
+ struct string {
+ string(const char*) { }
+ ~string() { }
+ } s;
+};
+
+B foo()
+{
+ B ret{ A{}, "" };
+ return ret;
+}
+
+int main()
+{
+ B b = foo();
+ if (!destroyed)
+ __builtin_abort();
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist129.C b/gcc/testsuite/g++.dg/cpp0x/initlist129.C
new file mode 100644
index 00000000000..4d4faa9e08d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist129.C
@@ -0,0 +1,6 @@
+// PR c++/104996
+// { dg-do compile { target c++11 } }
+
+template<unsigned size> char f(int (&&)[size]);
+template<unsigned size> int f(int const (&)[size]);
+static_assert(sizeof(f({1, 2, 3})) == 1, "");
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-current-inst1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-current-inst1.C
new file mode 100644
index 00000000000..a6631c5ca99
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-current-inst1.C
@@ -0,0 +1,18 @@
+// PR c++/82980
+// { dg-do compile { target c++11 } }
+
+template <class T>
+struct Outer
+{
+ template <class U>
+ void f();
+
+ void bar(Outer outer) {
+ [outer](){ outer.f<int>(); };
+ }
+ void baz(Outer *p) {
+ [&](){ p->f<int>(); };
+ }
+};
+
+int main() { }
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr105256.C b/gcc/testsuite/g++.dg/cpp0x/pr105256.C
new file mode 100644
index 00000000000..98ce5e8b7bf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr105256.C
@@ -0,0 +1,18 @@
+// PR c++/105256
+// { dg-do compile { target c++11 } }
+
+int bar (int &);
+
+struct S {
+ struct T {
+ struct U {
+ int i = bar (i);
+ } u;
+ };
+};
+
+void
+foo (S::T *p)
+{
+ *p = {};
+};
diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-bind4.C b/gcc/testsuite/g++.dg/cpp0x/ref-bind4.C
index 85ac9fbfd79..d296d7c3b72 100644
--- a/gcc/testsuite/g++.dg/cpp0x/ref-bind4.C
+++ b/gcc/testsuite/g++.dg/cpp0x/ref-bind4.C
@@ -51,6 +51,6 @@ g (int *p, const int *pc, const int **q)
similar types T1 and T2 (_conv.qual_), respectively, and the cv-
qualification signature of type T1 is a proper subset of the cv-
qualification signature of type T2 */
- f8 (q);
+ f8 (q); // { dg-error "call of overloaded" }
f9 (q);
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-bind8.C b/gcc/testsuite/g++.dg/cpp0x/ref-bind8.C
new file mode 100644
index 00000000000..eee78fd5e74
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/ref-bind8.C
@@ -0,0 +1,10 @@
+// PR c++/97296
+// { dg-do compile }
+
+void f(const int * const &);
+void f(const int *);
+int *x;
+int main()
+{
+ f(x); // { dg-error "call of overloaded" }
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/trailing15.C b/gcc/testsuite/g++.dg/cpp0x/trailing15.C
new file mode 100644
index 00000000000..3fa74d08e39
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/trailing15.C
@@ -0,0 +1,14 @@
+// PR c++/101051
+// { dg-do compile { target c++11 } }
+
+template <class T>
+class Foo
+{
+ constexpr operator T() -> T {} // { dg-error "trailing return" }
+};
+
+struct S {
+ operator int() const -> double; // { dg-error "trailing return" }
+};
+
+class A { operator auto*() -> int; }; // { dg-error "auto|trailing return" }