From 3618b3754235d823cfd8c1e0d8f485df8ac9f10a Mon Sep 17 00:00:00 2001 From: Larisse Voufo Date: Wed, 28 Jan 2015 01:01:21 +0000 Subject: [PATCH] Re-arrange DR test cases, and update DR status page. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227279 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CXX/drs/dr14xx.cpp | 173 +++++++--------------------------------- test/CXX/drs/dr15xx.cpp | 83 +++++++++++++++++++ test/CXX/drs/dr16xx.cpp | 26 ++++++ test/CXX/drs/dr17xx.cpp | 34 ++++++++ www/cxx_dr_status.html | 12 +-- 5 files changed, 176 insertions(+), 152 deletions(-) create mode 100644 test/CXX/drs/dr17xx.cpp diff --git a/test/CXX/drs/dr14xx.cpp b/test/CXX/drs/dr14xx.cpp index bdab5eb0af..c4d5608ad9 100644 --- a/test/CXX/drs/dr14xx.cpp +++ b/test/CXX/drs/dr14xx.cpp @@ -199,129 +199,110 @@ namespace dr1460 { // dr1460: 3.5 #if __cplusplus >= 201103L namespace std { typedef decltype(sizeof(int)) size_t; - + // libc++'s implementation template class initializer_list { const _E* __begin_; size_t __size_; - + initializer_list(const _E* __b, size_t __s) - : __begin_(__b), - __size_(__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 struct basic_string { - basic_string(const T* x) {} - ~basic_string() {}; - }; - typedef basic_string string; - } // std -namespace dr1467 { // dr1467: yes c++11 +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}); @@ -332,113 +313,13 @@ namespace dr1467 { // dr1467: yes c++11 NonAggregate y{x}; NonAggregate z{{x}}; } - } // nonaggregate - } // dr1467 - -namespace dr1490 { // dr1490: yes c++11 +namespace dr1490 { // dr1490: 3.7 c++11 // List-initialization from a string literal char s[4]{"abc"}; // Ok std::initializer_list{"abc"}; // expected-error {{expected unqualified-id}}} - -} // dr1490 - -namespace dr1589 { // dr1589: yes 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); // #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); // #2 - void g1() { f1({42}); } // chooses #2 - - void f2(std::pair, int = 0); // Would makes selection of #3 ambiguous - void f2(std::pair); // #3 - void f2(std::initializer_list); // #4 - void g2() { f2({"foo","bar"}); } // chooses #4 - - namespace with_error { - - void f0(long); // #0 expected-note {{candidate function}} - void f0(std::initializer_list); // #00 expected-note {{candidate function}} - void f0(std::initializer_list, 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); // #2 expected-note {{candidate function}} - void f1(std::initializer_list, 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); // #3 TODO: expected- note {{candidate function}} - void f2(std::initializer_list); // #4 expected-note {{candidate function}} - void f2(std::initializer_list, 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 - - -namespace dr1631 { // dr1589: yes 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}}); - } - - 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 - -namespace dr1756 { // dr1490: yes c++11 - // Direct-list-initialization of a non-class object - - int a{0}; - - struct X { operator int(); } x; - int b{x}; -} - -namespace dr1758 { // dr1758: yes 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 - +} // dr190 #endif diff --git a/test/CXX/drs/dr15xx.cpp b/test/CXX/drs/dr15xx.cpp index d7c2b9225c..d35583ff9f 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 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 struct basic_string { + basic_string(const T* x) {} + ~basic_string() {}; + }; + typedef basic_string 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); // #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); // #2 + void g1() { f1({42}); } // chooses #2 + + void f2(std::pair, int = 0); // Would makes selection of #3 ambiguous + void f2(std::pair); // #3 + void f2(std::initializer_list); // #4 + void g2() { f2({"foo","bar"}); } // chooses #4 + + namespace with_error { + void f0(long); // #0 expected-note {{candidate function}} + void f0(std::initializer_list); // #00 expected-note {{candidate function}} + void f0(std::initializer_list, 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); // #2 expected-note {{candidate function}} + void f1(std::initializer_list, 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); // #3 TODO: expected- note {{candidate function}} + void f2(std::initializer_list); // #4 expected-note {{candidate function}} + void f2(std::initializer_list, 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 62040f1a13..cbbd0e9be6 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}}); + } + + 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/dr17xx.cpp b/test/CXX/drs/dr17xx.cpp new file mode 100644 index 0000000000..1ab8c40d39 --- /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/www/cxx_dr_status.html b/www/cxx_dr_status.html index ed066f3aa8..03afa35c92 100644 --- a/www/cxx_dr_status.html +++ b/www/cxx_dr_status.html @@ -8617,7 +8617,7 @@ and POD class 1467 DR List-initialization of aggregate from same-type object - Unknown + SVN (C++11 onwards) 1468 @@ -8755,7 +8755,7 @@ and POD class 1490 DR List-initialization from a string literal - Unknown + SVN (C++11 onwards) 1491 @@ -9349,7 +9349,7 @@ and POD class 1589 DR Ambiguous ranking of list-initialization sequences - Unknown + SVN (C++11 onwards) 1590 @@ -9601,7 +9601,7 @@ and POD class 1631 DR Incorrect overload resolution for single-element initializer-list - Unknown + SVN (C++11 onwards) 1632 @@ -10351,7 +10351,7 @@ and POD class 1756 DR Direct-list-initialization of a non-class object - Unknown + SVN (C++11 onwards) 1757 @@ -10363,7 +10363,7 @@ and POD class 1758 DR Explicit conversion in copy/move list initialization - Unknown + SVN (C++11 onwards) 1759 -- 2.40.0