summaryrefslogtreecommitdiffstats
path: root/test/CXX/drs
diff options
context:
space:
mode:
Diffstat (limited to 'test/CXX/drs')
-rw-r--r--test/CXX/drs/dr0xx.cpp6
-rw-r--r--test/CXX/drs/dr14xx.cpp148
-rw-r--r--test/CXX/drs/dr15xx.cpp83
-rw-r--r--test/CXX/drs/dr16xx.cpp26
-rw-r--r--test/CXX/drs/dr1748.cpp35
-rw-r--r--test/CXX/drs/dr17xx.cpp34
-rw-r--r--test/CXX/drs/dr19xx.cpp71
-rw-r--r--test/CXX/drs/dr2xx.cpp15
-rw-r--r--test/CXX/drs/dr3xx.cpp4
-rw-r--r--test/CXX/drs/dr412.cpp2
-rw-r--r--test/CXX/drs/dr4xx.cpp4
-rw-r--r--test/CXX/drs/dr7xx.cpp20
12 files changed, 435 insertions, 13 deletions
diff --git a/test/CXX/drs/dr0xx.cpp b/test/CXX/drs/dr0xx.cpp
index 5b34cc3..dd0d4d1 100644
--- a/test/CXX/drs/dr0xx.cpp
+++ b/test/CXX/drs/dr0xx.cpp
@@ -425,7 +425,7 @@ namespace dr39 { // dr39: no
using V::z;
float &z(float);
};
- struct C : A, B, virtual V {} c;
+ struct C : A, B, virtual V {} c; // expected-warning {{direct base 'dr39::example2::A' is inaccessible due to ambiguity:\n struct dr39::example2::C -> struct dr39::example2::A\n struct dr39::example2::C -> struct dr39::example2::B -> struct dr39::example2::A}}
int &x = c.x(0); // expected-error {{found in multiple base classes}}
// FIXME: This is valid, because we find the same static data member either way.
int &y = c.y(0); // expected-error {{found in multiple base classes}}
@@ -864,7 +864,7 @@ namespace dr77 { // dr77: yes
namespace dr78 { // dr78: sup ????
// Under DR78, this is valid, because 'k' has static storage duration, so is
// zero-initialized.
- const int k; // expected-error {{default initialization of an object of const}} expected-note{{add an explicit initializer to initialize 'k'}}
+ const int k; // expected-error {{default initialization of an object of const}}
}
// dr79: na
@@ -994,7 +994,7 @@ namespace dr91 { // dr91: yes
int k = f(U());
}
-namespace dr92 { // dr92: yes
+namespace dr92 { // FIXME: Issue is still open.
void f() throw(int, float);
void (*p)() throw(int) = &f; // expected-error {{target exception specification is not superset of source}}
void (*q)() throw(int);
diff --git a/test/CXX/drs/dr14xx.cpp b/test/CXX/drs/dr14xx.cpp
index e931924..9491f7d 100644
--- a/test/CXX/drs/dr14xx.cpp
+++ b/test/CXX/drs/dr14xx.cpp
@@ -195,3 +195,151 @@ namespace dr1460 { // dr1460: 3.5
}
#endif
}
+
+#if __cplusplus >= 201103L
+namespace std {
+ typedef decltype(sizeof(int)) size_t;
+
+ // libc++'s implementation
+ template <class _E>
+ class initializer_list
+ {
+ const _E* __begin_;
+ size_t __size_;
+
+ initializer_list(const _E* __b, size_t __s)
+ : __begin_(__b), __size_(__s) {}
+
+ public:
+ typedef _E value_type;
+ typedef const _E& reference;
+ typedef const _E& const_reference;
+ typedef size_t size_type;
+
+ typedef const _E* iterator;
+ typedef const _E* const_iterator;
+
+ initializer_list() : __begin_(nullptr), __size_(0) {}
+
+ size_t size() const {return __size_;}
+ const _E* begin() const {return __begin_;}
+ const _E* end() const {return __begin_ + __size_;}
+ };
+} // std
+
+namespace dr1467 { // dr1467: 3.7 c++11
+ // List-initialization of aggregate from same-type object
+
+ namespace basic0 {
+ struct S {
+ int i = 42;
+ };
+
+ S a;
+ S b(a);
+ S c{a};
+
+ struct SS : public S { } x;
+ S y(x);
+ S z{x};
+ } // basic0
+
+ namespace basic1 {
+ struct S {
+ int i{42};
+ };
+
+ S a;
+ S b(a);
+ S c{a};
+
+ struct SS : public S { } x;
+ S y(x);
+ S z{x};
+ } // basic1
+
+ namespace basic2 {
+ struct S {
+ int i = {42};
+ };
+
+ S a;
+ S b(a);
+ S c{a};
+
+ struct SS : public S { } x;
+ S y(x);
+ S z{x};
+ } // basic2
+
+ namespace dr_example {
+ struct OK {
+ OK() = default;
+ OK(const OK&) = default;
+ OK(int) { }
+ };
+
+ OK ok;
+ OK ok2{ok};
+
+ struct X {
+ X() = default;
+ X(const X&) = default;
+ };
+
+ X x;
+ X x2{x};
+ } // dr_example
+
+ namespace nonaggregate {
+ struct NonAggregate {
+ NonAggregate() {}
+ };
+
+ struct WantsIt {
+ WantsIt(NonAggregate);
+ };
+
+ void f(NonAggregate);
+ void f(WantsIt);
+
+ void test1() {
+ NonAggregate n;
+ f({n});
+ }
+
+ void test2() {
+ NonAggregate x;
+ NonAggregate y{x};
+ NonAggregate z{{x}};
+ }
+ } // nonaggregate
+
+ namespace SelfInitIsNotListInit {
+ struct S {
+ S();
+ explicit S(S &);
+ S(const S &);
+ };
+ S s1;
+ S s2 = {s1}; // ok, not list-initialization so we pick the non-explicit constructor
+ }
+
+ struct NestedInit { int a, b, c; };
+ NestedInit ni[1] = {{NestedInit{1, 2, 3}}};
+
+ namespace NestedInit2 {
+ struct Pair { int a, b; };
+ struct TwoPairs { TwoPairs(Pair, Pair); };
+ struct Value { Value(Pair); Value(TwoPairs); };
+ void f() { Value{{{1,2},{3,4}}}; }
+ }
+} // dr1467
+
+namespace dr1490 { // dr1490: 3.7 c++11
+ // List-initialization from a string literal
+
+ char s[4]{"abc"}; // Ok
+ std::initializer_list<char>{"abc"}; // expected-error {{expected unqualified-id}}}
+} // dr190
+#endif
diff --git a/test/CXX/drs/dr15xx.cpp b/test/CXX/drs/dr15xx.cpp
index d7c2b92..d35583f 100644
--- a/test/CXX/drs/dr15xx.cpp
+++ b/test/CXX/drs/dr15xx.cpp
@@ -3,7 +3,9 @@
// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+#if __cplusplus < 201103L
// expected-no-diagnostics
+#endif
namespace dr1550 { // dr1550: yes
int f(bool b, int n) {
@@ -19,3 +21,84 @@ namespace dr1560 { // dr1560: 3.5
const X &get();
const X &x = true ? get() : throw 0;
}
+
+#if __cplusplus >= 201103L
+namespace std {
+ typedef decltype(sizeof(int)) size_t;
+
+ // libc++'s implementation
+ template <class _E>
+ class initializer_list
+ {
+ const _E* __begin_;
+ size_t __size_;
+
+ initializer_list(const _E* __b, size_t __s)
+ : __begin_(__b), __size_(__s) {}
+
+ public:
+ typedef _E value_type;
+ typedef const _E& reference;
+ typedef const _E& const_reference;
+ typedef size_t size_type;
+
+ typedef const _E* iterator;
+ typedef const _E* const_iterator;
+
+ initializer_list() : __begin_(nullptr), __size_(0) {}
+
+ size_t size() const {return __size_;}
+ const _E* begin() const {return __begin_;}
+ const _E* end() const {return __begin_ + __size_;}
+ };
+
+ template < class _T1, class _T2 > struct pair { _T2 second; };
+
+ template<typename T> struct basic_string {
+ basic_string(const T* x) {}
+ ~basic_string() {};
+ };
+ typedef basic_string<char> string;
+
+} // std
+
+namespace dr1589 { // dr1589: 3.7 c++11
+ // Ambiguous ranking of list-initialization sequences
+
+ void f0(long, int=0); // Would makes selection of #0 ambiguous
+ void f0(long); // #0
+ void f0(std::initializer_list<int>); // #00
+ void g0() { f0({1L}); } // chooses #00
+
+ void f1(int, int=0); // Would make selection of #1 ambiguous
+ void f1(int); // #1
+ void f1(std::initializer_list<long>); // #2
+ void g1() { f1({42}); } // chooses #2
+
+ void f2(std::pair<const char*, const char*>, int = 0); // Would makes selection of #3 ambiguous
+ void f2(std::pair<const char*, const char*>); // #3
+ void f2(std::initializer_list<std::string>); // #4
+ void g2() { f2({"foo","bar"}); } // chooses #4
+
+ namespace with_error {
+ void f0(long); // #0 expected-note {{candidate function}}
+ void f0(std::initializer_list<int>); // #00 expected-note {{candidate function}}
+ void f0(std::initializer_list<int>, int = 0); // Makes selection of #00 ambiguous \
+ // expected-note {{candidate function}}
+ void g0() { f0({1L}); } // chooses #00 expected-error{{call to 'f0' is ambiguous}}
+
+ void f1(int); // #1 expected-note {{candidate function}}
+ void f1(std::initializer_list<long>); // #2 expected-note {{candidate function}}
+ void f1(std::initializer_list<long>, int = 0); // Makes selection of #00 ambiguous \
+ // expected-note {{candidate function}}
+ void g1() { f1({42}); } // chooses #2 expected-error{{call to 'f1' is ambiguous}}
+
+ void f2(std::pair<const char*, const char*>); // #3 TODO: expected- note {{candidate function}}
+ void f2(std::initializer_list<std::string>); // #4 expected-note {{candidate function}}
+ void f2(std::initializer_list<std::string>, int = 0); // Makes selection of #00 ambiguous \
+ // expected-note {{candidate function}}
+ void g2() { f2({"foo","bar"}); } // chooses #4 expected-error{{call to 'f2' is ambiguous}}
+ }
+
+} // dr1589
+#endif
diff --git a/test/CXX/drs/dr16xx.cpp b/test/CXX/drs/dr16xx.cpp
index 62040f1..ddb7d16 100644
--- a/test/CXX/drs/dr16xx.cpp
+++ b/test/CXX/drs/dr16xx.cpp
@@ -17,3 +17,29 @@ namespace dr1684 { // dr1684: 3.6
constexpr int f(NonLiteral) { return 0; } // expected-error {{not a literal type}}
#endif
}
+
+#if __cplusplus >= 201103L
+namespace dr1631 { // dr1631: 3.7 c++11
+ // Incorrect overload resolution for single-element initializer-list
+
+ struct A { int a[1]; };
+ struct B { B(int); };
+ void f(B, int);
+ void f(B, int, int = 0);
+ void f(int, A);
+
+ void test() {
+ f({0}, {{1}}); // expected-warning {{braces around scalar init}}
+ }
+
+ namespace with_error {
+ void f(B, int); // TODO: expected- note {{candidate function}}
+ void f(int, A); // expected-note {{candidate function}}
+ void f(int, A, int = 0); // expected-note {{candidate function}}
+
+ void test() {
+ f({0}, {{1}}); // expected-error{{call to 'f' is ambiguous}}
+ }
+ }
+} // dr1631
+#endif
diff --git a/test/CXX/drs/dr1748.cpp b/test/CXX/drs/dr1748.cpp
new file mode 100644
index 0000000..7e04f40
--- /dev/null
+++ b/test/CXX/drs/dr1748.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s
+// RUN: %clang_cc1 -std=c++1z %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s
+
+// dr1748: 3.7
+
+// FIXME: __SIZE_TYPE__ expands to 'long long' on some targets.
+__extension__ typedef __SIZE_TYPE__ size_t;
+
+void *operator new(size_t, void *);
+void *operator new[](size_t, void *);
+
+struct X { X(); };
+
+// The reserved placement allocation functions get inlined
+// even if we can't see their definitions. They do not
+// perform a null check.
+
+// CHECK-LABEL: define {{.*}} @_Z1fPv(
+// CHECK-NOT: call
+// CHECK-NOT: icmp{{.*}} null
+// CHECK-NOT: br i1
+// CHECK: call void @_ZN1XC1Ev(
+// CHECK: }
+X *f(void *p) { return new (p) X; }
+
+// CHECK-LABEL: define {{.*}} @_Z1gPv(
+// CHECK-NOT: call
+// CHECK-NOT: icmp{{.*}} null
+// CHECK-NOT: br i1
+// CHECK: call void @_ZN1XC1Ev(
+// CHECK: br i1
+// CHECK: }
+X *g(void *p) { return new (p) X[5]; }
diff --git a/test/CXX/drs/dr17xx.cpp b/test/CXX/drs/dr17xx.cpp
new file mode 100644
index 0000000..1ab8c40
--- /dev/null
+++ b/test/CXX/drs/dr17xx.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+
+// expected-no-diagnostics
+
+#if __cplusplus >= 201103L
+namespace dr1756 { // dr1756: 3.7 c++11
+ // Direct-list-initialization of a non-class object
+
+ int a{0};
+
+ struct X { operator int(); } x;
+ int b{x};
+} // dr1756
+
+namespace dr1758 { // dr1758: 3.7 c++11
+ // Explicit conversion in copy/move list initialization
+
+ struct X { X(); };
+ struct Y { explicit operator X(); } y;
+ X x{y};
+
+ struct A {
+ A() {}
+ A(const A &) {}
+ };
+ struct B {
+ operator A() { return A(); }
+ } b;
+ A a{b};
+} // dr1758
+#endif
diff --git a/test/CXX/drs/dr19xx.cpp b/test/CXX/drs/dr19xx.cpp
new file mode 100644
index 0000000..9c2d3e7
--- /dev/null
+++ b/test/CXX/drs/dr19xx.cpp
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+
+namespace std { struct type_info; }
+
+namespace dr1902 { // dr1902: 3.7
+ struct A {};
+ struct B {
+ B(A);
+#if __cplusplus >= 201103L
+ // expected-note@-2 {{candidate}}
+#endif
+
+ B() = delete;
+#if __cplusplus < 201103L
+ // expected-error@-2 {{extension}}
+#endif
+
+ B(const B&) // expected-note {{deleted here}}
+#if __cplusplus >= 201103L
+ // expected-note@-2 {{candidate}}
+#else
+ // expected-error@+2 {{extension}}
+#endif
+ = delete;
+
+ operator A();
+ };
+
+ extern B b1;
+ B b2(b1); // expected-error {{call to deleted}}
+
+#if __cplusplus >= 201103L
+ // This is ambiguous, even though calling the B(const B&) constructor would
+ // both directly and indirectly call a deleted function.
+ B b({}); // expected-error {{ambiguous}}
+#endif
+}
+
+#if __cplusplus >= 201103L
+namespace dr1940 { // dr1940: yes
+static union {
+ static_assert(true, ""); // ok
+ static_assert(false, ""); // expected-error {{static_assert failed}}
+};
+}
+#endif
+
+#if __cplusplus >= 201402L
+namespace dr1947 { // dr1947: yes
+unsigned o = 0'01; // ok
+unsigned b = 0b'01; // expected-error {{invalid digit 'b' in octal constant}}
+unsigned x = 0x'01; // expected-error {{invalid suffix 'x'01' on integer constant}}
+}
+#endif
+
+#if __cplusplus >= 201103L
+// dr1948: yes
+// FIXME: This diagnostic could be improved.
+void *operator new(__SIZE_TYPE__) noexcept { return nullptr; } // expected-error{{exception specification in declaration does not match previous declaration}}
+#endif
+
+#if __cplusplus >= 201103L
+namespace dr1968 { // dr1968: yes
+static_assert(&typeid(int) == &typeid(int), ""); // expected-error{{not an integral constant expression}}
+}
+#endif
+
+// dr1994: dup 529
diff --git a/test/CXX/drs/dr2xx.cpp b/test/CXX/drs/dr2xx.cpp
index bb1f13a..25c8535 100644
--- a/test/CXX/drs/dr2xx.cpp
+++ b/test/CXX/drs/dr2xx.cpp
@@ -999,15 +999,20 @@ namespace dr294 { // dr294: no
}
}
-namespace dr295 { // dr295: no
+namespace dr295 { // dr295: 3.7
typedef int f();
- // FIXME: This warning is incorrect.
- const f g; // expected-warning {{unspecified behavior}}
- const f &r = g; // expected-warning {{unspecified behavior}}
+ const f g; // expected-warning {{'const' qualifier on function type 'f' (aka 'int ()') has no effect}}
+ f &r = g;
template<typename T> struct X {
const T &f;
};
- X<f> x = {g}; // FIXME: expected-error {{drops qualifiers}}
+ X<f> x = {g};
+
+ typedef int U();
+ typedef const U U; // expected-warning {{'const' qualifier on function type 'U' (aka 'int ()') has no effect}}
+
+ typedef int (*V)();
+ typedef volatile U *V; // expected-warning {{'volatile' qualifier on function type 'U' (aka 'int ()') has no effect}}
}
namespace dr296 { // dr296: yes
diff --git a/test/CXX/drs/dr3xx.cpp b/test/CXX/drs/dr3xx.cpp
index cea4d64..5ac4f01 100644
--- a/test/CXX/drs/dr3xx.cpp
+++ b/test/CXX/drs/dr3xx.cpp
@@ -170,9 +170,9 @@ namespace dr308 { // dr308: yes
void f() {
try {
throw D();
- } catch (const A&) {
+ } catch (const A&) { // expected-note {{for type 'const dr308::A &'}}
// unreachable
- } catch (const B&) {
+ } catch (const B&) { // expected-warning {{exception of type 'const dr308::B &' will be caught by earlier handler}}
// get here instead
}
}
diff --git a/test/CXX/drs/dr412.cpp b/test/CXX/drs/dr412.cpp
index 39cdd61..27bc7e5 100644
--- a/test/CXX/drs/dr412.cpp
+++ b/test/CXX/drs/dr412.cpp
@@ -15,7 +15,7 @@ inline void* operator new(size_t) BAD_ALLOC; // expected-error {{cannot be decla
inline void* operator new[](size_t) BAD_ALLOC; // expected-error {{cannot be declared 'inline'}}
inline void operator delete(void*) NOEXCEPT; // expected-error {{cannot be declared 'inline'}}
inline void operator delete[](void*) NOEXCEPT; // expected-error {{cannot be declared 'inline'}}
-#if __cplusplus >= 201402L
+#ifdef __cpp_sized_deallocation
inline void operator delete(void*, size_t) NOEXCEPT; // expected-error {{cannot be declared 'inline'}}
inline void operator delete[](void*, size_t) NOEXCEPT; // expected-error {{cannot be declared 'inline'}}
#endif
diff --git a/test/CXX/drs/dr4xx.cpp b/test/CXX/drs/dr4xx.cpp
index 42c6774..bbe5ee6 100644
--- a/test/CXX/drs/dr4xx.cpp
+++ b/test/CXX/drs/dr4xx.cpp
@@ -1202,9 +1202,9 @@ namespace dr497 { // dr497: yes
struct S {
mutable int i;
};
- const S cs; // expected-error {{default initialization}} expected-note {{add an explicit initializer}}
+ const S cs; // expected-error {{default initialization}}
int S::*pm = &S::i;
- cs.*pm = 88;
+ cs.*pm = 88; // expected-error {{not assignable}}
}
void after() {
diff --git a/test/CXX/drs/dr7xx.cpp b/test/CXX/drs/dr7xx.cpp
new file mode 100644
index 0000000..fe4a2dc
--- /dev/null
+++ b/test/CXX/drs/dr7xx.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+
+namespace dr777 { // dr777: 3.7
+#if __cplusplus >= 201103L
+template <typename... T>
+void f(int i = 0, T ...args) {}
+void ff() { f(); }
+
+template <typename... T>
+void g(int i = 0, T ...args, T ...args2) {}
+
+template <typename... T>
+void h(int i = 0, T ...args, int j = 1) {}
+#endif
+}
+
+// expected-no-diagnostics
OpenPOWER on IntegriCloud