[PATCH] D114576: [PR52549][clang-cl] Predefine _MSVC_EXECUTION_CHARACTER_SET

2021-11-25 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter accepted this revision.
CaseyCarter added a comment.

LGTM - thanks for the quick response!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114576/new/

https://reviews.llvm.org/D114576

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42225: libcxx: Provide overloads for basic_filebuf::open() et al that take wchar_t* filenames on Windows.

2021-09-24 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

In D42225#2963216 , @ldionne wrote:

> In D42225#2963190 , @mstorsjo wrote:
>
>> In D42225#2962348 , @ldionne wrote:
>>
>>> @pcc @mstorsjo Are we aware of anyone using these extensions?
>>>
>>> I would like to suggest that we either remove this extension if it's not 
>>> useful, or make it unconditional (not only on Windows) if we really think 
>>> it's that useful (but I'd like that to come with at least a paper proposing 
>>> to add them to the standard). Carrying around an extension that's only 
>>> enabled on one platform (and not the most widely used platform for libc++ 
>>> at that) is kind of awkward.
>>
>> This extension is fairly essential - without it, you can't interact with 
>> files that have names outside of the 8 bit charset on Windows (and exactly 
>> what the 8 bit charset is, can vary from system to system). I can't point to 
>> a specific user of it, but I'd expect there to be numerous out there.
>>
>> Making it universally available sounds like a sensible strategy forward - 
>> although I don't think I have the bandwidth to take on making it a standards 
>> proposal. Maybe someone from Microsoft (who invented this extension) can 
>> collaborate on it?
>
> @CaseyCarter Any appetite for that?

This isn't an extension for us. The Standard mandates overloads of 
`basic_filebuf::open`, `basic_ifstream::open`, `basic_ofstream::open`, and 
`basic_fstream::open`, as well as constructors for `basic_ifstream`, 
`basic_ofstream`, and `basic_fstream` that take `const 
filesystem::path::value_type*` which are "only be [sic] provided on systems 
where `filesystem::path::value_type` is not `char`." ([fstream.syn]/3) 
Unsurprisingly, `filesystem::path::value_type` for us is `wchar_t`. If you're 
supporting our mess of narrow character encodings, you may want to consider 
`wchar_t` for `filesystem::path` on Win32 as well. If you are only supporting 
UTF-8, I suppose you could instead transcode filenames to UTF-16 and use 
_wfopen?


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D42225/new/

https://reviews.llvm.org/D42225

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103155: [clang-cl] Add driver support for /std:c++20 and bump /std:c++latest (PR50465)

2021-05-26 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter accepted this revision.
CaseyCarter added a comment.

Looks great - thanks Hans!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103155/new/

https://reviews.llvm.org/D103155

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87459: [libcxx][test] ostream{,buf}_iterator::difference_type changes in C++20

2020-09-11 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter accepted this revision.
CaseyCarter added a comment.

LGTM!




Comment at: libcxx/include/iterator:1052
 class _LIBCPP_TEMPLATE_VIS ostream_iterator
 : public iterator
 {

`std::iterator` has been deprecated since C++17. Should this inheritance be 
dependent on `_LIBCPP_STD_VER < 17`? It's unnecessary now that the member types 
are defined directly. (Also on line 1161.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87459/new/

https://reviews.llvm.org/D87459

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87459: [libcxx][test] ostream{,buf}_iterator::difference_type changes in C++20

2020-09-10 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

> Ah, I see it. I'll add that bit to libc++ so we don't need special casing in 
> the tests.

Feel free to steal this for your test changes. Shall I close this differential 
then?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87459/new/

https://reviews.llvm.org/D87459

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87459: [libcxx][test] ostream{,buf}_iterator::difference_type changes in C++20

2020-09-10 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

In D87459#2265864 , @ldionne wrote:

> What paper is this? I searched but failed to find a paper this falls off from.

P0896R4 "The One Ranges Proposal" - Ranges demands that all iterators have 
useful difference types.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87459/new/

https://reviews.llvm.org/D87459

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87459: [libcxx][test] ostream{,buf}_iterator::difference_type changes in C++20

2020-09-10 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.
CaseyCarter added reviewers: ldionne, mclow.lists, EricWF.
Herald added subscribers: libcxx-commits, dexonsmith.
Herald added a project: libc++.
Herald added a reviewer: libc++.
CaseyCarter requested review of this revision.

Although libc++ doesn't yet implement this change, these tests should expect 
the difference type of `std::ostream_iterator` and `std::ostreambuf_iterator` 
specializations to be `std::ptrdiff_t` instead of `void` when testing C++ 
versions greater than 17 if the library under test is not libc++.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87459

Files:
  libcxx/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
  libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp


Index: 
libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
===
--- 
libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
+++ 
libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
@@ -19,6 +19,7 @@
 //   typedef basic_ostream   ostream_type;
 //   ...
 
+#include 
 #include 
 #include 
 #include 
@@ -34,7 +35,11 @@
 #else
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
+#if TEST_STD_VER <= 17 || defined(_LIBCPP_VERSION)
 static_assert((std::is_same::value), "");
+#else
+static_assert((std::is_same::value), 
"");
+#endif
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 #endif
@@ -50,7 +55,11 @@
 #else
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
+#if TEST_STD_VER <= 17 || defined(_LIBCPP_VERSION)
 static_assert((std::is_same::value), "");
+#else
+static_assert((std::is_same::value), 
"");
+#endif
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 #endif
Index: 
libcxx/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
===
--- libcxx/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
+++ libcxx/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
@@ -19,6 +19,7 @@
 // typedef basic_istream istream_type;
 // ...
 
+#include 
 #include 
 #include 
 
@@ -33,7 +34,11 @@
 #else
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
+#if TEST_STD_VER <= 17 || defined(_LIBCPP_VERSION)
 static_assert((std::is_same::value), "");
+#else
+static_assert((std::is_same::value), 
"");
+#endif
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 #endif
@@ -47,7 +52,11 @@
 #else
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
+#if TEST_STD_VER <= 17 || defined(_LIBCPP_VERSION)
 static_assert((std::is_same::value), "");
+#else
+static_assert((std::is_same::value), 
"");
+#endif
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 #endif


Index: libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
===
--- libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
+++ libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
@@ -19,6 +19,7 @@
 //   typedef basic_ostream   ostream_type;
 //   ...
 
+#include 
 #include 
 #include 
 #include 
@@ -34,7 +35,11 @@
 #else
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
+#if TEST_STD_VER <= 17 || defined(_LIBCPP_VERSION)
 static_assert((std::is_same::value), "");
+#else
+static_assert((std::is_same::value), "");
+#endif
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 #endif
@@ -50,7 +55,11 @@
 #else
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
+#if TEST_STD_VER <= 17 || defined(_LIBCPP_VERSION)
 static_assert((std::is_same::value), "");
+#else
+static_assert((std::is_same::value), "");
+#endif
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 #endif
Index: libcxx/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
===
--- libcxx/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
+++ libcxx/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
@@ -19,6 +19,7 @@
 // typedef basic_istream istream_type;
 // ...
 
+#include 
 #include 
 #include 
 
@@ -33,7 +34,11 @@
 #else
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
+#if TEST_STD_VER <= 17 || defined(_LIBCPP_VERSION)
 

[PATCH] D79343: [libc++][test] Adjust move_iterator tests to allow C++20

2020-05-07 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8615ce246d1c: [libc++][test] Adjust move_iterator tests to 
allow C++20 (authored by CaseyCarter).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79343/new/

https://reviews.llvm.org/D79343

Files:
  
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
  
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp


Index: 
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
===
--- 
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
+++ 
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
@@ -35,6 +35,8 @@
   typedef std::ptrdiff_t difference_type;
   typedef ValueType* pointer;
   typedef Reference reference;
+
+  Reference operator*() const;
 };
 
 template 
Index: 
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
===
--- 
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
+++ 
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
@@ -16,10 +16,20 @@
 
 #include 
 #include 
+#include 
 
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#if TEST_STD_VER > 17
+template 
+void test_single_pass(It i, It x) {
+  std::move_iterator r(std::move(i));
+  r++;
+  assert(std::move(r).base() == x);
+}
+#endif
+
 template 
 void
 test(It i, It x)
@@ -33,7 +43,11 @@
 int main(int, char**)
 {
 char s[] = "123";
+#if TEST_STD_VER > 17
+test_single_pass(input_iterator(s), input_iterator(s + 1));
+#else
 test(input_iterator(s), input_iterator(s+1));
+#endif
 test(forward_iterator(s), forward_iterator(s+1));
 test(bidirectional_iterator(s), bidirectional_iterator(s+1));
 test(random_access_iterator(s), random_access_iterator(s+1));


Index: libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
===
--- libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
+++ libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
@@ -35,6 +35,8 @@
   typedef std::ptrdiff_t difference_type;
   typedef ValueType* pointer;
   typedef Reference reference;
+
+  Reference operator*() const;
 };
 
 template 
Index: libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
===
--- libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
+++ libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
@@ -16,10 +16,20 @@
 
 #include 
 #include 
+#include 
 
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#if TEST_STD_VER > 17
+template 
+void test_single_pass(It i, It x) {
+  std::move_iterator r(std::move(i));
+  r++;
+  assert(std::move(r).base() == x);
+}
+#endif
+
 template 
 void
 test(It i, It x)
@@ -33,7 +43,11 @@
 int main(int, char**)
 {
 char s[] = "123";
+#if TEST_STD_VER > 17
+test_single_pass(input_iterator(s), input_iterator(s + 1));
+#else
 test(input_iterator(s), input_iterator(s+1));
+#endif
 test(forward_iterator(s), forward_iterator(s+1));
 test(bidirectional_iterator(s), bidirectional_iterator(s+1));
 test(random_access_iterator(s), random_access_iterator(s+1));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79343: [libc++][test] Adjust move_iterator tests to allow C++20

2020-05-07 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter marked an inline comment as done.
CaseyCarter added a comment.

In D79343#2025211 , @ldionne wrote:

> Regarding the formatting changes, I personally think we should clang-format 
> all of libc++, libc++abi and libunwind in one go. Then we'd be done with 
> these small issues that add up. And we can even add the revision to 
> `.git-blame-ignore-revs`.


I'm the furthest thing from a core libc++ maintainer, but FWIW I agree. I set 
up a `.git-blame-ignore-revs` for the MSVC internal git repo a week or two ago 
with our "clang-format the things" and "change all the line endings" commits 
and it has been a great experience.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79343/new/

https://reviews.llvm.org/D79343



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79343: [libc++][test] Adjust move_iterator tests to allow C++20

2020-05-06 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter marked 2 inline comments as done.
CaseyCarter added a comment.

Format issues addressed.




Comment at: 
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp:33
 struct DummyIt {
-  typedef std::forward_iterator_tag iterator_category;
-  typedef ValueType value_type;
-  typedef std::ptrdiff_t difference_type;
-  typedef ValueType* pointer;
-  typedef Reference reference;
+typedef std::forward_iterator_tag iterator_category;
+typedef ValueType value_type;

dexonsmith wrote:
> You seem to be changing from 2-space indent (the usual practice for LLVM) to 
> 4-space indent here.  I don't know if that's intentional, but if it's the 
> right thing to do please do so in a separate commit to avoid adding noise to 
> this patch.
Intentional - 4-space is the predominant indent in this file - but misguided. 
Thank you for the rundown of general formatting policy.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79343/new/

https://reviews.llvm.org/D79343



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79343: [libc++][test] Adjust move_iterator tests to allow C++20

2020-05-06 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 262494.
CaseyCarter added a comment.

clang-format new/changed sections of code per policy.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79343/new/

https://reviews.llvm.org/D79343

Files:
  
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
  
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp


Index: 
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
===
--- 
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
+++ 
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
@@ -35,6 +35,8 @@
   typedef std::ptrdiff_t difference_type;
   typedef ValueType* pointer;
   typedef Reference reference;
+
+  Reference operator*() const;
 };
 
 template 
Index: 
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
===
--- 
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
+++ 
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
@@ -16,10 +16,20 @@
 
 #include 
 #include 
+#include 
 
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#if TEST_STD_VER > 17
+template 
+void test_single_pass(It i, It x) {
+  std::move_iterator r(std::move(i));
+  r++;
+  assert(std::move(r).base() == x);
+}
+#endif
+
 template 
 void
 test(It i, It x)
@@ -33,7 +43,11 @@
 int main(int, char**)
 {
 char s[] = "123";
+#if TEST_STD_VER > 17
+test_single_pass(input_iterator(s), input_iterator(s + 1));
+#else
 test(input_iterator(s), input_iterator(s+1));
+#endif
 test(forward_iterator(s), forward_iterator(s+1));
 test(bidirectional_iterator(s), bidirectional_iterator(s+1));
 test(random_access_iterator(s), random_access_iterator(s+1));


Index: libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
===
--- libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
+++ libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
@@ -35,6 +35,8 @@
   typedef std::ptrdiff_t difference_type;
   typedef ValueType* pointer;
   typedef Reference reference;
+
+  Reference operator*() const;
 };
 
 template 
Index: libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
===
--- libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
+++ libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
@@ -16,10 +16,20 @@
 
 #include 
 #include 
+#include 
 
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#if TEST_STD_VER > 17
+template 
+void test_single_pass(It i, It x) {
+  std::move_iterator r(std::move(i));
+  r++;
+  assert(std::move(r).base() == x);
+}
+#endif
+
 template 
 void
 test(It i, It x)
@@ -33,7 +43,11 @@
 int main(int, char**)
 {
 char s[] = "123";
+#if TEST_STD_VER > 17
+test_single_pass(input_iterator(s), input_iterator(s + 1));
+#else
 test(input_iterator(s), input_iterator(s+1));
+#endif
 test(forward_iterator(s), forward_iterator(s+1));
 test(bidirectional_iterator(s), bidirectional_iterator(s+1));
 test(random_access_iterator(s), random_access_iterator(s+1));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79343: [libc++][test] Adjust move_iterator tests to allow C++20

2020-05-06 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

I'm not going to reformat *only* my additions per the clang-format instructions 
- that would be silly - and I suspect that folks would clang-format all of the 
tests if they actually wanted them formatted, so I won't format the entire 
file, either.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79343/new/

https://reviews.llvm.org/D79343



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79343: [libc++][test] Adjust move_iterator tests to allow C++20

2020-05-04 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.
CaseyCarter added reviewers: ldionne, EricWF, mclow.lists.
Herald added subscribers: libcxx-commits, broadwaylamb, dexonsmith.
Herald added a project: libc++.
Herald added a reviewer: libc++.

These tests fail due to a couple of changes to `move_iterator` for C++20:

1. `move_iterator::operator++(int)` returns `void` in C++20 if `I` doesn't 
model `forward_iterator`.
2. `move_iterator::reference` is calculated in C++20, so `I` must actually 
have an `operator*() const`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79343

Files:
  
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
  
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp


Index: 
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
===
--- 
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
+++ 
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
@@ -30,11 +30,13 @@
 
 template 
 struct DummyIt {
-  typedef std::forward_iterator_tag iterator_category;
-  typedef ValueType value_type;
-  typedef std::ptrdiff_t difference_type;
-  typedef ValueType* pointer;
-  typedef Reference reference;
+typedef std::forward_iterator_tag iterator_category;
+typedef ValueType value_type;
+typedef std::ptrdiff_t difference_type;
+typedef ValueType* pointer;
+typedef Reference reference;
+
+Reference operator*() const;
 };
 
 template 
@@ -92,5 +94,5 @@
 }
 #endif
 
-  return 0;
+return 0;
 }
Index: 
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
===
--- 
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
+++ 
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
@@ -16,10 +16,22 @@
 
 #include 
 #include 
+#include 
 
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#if TEST_STD_VER > 17
+template 
+void
+test_single_pass(It i, It x)
+{
+std::move_iterator r(std::move(i));
+r++;
+assert(std::move(r).base() == x);
+}
+#endif
+
 template 
 void
 test(It i, It x)
@@ -33,7 +45,11 @@
 int main(int, char**)
 {
 char s[] = "123";
+#if TEST_STD_VER > 17
+test_single_pass(input_iterator(s), input_iterator(s+1));
+#else
 test(input_iterator(s), input_iterator(s+1));
+#endif
 test(forward_iterator(s), forward_iterator(s+1));
 test(bidirectional_iterator(s), bidirectional_iterator(s+1));
 test(random_access_iterator(s), random_access_iterator(s+1));
@@ -52,5 +68,5 @@
 }
 #endif
 
-  return 0;
+return 0;
 }


Index: libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
===
--- libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
+++ libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
@@ -30,11 +30,13 @@
 
 template 
 struct DummyIt {
-  typedef std::forward_iterator_tag iterator_category;
-  typedef ValueType value_type;
-  typedef std::ptrdiff_t difference_type;
-  typedef ValueType* pointer;
-  typedef Reference reference;
+typedef std::forward_iterator_tag iterator_category;
+typedef ValueType value_type;
+typedef std::ptrdiff_t difference_type;
+typedef ValueType* pointer;
+typedef Reference reference;
+
+Reference operator*() const;
 };
 
 template 
@@ -92,5 +94,5 @@
 }
 #endif
 
-  return 0;
+return 0;
 }
Index: libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
===
--- libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
+++ libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
@@ -16,10 +16,22 @@
 
 #include 
 #include 
+#include 
 
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#if TEST_STD_VER > 17
+template 
+void
+test_single_pass(It i, It x)
+{
+std::move_iterator r(std::move(i));
+r++;
+assert(std::move(r).base() == x);
+}
+#endif
+
 template 
 void
 test(It i, It x)
@@ -33,7 +45,11 @@
 int main(int, char**)
 {
 char s[] = "123";
+#if TEST_STD_VER > 17
+test_single_pass(input_iterator(s), input_iterator(s+1));
+#else
 test(input_iterator(s), input_iterator(s+1));
+#endif
 test(forward_iterator(s), forward_iterator(s+1));
 test(bidirectional_iterator(s), bidirectional_iterator(s+1));
 test(random_access_iterator(s), random_access_iterator(s+1));
@@ -52,5 +68,5 @@
 }
 #endif
 
-  return 0;

[PATCH] D78944: [libc++][test] Disable test for extension that's unsupportable in C++20

2020-04-27 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb4437992ecce: [libc++][test] Disable test for extension 
thats unsupportable in C++20 (authored by CaseyCarter).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78944/new/

https://reviews.llvm.org/D78944

Files:
  libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
  
libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp


Index: 
libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
===
--- 
libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
+++ 
libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
@@ -21,12 +21,11 @@
 std::multimap m;
 std::multimap::iterator i;
 std::multimap::const_iterator ci;
+#if TEST_STD_VER <= 17
+// These reverse_iterator specializations require X to be complete in 
C++20.
 std::multimap::reverse_iterator ri;
 std::multimap::const_reverse_iterator cri;
+#endif // TEST_STD_VER <= 17
 };
 
-int main(int, char**)
-{
-
-  return 0;
-}
+int main(int, char**) { return 0; }
Index: 
libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
===
--- 
libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
+++ 
libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
@@ -21,12 +21,11 @@
 std::map m;
 std::map::iterator i;
 std::map::const_iterator ci;
+#if TEST_STD_VER <= 17
+// These reverse_iterator specializations require X to be complete in 
C++20.
 std::map::reverse_iterator ri;
 std::map::const_reverse_iterator cri;
+#endif // TEST_STD_VER <= 17
 };
 
-int main(int, char**)
-{
-
-  return 0;
-}
+int main(int, char**) { return 0; }


Index: libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
===
--- libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
+++ libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
@@ -21,12 +21,11 @@
 std::multimap m;
 std::multimap::iterator i;
 std::multimap::const_iterator ci;
+#if TEST_STD_VER <= 17
+// These reverse_iterator specializations require X to be complete in C++20.
 std::multimap::reverse_iterator ri;
 std::multimap::const_reverse_iterator cri;
+#endif // TEST_STD_VER <= 17
 };
 
-int main(int, char**)
-{
-
-  return 0;
-}
+int main(int, char**) { return 0; }
Index: libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
===
--- libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
+++ libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
@@ -21,12 +21,11 @@
 std::map m;
 std::map::iterator i;
 std::map::const_iterator ci;
+#if TEST_STD_VER <= 17
+// These reverse_iterator specializations require X to be complete in C++20.
 std::map::reverse_iterator ri;
 std::map::const_reverse_iterator cri;
+#endif // TEST_STD_VER <= 17
 };
 
-int main(int, char**)
-{
-
-  return 0;
-}
+int main(int, char**) { return 0; }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78944: [libc++][test] Disable test for extension that's unsupportable in C++20

2020-04-27 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 260391.
CaseyCarter added a comment.

Review comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78944/new/

https://reviews.llvm.org/D78944

Files:
  libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
  
libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp


Index: 
libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
===
--- 
libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
+++ 
libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
@@ -21,12 +21,11 @@
 std::multimap m;
 std::multimap::iterator i;
 std::multimap::const_iterator ci;
+#if TEST_STD_VER <= 17
+// These reverse_iterator specializations require X to be complete in 
C++20.
 std::multimap::reverse_iterator ri;
 std::multimap::const_reverse_iterator cri;
+#endif // TEST_STD_VER <= 17
 };
 
-int main(int, char**)
-{
-
-  return 0;
-}
+int main(int, char**) { return 0; }
Index: 
libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
===
--- 
libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
+++ 
libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
@@ -21,12 +21,11 @@
 std::map m;
 std::map::iterator i;
 std::map::const_iterator ci;
+#if TEST_STD_VER <= 17
+// These reverse_iterator specializations require X to be complete in 
C++20.
 std::map::reverse_iterator ri;
 std::map::const_reverse_iterator cri;
+#endif // TEST_STD_VER <= 17
 };
 
-int main(int, char**)
-{
-
-  return 0;
-}
+int main(int, char**) { return 0; }


Index: libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
===
--- libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
+++ libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
@@ -21,12 +21,11 @@
 std::multimap m;
 std::multimap::iterator i;
 std::multimap::const_iterator ci;
+#if TEST_STD_VER <= 17
+// These reverse_iterator specializations require X to be complete in C++20.
 std::multimap::reverse_iterator ri;
 std::multimap::const_reverse_iterator cri;
+#endif // TEST_STD_VER <= 17
 };
 
-int main(int, char**)
-{
-
-  return 0;
-}
+int main(int, char**) { return 0; }
Index: libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
===
--- libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
+++ libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
@@ -21,12 +21,11 @@
 std::map m;
 std::map::iterator i;
 std::map::const_iterator ci;
+#if TEST_STD_VER <= 17
+// These reverse_iterator specializations require X to be complete in C++20.
 std::map::reverse_iterator ri;
 std::map::const_reverse_iterator cri;
+#endif // TEST_STD_VER <= 17
 };
 
-int main(int, char**)
-{
-
-  return 0;
-}
+int main(int, char**) { return 0; }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78944: [libc++][test] Disable test for extension that's unsupportable in C++20

2020-04-27 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.
CaseyCarter added reviewers: ldionne, EricWF, mclow.lists.
Herald added subscribers: libcxx-commits, broadwaylamb, dexonsmith.
Herald added a project: libc++.
Herald added a reviewer: libc++.

Defining the nested types `reference` and `iterator_concept` of 
`reverse_iterator` necessarily requires `I` to be complete in C++20. These 
tests that verify that `std::map::reverse_iterator` can be instantiated 
when `X` is incomplete are going to have a bad time.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78944

Files:
  libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
  
libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp


Index: 
libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
===
--- 
libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
+++ 
libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
@@ -21,12 +21,13 @@
 std::multimap m;
 std::multimap::iterator i;
 std::multimap::const_iterator ci;
+#if TEST_STD_VER <= 17
 std::multimap::reverse_iterator ri;
 std::multimap::const_reverse_iterator cri;
+#endif // TEST_STD_VER <= 17
 };
 
 int main(int, char**)
 {
-
-  return 0;
+return 0;
 }
Index: 
libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
===
--- 
libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
+++ 
libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
@@ -21,12 +21,13 @@
 std::map m;
 std::map::iterator i;
 std::map::const_iterator ci;
+#if TEST_STD_VER <= 17
 std::map::reverse_iterator ri;
 std::map::const_reverse_iterator cri;
+#endif // TEST_STD_VER <= 17
 };
 
 int main(int, char**)
 {
-
-  return 0;
+return 0;
 }


Index: libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
===
--- libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
+++ libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
@@ -21,12 +21,13 @@
 std::multimap m;
 std::multimap::iterator i;
 std::multimap::const_iterator ci;
+#if TEST_STD_VER <= 17
 std::multimap::reverse_iterator ri;
 std::multimap::const_reverse_iterator cri;
+#endif // TEST_STD_VER <= 17
 };
 
 int main(int, char**)
 {
-
-  return 0;
+return 0;
 }
Index: libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
===
--- libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
+++ libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
@@ -21,12 +21,13 @@
 std::map m;
 std::map::iterator i;
 std::map::const_iterator ci;
+#if TEST_STD_VER <= 17
 std::map::reverse_iterator ri;
 std::map::const_reverse_iterator cri;
+#endif // TEST_STD_VER <= 17
 };
 
 int main(int, char**)
 {
-
-  return 0;
+return 0;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70099: [libcxx][test] Only call valarray::min and ::max on empty containers when testing libc++

2020-01-29 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter abandoned this revision.
CaseyCarter added a subscriber: STL_MSFT.
CaseyCarter added a comment.

@STL_MSFT seems to have already fixed this by removing the problem test cases 
in bf7dc572f199007cbe042d5ea41bcf873dcedd8f 
. I'll 
simply abandon this change.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70099/new/

https://reviews.llvm.org/D70099



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70099: [libcxx][test] Only call valarray::min and ::max on empty containers when testing libc++

2019-11-11 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.
CaseyCarter added reviewers: mclow.lists, EricWF, ldionne.
Herald added a subscriber: dexonsmith.

`valarray:min` and `valarray::max` have preconditions that require the 
`valarray` to be non-empty, so these calls are inherently non-portable.


https://reviews.llvm.org/D70099

Files:
  test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp
  test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp


Index: 
test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp
===
--- test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp
+++ test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp
@@ -26,11 +26,13 @@
 std::valarray v1(a1, N1);
 assert(v1.min() == -3.0);
 }
+#ifdef _LIBCPP_VERSION // Not portable: valarray::min requires size() >
 {
 typedef double T;
 std::valarray v1;
 v1.min();
 }
+#endif // _LIBCPP_VERSION
 {
 typedef double T;
 T a1[] = {1.5, 2.5, -3, 4, 5.5};
@@ -39,5 +41,5 @@
 assert((2*v1).min() == -6.0);
 }
 
-  return 0;
+return 0;
 }
Index: 
test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp
===
--- test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp
+++ test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp
@@ -26,11 +26,13 @@
 std::valarray v1(a1, N1);
 assert(v1.max() == 4.0);
 }
+#ifdef _LIBCPP_VERSION // Not portable: valarray::max requires size() > 0
 {
 typedef double T;
 std::valarray v1;
 v1.max();
 }
+#endif // _LIBCPP_VERSION
 {
 typedef double T;
 T a1[] = {1.5, 2.5, -3, 4, -5.5};
@@ -39,5 +41,5 @@
 assert((2*v1).max() == 8.0);
 }
 
-  return 0;
+return 0;
 }


Index: test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp
===
--- test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp
+++ test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp
@@ -26,11 +26,13 @@
 std::valarray v1(a1, N1);
 assert(v1.min() == -3.0);
 }
+#ifdef _LIBCPP_VERSION // Not portable: valarray::min requires size() >
 {
 typedef double T;
 std::valarray v1;
 v1.min();
 }
+#endif // _LIBCPP_VERSION
 {
 typedef double T;
 T a1[] = {1.5, 2.5, -3, 4, 5.5};
@@ -39,5 +41,5 @@
 assert((2*v1).min() == -6.0);
 }
 
-  return 0;
+return 0;
 }
Index: test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp
===
--- test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp
+++ test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp
@@ -26,11 +26,13 @@
 std::valarray v1(a1, N1);
 assert(v1.max() == 4.0);
 }
+#ifdef _LIBCPP_VERSION // Not portable: valarray::max requires size() > 0
 {
 typedef double T;
 std::valarray v1;
 v1.max();
 }
+#endif // _LIBCPP_VERSION
 {
 typedef double T;
 T a1[] = {1.5, 2.5, -3, 4, -5.5};
@@ -39,5 +41,5 @@
 assert((2*v1).max() == 8.0);
 }
 
-  return 0;
+return 0;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68947: [libc++][test] Add license headers to test/support/archetypes.*

2019-10-14 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc86ba5818833: [libc++][test] Add license headers to 
test/support/archetypes.* (authored by CaseyCarter).
Herald added subscribers: libcxx-commits, christof.
Herald added a project: libc++.

Changed prior to commit:
  https://reviews.llvm.org/D68947?vs=224867=224878#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68947/new/

https://reviews.llvm.org/D68947

Files:
  libcxx/test/support/archetypes.h
  libcxx/test/support/archetypes.ipp


Index: libcxx/test/support/archetypes.ipp
===
--- libcxx/test/support/archetypes.ipp
+++ libcxx/test/support/archetypes.ipp
@@ -1,3 +1,10 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
 
 #ifndef DEFINE_BASE
 #define DEFINE_BASE(Name) ::ArchetypeBases::NullBase
Index: libcxx/test/support/archetypes.h
===
--- libcxx/test/support/archetypes.h
+++ libcxx/test/support/archetypes.h
@@ -1,3 +1,11 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
 #ifndef TEST_SUPPORT_ARCHETYPES_H
 #define TEST_SUPPORT_ARCHETYPES_H
 


Index: libcxx/test/support/archetypes.ipp
===
--- libcxx/test/support/archetypes.ipp
+++ libcxx/test/support/archetypes.ipp
@@ -1,3 +1,10 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
 
 #ifndef DEFINE_BASE
 #define DEFINE_BASE(Name) ::ArchetypeBases::NullBase
Index: libcxx/test/support/archetypes.h
===
--- libcxx/test/support/archetypes.h
+++ libcxx/test/support/archetypes.h
@@ -1,3 +1,11 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
 #ifndef TEST_SUPPORT_ARCHETYPES_H
 #define TEST_SUPPORT_ARCHETYPES_H
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68947: [libc++][test] Add license headers to test/support/archetypes.*

2019-10-14 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.
CaseyCarter added reviewers: mclow.lists, EricWF, ldionne.
Herald added a subscriber: dexonsmith.

These two files (`archetypes.h` and `archetypes.ipp`) are missing license 
headers.


https://reviews.llvm.org/D68947

Files:
  test/support/archetypes.h
  test/support/archetypes.ipp


Index: test/support/archetypes.ipp
===
--- test/support/archetypes.ipp
+++ test/support/archetypes.ipp
@@ -1,3 +1,10 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
 
 #ifndef DEFINE_BASE
 #define DEFINE_BASE(Name) ::ArchetypeBases::NullBase
Index: test/support/archetypes.h
===
--- test/support/archetypes.h
+++ test/support/archetypes.h
@@ -1,3 +1,11 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
 #ifndef TEST_SUPPORT_ARCHETYPES_H
 #define TEST_SUPPORT_ARCHETYPES_H
 


Index: test/support/archetypes.ipp
===
--- test/support/archetypes.ipp
+++ test/support/archetypes.ipp
@@ -1,3 +1,10 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
 
 #ifndef DEFINE_BASE
 #define DEFINE_BASE(Name) ::ArchetypeBases::NullBase
Index: test/support/archetypes.h
===
--- test/support/archetypes.h
+++ test/support/archetypes.h
@@ -1,3 +1,11 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
 #ifndef TEST_SUPPORT_ARCHETYPES_H
 #define TEST_SUPPORT_ARCHETYPES_H
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68756: [libc++][test] Change IsSmallObject's calculation for std::any's small object buffer

2019-10-10 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGffc83995de6d: [libc++][test] Change IsSmallObjects 
calculation for std::anys small object… (authored by CaseyCarter).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68756/new/

https://reviews.llvm.org/D68756

Files:
  libcxx/test/support/any_helpers.h


Index: libcxx/test/support/any_helpers.h
===
--- libcxx/test/support/any_helpers.h
+++ libcxx/test/support/any_helpers.h
@@ -26,7 +26,7 @@
 template 
   struct IsSmallObject
 : public std::integral_constant::value
  % std::alignment_of::value == 0
   && std::is_nothrow_move_constructible::value


Index: libcxx/test/support/any_helpers.h
===
--- libcxx/test/support/any_helpers.h
+++ libcxx/test/support/any_helpers.h
@@ -26,7 +26,7 @@
 template 
   struct IsSmallObject
 : public std::integral_constant::value
  % std::alignment_of::value == 0
   && std::is_nothrow_move_constructible::value
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68756: [libc++][test] Change IsSmallObject's calculation for std::any's small object buffer

2019-10-09 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter marked an inline comment as done.
CaseyCarter added inline comments.



Comment at: libcxx/test/support/any_helpers.h:24
 : public std::integral_constant::value

I have no idea why this line is highlighted: there are no changes on this line 
in the diff I submitted, the line endings are plain LF, ... :shrug:


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68756/new/

https://reviews.llvm.org/D68756



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68756: [libc++][test] Change IsSmallObject's calculation for std::any's small object buffer

2019-10-09 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.
CaseyCarter added reviewers: mclow.lists, EricWF, ldionne.
CaseyCarter added a project: libc++.
Herald added subscribers: libcxx-commits, dexonsmith, christof.

`sizeof(std::any) - sizeof(void*)` is correct for both libc++ and the MSVC 
standard library.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68756

Files:
  libcxx/test/support/any_helpers.h


Index: libcxx/test/support/any_helpers.h
===
--- libcxx/test/support/any_helpers.h
+++ libcxx/test/support/any_helpers.h
@@ -26,13 +26,13 @@
 template 
   struct IsSmallObject
 : public std::integral_constant::value
  % std::alignment_of::value == 0
   && std::is_nothrow_move_constructible::value
 >
   {};

 template 
 bool containsType(std::any const& a) {
 #if !defined(TEST_HAS_NO_RTTI)


Index: libcxx/test/support/any_helpers.h
===
--- libcxx/test/support/any_helpers.h
+++ libcxx/test/support/any_helpers.h
@@ -26,13 +26,13 @@
 template 
   struct IsSmallObject
 : public std::integral_constant::value
  % std::alignment_of::value == 0
   && std::is_nothrow_move_constructible::value
 >
   {};

 template 
 bool containsType(std::any const& a) {
 #if !defined(TEST_HAS_NO_RTTI)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68681: [libc++][test] Miscellaneous MSVC cleanups

2019-10-09 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

In D68681#1702194 , @ldionne wrote:

> You have commit access, right? If so, go ahead. Otherwise, LMK and I can 
> commit this for you.


Yes, I apparently still have commit access ;) Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68681/new/

https://reviews.llvm.org/D68681



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68681: [libc++][test] Miscellaneous MSVC cleanups

2019-10-09 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb2e3c83b0d64: [libc++][test] Miscellaneous MSVC cleanups 
(authored by CaseyCarter).
Herald added a subscriber: christof.
Herald added a project: libc++.

Changed prior to commit:
  https://reviews.llvm.org/D68681?vs=224092=224190#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68681/new/

https://reviews.llvm.org/D68681

Files:
  
libcxx/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp
  
libcxx/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp
  libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/deduct.pass.cpp
  
libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/deduct.pass.cpp
  libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/deduct.pass.cpp
  libcxx/test/std/numerics/c.math/abs.pass.cpp
  
libcxx/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp
  
libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp

Index: libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
===
--- libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
+++ libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
@@ -42,7 +42,7 @@
 ASSERT_SAME_TYPE(Expected, typename std::underlying_type::type);
 #if TEST_STD_VER > 11
 ASSERT_SAME_TYPE(Expected, typename std::underlying_type_t);
-#endif  
+#endif
 }
 
 enum E { V = INT_MIN };
@@ -79,7 +79,9 @@
 //  SFINAE-able underlying_type
 #if TEST_STD_VER > 17
 static_assert( has_type_member::value, "");
+#ifdef TEST_UNSIGNED_UNDERLYING_TYPE
 static_assert( has_type_member::value, "");
+#endif // TEST_UNSIGNED_UNDERLYING_TYPE
 static_assert( has_type_member::value, "");
 
 static_assert(!has_type_member::value, "");
Index: libcxx/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp
===
--- libcxx/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp
+++ libcxx/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp
@@ -41,7 +41,7 @@
 
 constexpr T maxV = std::numeric_limits::max();
 constexpr T minV = std::numeric_limits::min();
-
+
 //  Things that can be compared exactly
 static_assert((std::midpoint(T(0), T(0))   == T(0)),   "");
 static_assert((std::midpoint(T(2), T(4))   == T(3)),   "");
@@ -58,7 +58,7 @@
 assert((fptest_close_pct(std::midpoint(T(0.1),  T(0.4)),  T(0.25), pct)));
 
 assert((fptest_close_pct(std::midpoint(T(11.2345), T(14.5432)), T(12.5),  pct)));
-
+
 //  From e to pi
 assert((fptest_close_pct(std::midpoint(T(2.71828182845904523536028747135266249775724709369995),
   T(3.14159265358979323846264338327950288419716939937510)),
@@ -86,7 +86,7 @@
 //  TODO
 
 //  Check two values "close to each other"
-T d1 = 3.14;
+T d1 = T(3.14);
 T d0 = std::nextafter(d1, T(2));
 T d2 = std::nextafter(d1, T(5));
 assert(d0 < d1);  // sanity checking
Index: libcxx/test/std/numerics/c.math/abs.pass.cpp
===
--- libcxx/test/std/numerics/c.math/abs.pass.cpp
+++ libcxx/test/std/numerics/c.math/abs.pass.cpp
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "test_macros.h"
@@ -75,4 +76,3 @@
 
 return 0;
 }
-
Index: libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/deduct.pass.cpp
===
--- libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/deduct.pass.cpp
+++ libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/deduct.pass.cpp
@@ -78,37 +78,37 @@
 
 {
 const int arr[] = { 1, 2, 1, INT_MAX, 3 };
-std::unordered_set s(std::begin(arr), std::end(arr), 42, std::hash());
+std::unordered_set s(std::begin(arr), std::end(arr), 42, std::hash());
 
-ASSERT_SAME_TYPE(decltype(s), std::unordered_set>);
+ASSERT_SAME_TYPE(decltype(s), std::unordered_set>);
 assert(std::is_permutation(s.begin(), s.end(), std::begin(expected_s), std::end(expected_s)));
 }
 
 {
 const int arr[] = { 1, 2, 1, INT_MAX, 3 };
-std::unordered_set s(std::begin(arr), std::end(arr), 42, std::hash(), test_allocator(0, 40));
+std::unordered_set s(std::begin(arr), std::end(arr), 42, std::hash(), test_allocator(0, 40));
 
-ASSERT_SAME_TYPE(decltype(s), std::unordered_set, std::equal_to, test_allocator>);
+ASSERT_SAME_TYPE(decltype(s), std::unordered_set, std::equal_to, test_allocator>);
 assert(std::is_permutation(s.begin(), s.end(), std::begin(expected_s), std::end(expected_s)));
 assert(s.get_allocator().get_id() == 

[PATCH] D68681: [libc++][test] Miscellaneous MSVC cleanups

2019-10-09 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 224092.
CaseyCarter edited the summary of this revision.
CaseyCarter added a comment.

Avoid rather than suppress truncation warnings in `unordered_meow` deduction 
guide tests.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68681/new/

https://reviews.llvm.org/D68681

Files:
  test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp
  test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp
  test/std/containers/unord/unord.map/unord.map.cnstr/deduct.pass.cpp
  test/std/containers/unord/unord.multiset/unord.multiset.cnstr/deduct.pass.cpp
  test/std/containers/unord/unord.set/unord.set.cnstr/deduct.pass.cpp
  test/std/numerics/c.math/abs.pass.cpp
  test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp
  test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp

Index: test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
===
--- test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
+++ test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
@@ -42,7 +42,7 @@
 ASSERT_SAME_TYPE(Expected, typename std::underlying_type::type);
 #if TEST_STD_VER > 11
 ASSERT_SAME_TYPE(Expected, typename std::underlying_type_t);
-#endif  
+#endif
 }
 
 enum E { V = INT_MIN };
@@ -79,7 +79,9 @@
 //  SFINAE-able underlying_type
 #if TEST_STD_VER > 17
 static_assert( has_type_member::value, "");
+#ifdef TEST_UNSIGNED_UNDERLYING_TYPE
 static_assert( has_type_member::value, "");
+#endif // TEST_UNSIGNED_UNDERLYING_TYPE
 static_assert( has_type_member::value, "");
 
 static_assert(!has_type_member::value, "");
Index: test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp
===
--- test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp
+++ test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp
@@ -41,7 +41,7 @@
 
 constexpr T maxV = std::numeric_limits::max();
 constexpr T minV = std::numeric_limits::min();
-
+
 //  Things that can be compared exactly
 static_assert((std::midpoint(T(0), T(0))   == T(0)),   "");
 static_assert((std::midpoint(T(2), T(4))   == T(3)),   "");
@@ -58,7 +58,7 @@
 assert((fptest_close_pct(std::midpoint(T(0.1),  T(0.4)),  T(0.25), pct)));
 
 assert((fptest_close_pct(std::midpoint(T(11.2345), T(14.5432)), T(12.5),  pct)));
-
+
 //  From e to pi
 assert((fptest_close_pct(std::midpoint(T(2.71828182845904523536028747135266249775724709369995),
   T(3.14159265358979323846264338327950288419716939937510)),
@@ -86,7 +86,7 @@
 //  TODO
 
 //  Check two values "close to each other"
-T d1 = 3.14;
+T d1 = T(3.14);
 T d0 = std::nextafter(d1, T(2));
 T d2 = std::nextafter(d1, T(5));
 assert(d0 < d1);  // sanity checking
Index: test/std/numerics/c.math/abs.pass.cpp
===
--- test/std/numerics/c.math/abs.pass.cpp
+++ test/std/numerics/c.math/abs.pass.cpp
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "test_macros.h"
@@ -75,4 +76,3 @@
 
 return 0;
 }
-
Index: test/std/containers/unord/unord.set/unord.set.cnstr/deduct.pass.cpp
===
--- test/std/containers/unord/unord.set/unord.set.cnstr/deduct.pass.cpp
+++ test/std/containers/unord/unord.set/unord.set.cnstr/deduct.pass.cpp
@@ -78,37 +78,37 @@
 
 {
 const int arr[] = { 1, 2, 1, INT_MAX, 3 };
-std::unordered_set s(std::begin(arr), std::end(arr), 42, std::hash());
+std::unordered_set s(std::begin(arr), std::end(arr), 42, std::hash());
 
-ASSERT_SAME_TYPE(decltype(s), std::unordered_set>);
+ASSERT_SAME_TYPE(decltype(s), std::unordered_set>);
 assert(std::is_permutation(s.begin(), s.end(), std::begin(expected_s), std::end(expected_s)));
 }
 
 {
 const int arr[] = { 1, 2, 1, INT_MAX, 3 };
-std::unordered_set s(std::begin(arr), std::end(arr), 42, std::hash(), test_allocator(0, 40));
+std::unordered_set s(std::begin(arr), std::end(arr), 42, std::hash(), test_allocator(0, 40));
 
-ASSERT_SAME_TYPE(decltype(s), std::unordered_set, std::equal_to, test_allocator>);
+ASSERT_SAME_TYPE(decltype(s), std::unordered_set, std::equal_to, test_allocator>);
 assert(std::is_permutation(s.begin(), s.end(), std::begin(expected_s), std::end(expected_s)));
 assert(s.get_allocator().get_id() == 40);
 }
 
 {
-std::unordered_set, std::equal_to<>, test_allocator> source;
+std::unordered_set, std::equal_to<>, test_allocator> source;
 std::unordered_set s(source);
 ASSERT_SAME_TYPE(decltype(s), decltype(source));
 assert(s.size() == 0);
 }
 
 {
-

[PATCH] D68681: [libc++][test] Miscellaneous MSVC cleanups

2019-10-09 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added inline comments.



Comment at: 
test/std/containers/unord/unord.map/unord.map.cnstr/deduct.pass.cpp:70
+#pragma warning(disable: 4244) // '%s': conversion from '%s' to '%s', possible 
loss of data
+#endif // TEST_COMPILER_C1XX
+

Quuxplusone wrote:
> Alternatively, if you wanted to change the instances of `hash` to 
> `hash<>`, that would be fine with me. (Just as long as it's something 
> distinguishable from the default of `hash`.)
I do like the idea of avoiding rather than suppressing the warning. I'll change 
these tests to use `hash` instead of `hash`, which avoids 
truncating conversions and preserves the "neither `int` nor `long`" property 
which provides some assurance the deduction guides aren't getting the type from 
the key type or mapped type.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68681/new/

https://reviews.llvm.org/D68681



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68681: [libc++][test] Miscellaneous MSVC cleanups

2019-10-08 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.
CaseyCarter added reviewers: mclow.lists, EricWF, ldionne.
Herald added a subscriber: dexonsmith.

- Silence unused-local-typedef warnings: 
`map.cons/assign_initializer_list.pass.cpp` (and the `set.cons` variant) uses a 
local typedef only within `LIBCPP_ASSERT`s, so clang diagnoses it as unused 
when testing non-libc++.

- Add missing include: `c.math/abs.pass.cpp` uses `std::numeric_limits` but 
failed to `#include `.

- Don't test non-type: A "recent" change to 
`meta.trans.other/underlying_type.pass.cpp` unconditionally tests the type `F` 
which is conditionally defined.

- Silence truncation warnings: A few deduction guide tests use 
`unordered_meow>` which triggers sirens and claxons (as 
it should). `midpoint.float.pass` uses `float meow = 3.14;`, which triggers 
bogus truncation warnings.


https://reviews.llvm.org/D68681

Files:
  test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp
  test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp
  test/std/containers/unord/unord.map/unord.map.cnstr/deduct.pass.cpp
  test/std/containers/unord/unord.multiset/unord.multiset.cnstr/deduct.pass.cpp
  test/std/containers/unord/unord.set/unord.set.cnstr/deduct.pass.cpp
  test/std/numerics/c.math/abs.pass.cpp
  test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp
  test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp

Index: test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
===
--- test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
+++ test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
@@ -42,7 +42,7 @@
 ASSERT_SAME_TYPE(Expected, typename std::underlying_type::type);
 #if TEST_STD_VER > 11
 ASSERT_SAME_TYPE(Expected, typename std::underlying_type_t);
-#endif  
+#endif
 }
 
 enum E { V = INT_MIN };
@@ -79,7 +79,9 @@
 //  SFINAE-able underlying_type
 #if TEST_STD_VER > 17
 static_assert( has_type_member::value, "");
+#ifdef TEST_UNSIGNED_UNDERLYING_TYPE
 static_assert( has_type_member::value, "");
+#endif // TEST_UNSIGNED_UNDERLYING_TYPE
 static_assert( has_type_member::value, "");
 
 static_assert(!has_type_member::value, "");
Index: test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp
===
--- test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp
+++ test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp
@@ -41,7 +41,7 @@
 
 constexpr T maxV = std::numeric_limits::max();
 constexpr T minV = std::numeric_limits::min();
-
+
 //  Things that can be compared exactly
 static_assert((std::midpoint(T(0), T(0))   == T(0)),   "");
 static_assert((std::midpoint(T(2), T(4))   == T(3)),   "");
@@ -58,7 +58,7 @@
 assert((fptest_close_pct(std::midpoint(T(0.1),  T(0.4)),  T(0.25), pct)));
 
 assert((fptest_close_pct(std::midpoint(T(11.2345), T(14.5432)), T(12.5),  pct)));
-
+
 //  From e to pi
 assert((fptest_close_pct(std::midpoint(T(2.71828182845904523536028747135266249775724709369995),
   T(3.14159265358979323846264338327950288419716939937510)),
@@ -86,7 +86,7 @@
 //  TODO
 
 //  Check two values "close to each other"
-T d1 = 3.14;
+T d1 = T(3.14);
 T d0 = std::nextafter(d1, T(2));
 T d2 = std::nextafter(d1, T(5));
 assert(d0 < d1);  // sanity checking
Index: test/std/numerics/c.math/abs.pass.cpp
===
--- test/std/numerics/c.math/abs.pass.cpp
+++ test/std/numerics/c.math/abs.pass.cpp
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "test_macros.h"
@@ -75,4 +76,3 @@
 
 return 0;
 }
-
Index: test/std/containers/unord/unord.set/unord.set.cnstr/deduct.pass.cpp
===
--- test/std/containers/unord/unord.set/unord.set.cnstr/deduct.pass.cpp
+++ test/std/containers/unord/unord.set/unord.set.cnstr/deduct.pass.cpp
@@ -56,6 +56,11 @@
 
 #include "test_allocator.h"
 
+#ifdef TEST_COMPILER_C1XX
+#pragma warning(disable: 4242) // '%s': conversion from '%s' to '%s', possible loss of data
+#pragma warning(disable: 4244) // '%s': conversion from '%s' to '%s', possible loss of data
+#endif // TEST_COMPILER_C1XX
+
 int main(int, char**)
 {
 const int expected_s[] = {1, 2, 3, INT_MAX};
Index: test/std/containers/unord/unord.multiset/unord.multiset.cnstr/deduct.pass.cpp
===
--- test/std/containers/unord/unord.multiset/unord.multiset.cnstr/deduct.pass.cpp
+++ test/std/containers/unord/unord.multiset/unord.multiset.cnstr/deduct.pass.cpp
@@ -56,6 +56,11 @@
 
 #include "test_allocator.h"
 
+#ifdef 

[PATCH] D61365: [libcxx] [test] Suppress float->int narrowing warning in vector range-construction test.

2019-10-08 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added inline comments.



Comment at: 
test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp:159
 float array[3] = {0.0f, 1.0f, 2.0f};
+#pragma warning(suppress: 4244) // narrowing float to int
 std::vector v(array, array + 3);

CaseyCarter wrote:
> BillyONeal wrote:
> > CaseyCarter wrote:
> > > This will blow up non-MSVC-ish when running the test suite with `-Wall -W 
> > > -Werror` (which is typical). I suggest wrapping in `#ifdef _MSC_VER`.
> > Why didn't it blow up on Contest then? clang-cl is happy with it?
> clang-cl is the "ish" in my "MSVC-ish" (MSVC and compilers emulating MSVC). 
> GCC and clang-without-`-fms-compatibility` when compiling with `-Wall` warn 
> about unrecognized pragmas, just as does cl in default mode 
> (https://godbolt.org/z/Chue0L).
Correction: Wrap with `#ifdef TEST_COMPILER_C1XX` instead of `#ifdef _MSC_VER`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61365/new/

https://reviews.llvm.org/D61365



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61365: [libcxx] [test] Suppress float->int narrowing warning in vector range-construction test.

2019-05-07 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added inline comments.



Comment at: 
test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp:159
 float array[3] = {0.0f, 1.0f, 2.0f};
+#pragma warning(suppress: 4244) // narrowing float to int
 std::vector v(array, array + 3);

BillyONeal wrote:
> CaseyCarter wrote:
> > This will blow up non-MSVC-ish when running the test suite with `-Wall -W 
> > -Werror` (which is typical). I suggest wrapping in `#ifdef _MSC_VER`.
> Why didn't it blow up on Contest then? clang-cl is happy with it?
clang-cl is the "ish" in my "MSVC-ish" (MSVC and compilers emulating MSVC). GCC 
and clang-without-`-fms-compatibility` when compiling with `-Wall` warn about 
unrecognized pragmas, just as does cl in default mode 
(https://godbolt.org/z/Chue0L).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61365/new/

https://reviews.llvm.org/D61365



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61365: [libcxx] [test] Suppress float->int narrowing warning in vector range-construction test.

2019-05-03 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added inline comments.



Comment at: 
test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp:159
 float array[3] = {0.0f, 1.0f, 2.0f};
+#pragma warning(suppress: 4244) // narrowing float to int
 std::vector v(array, array + 3);

This will blow up non-MSVC-ish when running the test suite with `-Wall -W 
-Werror` (which is typical). I suggest wrapping in `#ifdef _MSC_VER`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61365/new/

https://reviews.llvm.org/D61365



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50860: [libc++][test] Remove non-portable assumption that thread's constructor allocates with ::new

2019-05-02 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX359827: [libc++][test] Remove non-portable assumption that 
threads constructor… (authored by CaseyCarter, committed by ).
Herald added subscribers: libcxx-commits, jfb, ldionne.

Changed prior to commit:
  https://reviews.llvm.org/D50860?vs=171344=197868#toc

Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50860/new/

https://reviews.llvm.org/D50860

Files:
  
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp


Index: 
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
===
--- 
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
+++ 
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
@@ -30,9 +30,10 @@
 
 void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
 {
-if (throw_one == 0)
-TEST_THROW(std::bad_alloc());
---throw_one;
+unsigned expected = throw_one;
+do {
+if (expected == 0) TEST_THROW(std::bad_alloc());
+} while (!throw_one.compare_exchange_weak(expected, expected - 1));
 ++outstanding_new;
 void* ret = std::malloc(s);
 if (!ret) std::abort(); // placate MSVC's unchecked malloc warning
@@ -41,6 +42,7 @@
 
 void  operator delete(void* p) TEST_NOEXCEPT
 {
+if (!p) return;
 --outstanding_new;
 std::free(p);
 }
@@ -108,13 +110,17 @@
 //  B std::thread's constructor should properly handle exceptions and not leak
 //memory.
 // Plan:
-//  1 Create a thread and count the number of allocations, 'N', it performs.
+//  1 Create a thread and count the number of allocations, 'numAllocs', it
+//performs.
 //  2 For each allocation performed run a test where that allocation throws.
 //2.1 check that the exception can be caught in the parent thread.
 //2.2 Check that the functor has not been called.
 //2.3 Check that no memory allocated by the creation of the thread is 
leaked.
-//  3 Finally check that a thread runs successfully if we throw after 'N+1'
-//allocations.
+//  3 Finally check that a thread runs successfully if we throw after
+//'numAllocs + 1' allocations.
+
+int numAllocs;
+
 void test_throwing_new_during_thread_creation() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 throw_one = 0xFFF;
@@ -122,7 +128,7 @@
 std::thread t(f);
 t.join();
 }
-const int numAllocs = 0xFFF - throw_one;
+numAllocs = 0xFFF - throw_one;
 // i <= numAllocs means the last iteration is expected not to throw.
 for (int i=0; i <= numAllocs; ++i) {
 throw_one = i;
@@ -166,7 +172,10 @@
 }
 G::op_run = false;
 #ifndef TEST_HAS_NO_EXCEPTIONS
-{
+// The test below expects `std::thread` to call `new`, which may not be the
+// case for all implementations.
+LIBCPP_ASSERT(numAllocs > 0); // libc++ should call new.
+if (numAllocs > 0) {
 try
 {
 throw_one = 0;
@@ -175,7 +184,7 @@
 std::thread t((G()));
 assert(false);
 }
-catch (...)
+catch (std::bad_alloc const&)
 {
 throw_one = 0x;
 assert(G::n_alive == 0);
@@ -201,5 +210,5 @@
 }
 #endif
 
-  return 0;
+return 0;
 }


Index: test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
===
--- test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
+++ test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
@@ -30,9 +30,10 @@
 
 void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
 {
-if (throw_one == 0)
-TEST_THROW(std::bad_alloc());
---throw_one;
+unsigned expected = throw_one;
+do {
+if (expected == 0) TEST_THROW(std::bad_alloc());
+} while (!throw_one.compare_exchange_weak(expected, expected - 1));
 ++outstanding_new;
 void* ret = std::malloc(s);
 if (!ret) std::abort(); // placate MSVC's unchecked malloc warning
@@ -41,6 +42,7 @@
 
 void  operator delete(void* p) TEST_NOEXCEPT
 {
+if (!p) return;
 --outstanding_new;
 std::free(p);
 }
@@ -108,13 +110,17 @@
 //  B std::thread's constructor should properly handle exceptions and not leak
 //memory.
 // Plan:
-//  1 Create a thread and count the number of allocations, 'N', it performs.
+//  1 Create a thread and count the number of allocations, 'numAllocs', it
+//performs.
 //  2 For each allocation performed run a test where that allocation throws.
 //2.1 check that the exception can be caught in the parent thread.
 //2.2 Check that the functor has not been called.
 //2.3 Check that no memory allocated by the creation of the thread is leaked.
-//  3 Finally check that a thread runs successfully if we throw 

[PATCH] D50860: [libc++][test] Remove non-portable assumption that thread's constructor allocates with ::new

2019-04-21 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

Ping?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50860/new/

https://reviews.llvm.org/D50860



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60023: [libcxx] [test] Fix inability to rebind poca_alloc in string.cons/copy_alloc.pass.cpp.

2019-04-01 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter requested changes to this revision.
CaseyCarter added inline comments.
This revision now requires changes to proceed.



Comment at: test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp:128
+// but the standard only requires the basic guarantee:
+_LIBCXX_ASSERT(s1 == p1);
+s1.clear(); // under the basic guarantee, s1 must still be a valid string 
object.

`LIBCPP_ASSERT(s1 == p1)` (NB: no leading underscore) in test code.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60023/new/

https://reviews.llvm.org/D60023



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46140: [coroutines] Add std::experimental::task type

2019-03-27 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter requested changes to this revision.
CaseyCarter added a subscriber: mclow.lists.
CaseyCarter added inline comments.
This revision now requires changes to proceed.



Comment at: include/experimental/__memory:80
+{
+return (__s + __a - 1) & ~(__a - 1);
+}

This is missing preconditions that `__a` is a power of 2, and that `__s <=  
-__a`.



Comment at: include/experimental/task:141
+
+void* __pointer = __charAllocator.allocate(
+__get_padded_frame_size_with_allocator<_CharAlloc>(__size));

The return value of `allocate` isn't necessarily convertible to `void*`, it 
could be a fancy pointer. We should either `static_assert(is_same_v::void_pointer, void*>, "Piss off with your fancy 
pointers");` or use `pointer_traits` here and in `__deallocFunc` to unfancy and 
re-fancy the pointer.



Comment at: include/experimental/task:210
+private:
+  friend struct __task_promise_final_awaitable;
+

Pure style comment: I recommend using the non-elaborated `friend 
__task_promise_final_awaitable;` whenever possible. `friend struct foo` 
declares or redeclares `struct foo` in the enclosing namespace, whereas `friend 
foo` uses name lookup to find `foo` and makes it a friend. The latter form 
makes it far easier to analyze compiler errors when you screw something up in 
maintenance. (And on 480)



Comment at: include/experimental/task:220
+public:
+  __task_promise() _NOEXCEPT : __state_(_State::__no_value) {}
+

This mem-initializer for `__state_` is redundant with the default member 
initializer on 306.



Comment at: include/experimental/task:227
+  break;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+case _State::__exception:

I suggest moving the `case` label and `break` outside the `#ifndef` here so the 
compiler won't warn about this case being unhandled when 
`_LIBCPP_NO_EXCEPTIONS`.



Comment at: include/experimental/task:244
+exception_ptr(current_exception());
+__state_ = _State::__exception;
+#else

Are you certain that `unhandled_exception` can't possibly be called after 
storing a value? If so, this would leak the value.



Comment at: include/experimental/task:254
+  template ::value, int> = 0>
+  void return_value(_Value&& __value)

Style: you've been using the `_v` variable templates for traits elsewhere.



Comment at: include/experimental/task:261
+  template 
+  auto return_value(std::initializer_list<_Value> __initializer) _NOEXCEPT_(
+  (is_nothrow_constructible_v<_Tp, std::initializer_list<_Value>>))

Unnecessary `std::` qualifier. (Occurs repeatedly.)



Comment at: include/experimental/task:263
+  (is_nothrow_constructible_v<_Tp, std::initializer_list<_Value>>))
+  -> std::enable_if_t<
+  std::is_constructible_v<_Tp, std::initializer_list<_Value>>> {

Style: the use of trailing-return-type SFINAE here is inconsistent with the use 
of template parameter SFINAE on 254.



Comment at: include/experimental/task:308
+  union {
+char __empty_;
+_Tp __value_;

These `__empty_` members seem extraneous. 



Comment at: include/experimental/task:309
+char __empty_;
+_Tp __value_;
+exception_ptr __exception_;

Should we `static_assert` that `_Tp` is a destructible object type?



Comment at: include/experimental/task:373
+template <>
+class __task_promise final : public __task_promise_base {
+  using _Handle = coroutine_handle<__task_promise>;

Do we care about `task`?



Comment at: include/experimental/task:389
+
+  void __rvalue_result() { __throw_if_exception(); }
+

Should these `__foovalue_result` members be `foo`-qualified to make them harder 
to misuse?



Comment at: include/experimental/task:407
+  using promise_type = __task_promise<_Tp>;
+
+private:

Similar to above, should we `static_assert` that `_Tp` is `void`, an lvalue 
reference type, or a destructible non-array object type?



Comment at: include/experimental/task:453
+  decltype(auto) await_resume() {
+return this->__coro_.promise().__lvalue_result();
+  }

`this->` is extraneous in these classes that derive from the concrete 
`_AwaiterBase`. (And on 470)



Comment at: include/experimental/task:458
+_LIBCPP_ASSERT(__coro_,
+   "Undefined behaviour to co_await an invalid task");
+return _Awaiter{__coro_};

Is missing a subject. How about "co_await on an invalid task has undefined 
behavior"? (And on 475)



Comment at: include/experimental/task:28
+#if defined(_LIBCPP_WARNING)
+_LIBCPP_WARNING(" cannot be 

[PATCH] D53763: [libc++] [test] Fix logic error in tests; enable for MSVC previews

2019-01-14 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter closed this revision.
CaseyCarter added a comment.

I merged this as r351148.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53763/new/

https://reviews.llvm.org/D53763



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53763: [libc++] [test] Fix logic error in tests; enable for MSVC previews

2019-01-14 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

In D53763#1356356 , @mclow.lists wrote:

> I'm a bit concerned about the `TEST_HAS_NO_SPACESHIP_OPERATOR` and how it 
> tracks with `_LIBCPP_HAS_NO_SPACESHIP_OPERATOR`, but I'm not going to hold 
> this up for that.


Same. I tried to convince the compiler guys to define a feature-test macro, but 
they're paranoid about doing so before it's in the standard. We can clean this 
up when that happens.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53763/new/

https://reviews.llvm.org/D53763



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50860: [libc++][test] Remove non-portable assumption that thread's constructor allocates with ::new

2018-10-26 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 171344.
CaseyCarter added a comment.

Clarify use of `numAllocs`.


https://reviews.llvm.org/D50860

Files:
  
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp


Index: 
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
===
--- 
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
+++ 
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
@@ -31,17 +31,19 @@
 
 void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
 {
-if (throw_one == 0)
-TEST_THROW(std::bad_alloc());
---throw_one;
+unsigned expected = throw_one;
+do {
+if (expected == 0) TEST_THROW(std::bad_alloc());
+} while (!throw_one.compare_exchange_weak(expected, expected - 1));
 ++outstanding_new;
 void* ret = std::malloc(s);
 if (!ret) std::abort(); // placate MSVC's unchecked malloc warning
 return ret;
 }
 
 void  operator delete(void* p) TEST_NOEXCEPT
 {
+if (!p) return;
 --outstanding_new;
 std::free(p);
 }
@@ -109,21 +111,23 @@
 //  B std::thread's constructor should properly handle exceptions and not leak
 //memory.
 // Plan:
-//  1 Create a thread and count the number of allocations, 'N', it performs.
+//  1 Create a thread and count the number of allocations, 'numAllocs', it 
performs.
 //  2 For each allocation performed run a test where that allocation throws.
 //2.1 check that the exception can be caught in the parent thread.
 //2.2 Check that the functor has not been called.
 //2.3 Check that no memory allocated by the creation of the thread is 
leaked.
-//  3 Finally check that a thread runs successfully if we throw after 'N+1'
+//  3 Finally check that a thread runs successfully if we throw after 
'numAllocs+1'
 //allocations.
+int numAllocs;
+
 void test_throwing_new_during_thread_creation() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 throw_one = 0xFFF;
 {
 std::thread t(f);
 t.join();
 }
-const int numAllocs = 0xFFF - throw_one;
+numAllocs = 0xFFF - throw_one;
 // i <= numAllocs means the last iteration is expected not to throw.
 for (int i=0; i <= numAllocs; ++i) {
 throw_one = i;
@@ -167,16 +171,16 @@
 }
 G::op_run = false;
 #ifndef TEST_HAS_NO_EXCEPTIONS
-{
+if (numAllocs > 0) { // Creating a thread might not call new at all.
 try
 {
 throw_one = 0;
 assert(G::n_alive == 0);
 assert(!G::op_run);
 std::thread t((G()));
 assert(false);
 }
-catch (...)
+catch (std::bad_alloc const&)
 {
 throw_one = 0x;
 assert(G::n_alive == 0);


Index: test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
===
--- test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
+++ test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
@@ -31,17 +31,19 @@
 
 void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
 {
-if (throw_one == 0)
-TEST_THROW(std::bad_alloc());
---throw_one;
+unsigned expected = throw_one;
+do {
+if (expected == 0) TEST_THROW(std::bad_alloc());
+} while (!throw_one.compare_exchange_weak(expected, expected - 1));
 ++outstanding_new;
 void* ret = std::malloc(s);
 if (!ret) std::abort(); // placate MSVC's unchecked malloc warning
 return ret;
 }
 
 void  operator delete(void* p) TEST_NOEXCEPT
 {
+if (!p) return;
 --outstanding_new;
 std::free(p);
 }
@@ -109,21 +111,23 @@
 //  B std::thread's constructor should properly handle exceptions and not leak
 //memory.
 // Plan:
-//  1 Create a thread and count the number of allocations, 'N', it performs.
+//  1 Create a thread and count the number of allocations, 'numAllocs', it performs.
 //  2 For each allocation performed run a test where that allocation throws.
 //2.1 check that the exception can be caught in the parent thread.
 //2.2 Check that the functor has not been called.
 //2.3 Check that no memory allocated by the creation of the thread is leaked.
-//  3 Finally check that a thread runs successfully if we throw after 'N+1'
+//  3 Finally check that a thread runs successfully if we throw after 'numAllocs+1'
 //allocations.
+int numAllocs;
+
 void test_throwing_new_during_thread_creation() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 throw_one = 0xFFF;
 {
 std::thread t(f);
 t.join();
 }
-const int numAllocs = 0xFFF - throw_one;
+numAllocs = 0xFFF - throw_one;
 // i <= numAllocs means the last iteration is expected not to throw.
 for (int i=0; i <= numAllocs; ++i) {
 throw_one = i;
@@ -167,16 

[PATCH] D50860: [libc++][test] Remove non-portable assumption that thread's constructor allocates with ::new

2018-10-26 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

I'll put this explanation in the comments and push a change.




Comment at: 
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp:121
 //allocations.
+int numAllocs;
+

EricWF wrote:
> Why?
`main` non-portably assumes that thread creation results in at least one call 
to `::operator new`. This change fixes that assumption by counting the number 
of calls to `::operator new` here for creation of a do-nothing thread, and 
communicating that count to `main` via `numAllocs`.



Comment at: 
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp:171
 #ifndef TEST_HAS_NO_EXCEPTIONS
-{
+if (numAllocs > 0) {
 try

EricWF wrote:
> I'm not sure I understand this change either.
> 
If thread creation in `test_throwing_new_during_thread_creation` resulted in 
`0` calls to `::operator new`, the expectation is that the same will occur here 
when we create a thread. If `::operator new` isn't called, it can't throw the 
exception this test is expecting to catch.


https://reviews.llvm.org/D50860



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53763: [libc++] [test] Fix logic error in tests; enable for MSVC previews

2018-10-26 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.
CaseyCarter added reviewers: EricWF, mclow.lists.

Fairly straightforward: these tests were written without an implementation of 
`<=>`, and they're incorrectly testing that `0 <=> foo` has the behavior that 
is required for `foo <=> 0`.


https://reviews.llvm.org/D53763

Files:
  test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp
  test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp
  test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp
  test/support/test_macros.h


Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -203,8 +203,9 @@
 
 // FIXME: Fix this feature check when either (A) a compiler provides a complete
 // implementation, or (b) a feature check macro is specified
+#if !defined(_MSC_VER) || defined(__clang__) || _MSC_VER < 1920 || _MSVC_LANG 
<= 201703L
 #define TEST_HAS_NO_SPACESHIP_OPERATOR
-
+#endif
 
 #if TEST_STD_VER < 11
 #define ASSERT_NOEXCEPT(...)
Index: test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp
===
--- test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp
+++ test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp
@@ -142,7 +142,7 @@
   };
   for (auto TC : SpaceshipTestCases)
   {
-std::weak_ordering Res = (0 <=> TC.Value);
+std::weak_ordering Res = (TC.Value <=> 0);
 switch (TC.Expect) {
 case ER_Equiv:
   assert(Res == 0);
Index: test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp
===
--- test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp
+++ test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp
@@ -185,7 +185,7 @@
   };
   for (auto TC : SpaceshipTestCases)
   {
-std::strong_ordering Res = (0 <=> TC.Value);
+std::strong_ordering Res = (TC.Value <=> 0);
 switch (TC.Expect) {
 case ER_Equiv:
   assert(Res == 0);
Index: test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp
===
--- test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp
+++ test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp
@@ -130,7 +130,7 @@
   };
   for (auto TC : SpaceshipTestCases)
   {
-std::partial_ordering Res = (0 <=> TC.Value);
+std::partial_ordering Res = (TC.Value <=> 0);
 switch (TC.Expect) {
 case ER_Equiv:
   assert(Res == 0);


Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -203,8 +203,9 @@
 
 // FIXME: Fix this feature check when either (A) a compiler provides a complete
 // implementation, or (b) a feature check macro is specified
+#if !defined(_MSC_VER) || defined(__clang__) || _MSC_VER < 1920 || _MSVC_LANG <= 201703L
 #define TEST_HAS_NO_SPACESHIP_OPERATOR
-
+#endif
 
 #if TEST_STD_VER < 11
 #define ASSERT_NOEXCEPT(...)
Index: test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp
===
--- test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp
+++ test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp
@@ -142,7 +142,7 @@
   };
   for (auto TC : SpaceshipTestCases)
   {
-std::weak_ordering Res = (0 <=> TC.Value);
+std::weak_ordering Res = (TC.Value <=> 0);
 switch (TC.Expect) {
 case ER_Equiv:
   assert(Res == 0);
Index: test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp
===
--- test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp
+++ test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp
@@ -185,7 +185,7 @@
   };
   for (auto TC : SpaceshipTestCases)
   {
-std::strong_ordering Res = (0 <=> TC.Value);
+std::strong_ordering Res = (TC.Value <=> 0);
 switch (TC.Expect) {
 case ER_Equiv:
   assert(Res == 0);
Index: test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp
===
--- test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp
+++ test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp
@@ -130,7 +130,7 @@
   };
   for (auto TC : SpaceshipTestCases)
   {
-std::partial_ordering Res = (0 <=> TC.Value);
+std::partial_ordering Res = (TC.Value <=> 0);
 switch (TC.Expect) {
 case ER_Equiv:
   assert(Res == 0);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50860: [libc++][test] Remove non-portable assumption that thread's constructor allocates with ::new

2018-08-16 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.
CaseyCarter added reviewers: mclow.lists, EricWF.

Drive-by:

- Fix potential race between check and update of `throw_one` in operator new
- Fix latent bug in operator delete, which shouldn't decrement 
`outstanding_new` when passed a null pointer
- Specifically catch the expected `bad_alloc` in `main` instead of `...`


https://reviews.llvm.org/D50860

Files:
  
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp


Index: 
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
===
--- 
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
+++ 
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
@@ -31,17 +31,19 @@
 
 void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
 {
-if (throw_one == 0)
-TEST_THROW(std::bad_alloc());
---throw_one;
+unsigned expected = throw_one;
+do {
+if (expected == 0) TEST_THROW(std::bad_alloc());
+} while (!throw_one.compare_exchange_weak(expected, expected - 1));
 ++outstanding_new;
 void* ret = std::malloc(s);
 if (!ret) std::abort(); // placate MSVC's unchecked malloc warning
 return ret;
 }
 
 void  operator delete(void* p) TEST_NOEXCEPT
 {
+if (!p) return;
 --outstanding_new;
 std::free(p);
 }
@@ -116,14 +118,16 @@
 //2.3 Check that no memory allocated by the creation of the thread is 
leaked.
 //  3 Finally check that a thread runs successfully if we throw after 'N+1'
 //allocations.
+int numAllocs;
+
 void test_throwing_new_during_thread_creation() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 throw_one = 0xFFF;
 {
 std::thread t(f);
 t.join();
 }
-const int numAllocs = 0xFFF - throw_one;
+numAllocs = 0xFFF - throw_one;
 // i <= numAllocs means the last iteration is expected not to throw.
 for (int i=0; i <= numAllocs; ++i) {
 throw_one = i;
@@ -164,16 +168,16 @@
 }
 G::op_run = false;
 #ifndef TEST_HAS_NO_EXCEPTIONS
-{
+if (numAllocs > 0) {
 try
 {
 throw_one = 0;
 assert(G::n_alive == 0);
 assert(!G::op_run);
 std::thread t((G()));
 assert(false);
 }
-catch (...)
+catch (std::bad_alloc const&)
 {
 throw_one = 0x;
 assert(G::n_alive == 0);


Index: test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
===
--- test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
+++ test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
@@ -31,17 +31,19 @@
 
 void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
 {
-if (throw_one == 0)
-TEST_THROW(std::bad_alloc());
---throw_one;
+unsigned expected = throw_one;
+do {
+if (expected == 0) TEST_THROW(std::bad_alloc());
+} while (!throw_one.compare_exchange_weak(expected, expected - 1));
 ++outstanding_new;
 void* ret = std::malloc(s);
 if (!ret) std::abort(); // placate MSVC's unchecked malloc warning
 return ret;
 }
 
 void  operator delete(void* p) TEST_NOEXCEPT
 {
+if (!p) return;
 --outstanding_new;
 std::free(p);
 }
@@ -116,14 +118,16 @@
 //2.3 Check that no memory allocated by the creation of the thread is leaked.
 //  3 Finally check that a thread runs successfully if we throw after 'N+1'
 //allocations.
+int numAllocs;
+
 void test_throwing_new_during_thread_creation() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 throw_one = 0xFFF;
 {
 std::thread t(f);
 t.join();
 }
-const int numAllocs = 0xFFF - throw_one;
+numAllocs = 0xFFF - throw_one;
 // i <= numAllocs means the last iteration is expected not to throw.
 for (int i=0; i <= numAllocs; ++i) {
 throw_one = i;
@@ -164,16 +168,16 @@
 }
 G::op_run = false;
 #ifndef TEST_HAS_NO_EXCEPTIONS
-{
+if (numAllocs > 0) {
 try
 {
 throw_one = 0;
 assert(G::n_alive == 0);
 assert(!G::op_run);
 std::thread t((G()));
 assert(false);
 }
-catch (...)
+catch (std::bad_alloc const&)
 {
 throw_one = 0x;
 assert(G::n_alive == 0);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49120: [libc++] P0898R3 2 of 12: Implement header

2018-07-11 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added inline comments.



Comment at: include/concepts:175
+template 
+_LIBCPP_CONCEPT_DECL Same = __same_impl<_Tp, _Up> && __same_impl<_Up, _Tp>;
+

Quuxplusone wrote:
> CaseyCarter wrote:
> > Quuxplusone wrote:
> > > Peanut gallery asks: From lines 166-171 it looks awfully like 
> > > `__same_impl<_Tp, _Up>` is true if and only if `__same_impl<_Up, _Tp>` is 
> > > true. So why bother instantiating both templates?
> > This is the library implementation of the ["`Same` subsumes `Same > T>`" requirement](http://eel.is/c++draft/concept.same#1).
> Ah, so this and tangentially line 280 are both about fiddling with 
> "subsumption." Admittedly I don't know how the compiler side is implemented, 
> but it seems too bad that the library has to do double the work (even at this 
> leafy of a level) just to deal with subsumption, which AIUI is required in 
> order to properly order competing template specializations (a situation that 
> is(?) unlikely to come up in the average end-user's code). :/
> Anyway, carry on.
Ideally, `Same` would be implemented with an intrinsic that tells the compiler 
to ignore the parameter mappings (http://eel.is/c++draft/temp.constr.atomic#2) 
when it checks the atomic constraints defined in this concept for equivalence. 
Or better yet, we could expose that feature in the language - say with a 
context-sensitive keyword `concept symmetric Same` - that could be applied to 
any two-type concept. There are quite a few symmetric concepts that could 
benefit similarly - `Common`, `CommonReference`, all of the `FooWith` concepts 
- for which we don't require subsumption because evaluating them is 
significantly more expensive than `Same`.



Comment at: include/concepts:152
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && _LIBCPP_STD_VER > 17
+#define __cpp_lib_concepts 201806L
+

I've just realized I failed to update `` with the feature test macro 
value. Does libc++ have a plan yet for how to handle the feature test macros? 
Should I `#define` it in `` and include that here?

I suspect we should rename `__config` to `` and define all feature 
test macros therein.


https://reviews.llvm.org/D49120



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49118: [libc++] P0898R3 1 of 12: changes to common_type; implement common_reference

2018-07-10 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

In https://reviews.llvm.org/D49118#1157438, @mclow.lists wrote:

> >   I've conservatively hidden everything behind _LIBCPP_STD_VER > 17, 
> > although it could be made available in C++11 mode with some edits.
>
> If we have a use for this in pre c++2a code, the libc++ convention would be 
> to implement `__common_reference` that works most everywhere, and then have 
> `common_reference` that only works > 17, but inherits from the ugly name.
>
> That might be difficult in this case, because users can extend 
> `common_reference`.


I was thinking more about implementing the new bullet for `common_type` 
unconditionally. Despite that it wouldn't quite conform in older modes, it 
would avoid introducing an obscure difference between 20-mode `common_type` and 
11-mode `common_type`. That said, I wouldn't do so in MSFTL so I assumed you 
wouldn't in libc++.


https://reviews.llvm.org/D49118



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49120: [libc++] P0898R3 2 of 12: Implement header

2018-07-10 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 154787.
CaseyCarter added a comment.

Qualify call to `__invoke_constexpr` in the definition of the `Invocable` 
concept.


https://reviews.llvm.org/D49120

Files:
  CMakeLists.txt
  include/CMakeLists.txt
  include/__config
  include/concepts
  include/module.modulemap
  test/libcxx/concepts/lit.local.cfg
  test/libcxx/concepts/version.pass.cpp
  test/libcxx/double_include.sh.cpp
  test/libcxx/min_max_macros.sh.cpp
  utils/libcxx/test/config.py

Index: utils/libcxx/test/config.py
===
--- utils/libcxx/test/config.py
+++ utils/libcxx/test/config.py
@@ -153,6 +153,7 @@
 self.configure_coverage()
 self.configure_modules()
 self.configure_coroutines()
+self.configure_concepts()
 self.configure_substitutions()
 self.configure_features()
 
@@ -1017,6 +1018,22 @@
 if intMacroValue(macros['__cpp_coroutines']) >= 201703:
 self.config.available_features.add('fcoroutines-ts')
 
+def configure_concepts(self):
+# If the compiler supports concepts, add the 'concepts' feature.
+# If it requires the '-fconcepts' flag to do so, additionally add the
+# 'fconcepts' feature.
+macros = self._dump_macros_verbose()
+if '__cpp_concepts' in macros and intMacroValue(macros['__cpp_concepts']) >= 201507:
+self.config.available_features.add('concepts')
+elif self.cxx.hasCompileFlag('-fconcepts'):
+macros = self._dump_macros_verbose(flags=['-fconcepts'])
+if '__cpp_concepts' not in macros:
+self.lit_config.warning('-fconcepts is supported but '
+'__cpp_concepts is not defined')
+if intMacroValue(macros['__cpp_concepts']) >= 201507:
+self.config.available_features.add('concepts')
+self.config.available_features.add('fconcepts')
+
 def configure_modules(self):
 modules_flags = ['-fmodules']
 if platform.system() != 'Darwin':
Index: test/libcxx/min_max_macros.sh.cpp
===
--- test/libcxx/min_max_macros.sh.cpp
+++ test/libcxx/min_max_macros.sh.cpp
@@ -64,6 +64,8 @@
 TEST_MACROS();
 #include 
 TEST_MACROS();
+#include 
+TEST_MACROS();
 #include 
 TEST_MACROS();
 #include 
Index: test/libcxx/double_include.sh.cpp
===
--- test/libcxx/double_include.sh.cpp
+++ test/libcxx/double_include.sh.cpp
@@ -44,6 +44,9 @@
 #include 
 #include 
 #include 
+#ifndef _LIBCPP_HAS_NO_CONCEPTS
+#include 
+#endif
 #include 
 #include 
 #include 
Index: test/libcxx/concepts/version.pass.cpp
===
--- /dev/null
+++ test/libcxx/concepts/version.pass.cpp
@@ -0,0 +1,19 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+
+#include 
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main() {}
Index: test/libcxx/concepts/lit.local.cfg
===
--- /dev/null
+++ test/libcxx/concepts/lit.local.cfg
@@ -0,0 +1,9 @@
+# If the compiler doesn't support concepts, mark all of the tests under
+# this directory as unsupported.
+if 'concepts' not in config.available_features:
+  config.unsupported = True
+elif 'fconcepts' in config.available_features:
+  # The compiler supports concepts only with the flag - require it.
+  import copy
+  config.test_format.cxx = copy.deepcopy(config.test_format.cxx)
+  config.test_format.cxx.compile_flags += ['-fconcepts']
Index: include/module.modulemap
===
--- include/module.modulemap
+++ include/module.modulemap
@@ -251,6 +251,10 @@
 header "complex"
 export *
   }
+  module concepts {
+header "concepts"
+export *
+  }
   module condition_variable {
 header "condition_variable"
 export *
Index: include/concepts
===
--- /dev/null
+++ include/concepts
@@ -0,0 +1,417 @@
+// -*- C++ -*-
+//===-- concepts --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_CONCEPTS
+#define _LIBCPP_CONCEPTS
+
+/*

[PATCH] D49120: [libc++] P0898R3 2 of 12: Implement header

2018-07-09 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added inline comments.



Comment at: include/concepts:175
+template 
+_LIBCPP_CONCEPT_DECL Same = __same_impl<_Tp, _Up> && __same_impl<_Up, _Tp>;
+

Quuxplusone wrote:
> Peanut gallery asks: From lines 166-171 it looks awfully like 
> `__same_impl<_Tp, _Up>` is true if and only if `__same_impl<_Up, _Tp>` is 
> true. So why bother instantiating both templates?
This is the library implementation of the ["`Same` subsumes `Same`" 
requirement](http://eel.is/c++draft/concept.same#1).



Comment at: include/concepts:280
+Constructible<_Tp, const _Tp&> && ConvertibleTo &&
+Constructible<_Tp, const _Tp> && ConvertibleTo;
+

Quuxplusone wrote:
> Peanut gallery notices the lack of `Constructible<_Tp, const _Tp&&>` here, 
> and assumes it's intentional?
Yes: `Constructible` is equal to `is_constructible_v` 
which is true iff the declaration `T t(declval()...);` is valid. Since 
`decltype(declval())` is `add_rvalue_reference_t`, `Constructible<_Tp, 
const _Tp>` is equal to `Constructible<_Tp, const _Tp&&>`.

Admittedly the compiler doesn't know that - the subsumption rules don't know 
how `declval` is implemented - but no one has yet presented a use case where it 
would be helpful. If and when that happens, we can consider adding more terms 
to the concepts.



Comment at: include/concepts:295
+requires ConvertibleTo&, bool>;
+!__t1;requires ConvertibleTo;
+__t1 && __t2; requires Same;

Quuxplusone wrote:
> Peanut gallery asks: Am I correct that the instances of `ConvertibleTo<..., 
> bool>` here could (according to the WD) be replaced with `-> bool`?  Am I 
> correct that the instances of `Same<..., bool>` here could eventually be 
> replaced with `-> Same` once they fix that issue you wrote a paper 
> about?
> 
> I assume they're written like this for portability reasons.
`ConvertibleTo` requires both implicit and explicit conversions to be valid and 
have equal results - so it's stronger than `is_convertible` and therefore the 
core language's notion of implicit convertibility. Consequently `-> bool` would 
not be equivalent.

Yes, P1084 will let us simplify all of these horrible nested requirements that 
duplicate the expressions. `E; requires Concept;` will 
become `{ E } -> Concept;`.




Comment at: include/concepts:379
+_LIBCPP_CONCEPT_DECL Invocable = requires(_Fn&& __fn, _Args&&... __args) {
+__invoke_constexpr(static_cast<_Fn&&>(__fn), 
static_cast<_Args&&>(__args)...);
+};

Quuxplusone wrote:
> Does this need a `_VSTD::` for ADL reasons? (There's one in `` that 
> does use `_VSTD::`; there's two in `` that don't.)
Yes it does. Despite that the function name is ugly and a user can't hijack it, 
ADL will do crazy things like instantiating `T` when passed `T*` to determine 
`T`'s associated namespaces.



Comment at: include/concepts:394
+CommonReference<
+const remove_reference_t<_Tp>&,
+const remove_reference_t<_Up>&> &&

Quuxplusone wrote:
> I'm fairly confident that `const remove_reference_t<_Tp>&` is just `const 
> _Tp&`.
Not when `_Tp` is a reference type: https://godbolt.org/g/Q2Hon8.


https://reviews.llvm.org/D49120



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49120: [libc++] P0898R3 2 of 12: Implement header

2018-07-09 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added inline comments.



Comment at: include/concepts:193
+#endif
+#if 0 // FIXME: File LWG issue
+requires(_From (&_Fn)()) { static_cast<_To>(_Fn()); };

I suppose it would have been a good idea to fix this before submitting the 
patch for review - but it's too late now.

The issue here is that `ConvertibleTo` as specified rejects all conversions 
from array and function types. While this makes sense on the one hand - there 
are no expressions of array or function type from which to convert - it is a 
difference relative to `is_convertible` that I don't think any of the LEWG/LWG 
design discussions considered.

This conditional should be either removed, or the condition "flipped" so the 
concept definition agrees with the working draft. The affected test cases need 
to be conditional as well.


https://reviews.llvm.org/D49120



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49122: [libc++] P0898R3 3 of 12: Tests for Same, DerivedFrom, ConvertibleTo, and CommonReference

2018-07-09 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.
CaseyCarter added reviewers: mclow.lists, EricWF.

Like the title says, the first batch of tests.

I'll stop at three chunks for now - that should be enough to get some reviewer 
feedback and keep me busy making changes.


https://reviews.llvm.org/D49122

Files:
  test/std/concepts/concepts.lang/concept.commonref/common_reference.pass.cpp
  test/std/concepts/concepts.lang/concept.convertibleto/convertible_to.pass.cpp
  test/std/concepts/concepts.lang/concept.derivedfrom/derived_from.pass.cpp
  test/std/concepts/concepts.lang/concept.same/same.pass.cpp
  test/std/concepts/lit.local.cfg

Index: test/std/concepts/lit.local.cfg
===
--- /dev/null
+++ test/std/concepts/lit.local.cfg
@@ -0,0 +1,9 @@
+# If the compiler doesn't support concepts, mark all of the tests under
+# this directory as unsupported.
+if 'concepts' not in config.available_features:
+  config.unsupported = True
+elif 'fconcepts' in config.available_features:
+  # The compiler supports concepts only with the flag - require it.
+  import copy
+  config.test_format.cxx = copy.deepcopy(config.test_format.cxx)
+  config.test_format.cxx.compile_flags += ['-fconcepts']
Index: test/std/concepts/concepts.lang/concept.same/same.pass.cpp
===
--- /dev/null
+++ test/std/concepts/concepts.lang/concept.same/same.pass.cpp
@@ -0,0 +1,75 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+
+#include 
+#include 
+
+static_assert(std::Same);
+static_assert(std::Same);
+static_assert(!std::Same);
+static_assert(!std::Same);
+
+// Test that `Same` subsumes `Same` (with reversed args).
+template 
+requires std::Same
+constexpr bool foo() {
+return false;
+}
+
+template 
+requires std::Same && std::is_integral_v
+constexpr bool foo() {
+return true;
+}
+
+static_assert(!foo());
+static_assert(foo());
+
+template 
+void test_same() {
+static_assert( std::Same);
+static_assert(!std::Same);
+static_assert(!std::Same);
+static_assert( std::Same);
+}
+
+template 
+void test_same_ref() {
+static_assert(std::Same);
+static_assert(std::Same);
+static_assert(std::Same);
+static_assert(std::Same);
+}
+
+template 
+void test_not_same() {
+static_assert(!std::Same);
+}
+
+struct Class
+{
+~Class();
+};
+
+int main() {
+test_same();
+test_same();
+test_same();
+test_same();
+test_same_ref();
+
+test_not_same();
+test_not_same();
+test_not_same();
+test_not_same();
+test_not_same();
+}
Index: test/std/concepts/concepts.lang/concept.derivedfrom/derived_from.pass.cpp
===
--- /dev/null
+++ test/std/concepts/concepts.lang/concept.derivedfrom/derived_from.pass.cpp
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+
+#include 
+#include 
+
+#include "test_macros.h"
+
+template 
+void test_derived_from() {
+static_assert(std::DerivedFrom);
+static_assert(std::DerivedFrom);
+static_assert(std::DerivedFrom);
+static_assert(std::DerivedFrom);
+}
+
+template 
+void test_not_derived_from() {
+static_assert(!std::DerivedFrom);
+}
+
+struct B {};
+struct B1 : B {};
+struct B2 : B {};
+struct D : private B1, private B2 {};
+
+int main() {
+test_derived_from();
+test_derived_from();
+test_derived_from();
+
+test_not_derived_from();
+test_not_derived_from();
+test_not_derived_from();
+test_not_derived_from();
+test_not_derived_from();
+test_not_derived_from();
+test_not_derived_from();
+}
Index: test/std/concepts/concepts.lang/concept.convertibleto/convertible_to.pass.cpp
===
--- /dev/null
+++ test/std/concepts/concepts.lang/concept.convertibleto/convertible_to.pass.cpp
@@ -0,0 +1,298 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//

[PATCH] D49120: [libc++] P0898R3 2 of 12: Implement header

2018-07-09 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.
CaseyCarter added reviewers: mclow.lists, EricWF.
Herald added subscribers: christof, modocache, mgorny.

Piece number two contains the header, a bunch of "add a new header" changes, 
and LIT config to grok tests that need concepts (Thanks to @EricWF's similar 
handling for coroutines which I copied shamelessly).

No tests yet, but fear not - there are 10 pieces yet to come ;)


https://reviews.llvm.org/D49120

Files:
  CMakeLists.txt
  include/CMakeLists.txt
  include/__config
  include/concepts
  include/module.modulemap
  test/libcxx/concepts/lit.local.cfg
  test/libcxx/concepts/version.pass.cpp
  test/libcxx/double_include.sh.cpp
  test/libcxx/min_max_macros.sh.cpp
  utils/libcxx/test/config.py

Index: utils/libcxx/test/config.py
===
--- utils/libcxx/test/config.py
+++ utils/libcxx/test/config.py
@@ -153,6 +153,7 @@
 self.configure_coverage()
 self.configure_modules()
 self.configure_coroutines()
+self.configure_concepts()
 self.configure_substitutions()
 self.configure_features()
 
@@ -1017,6 +1018,22 @@
 if intMacroValue(macros['__cpp_coroutines']) >= 201703:
 self.config.available_features.add('fcoroutines-ts')
 
+def configure_concepts(self):
+# If the compiler supports concepts, add the 'concepts' feature.
+# If it requires the '-fconcepts' flag to do so, additionally add the
+# 'fconcepts' feature.
+macros = self._dump_macros_verbose()
+if '__cpp_concepts' in macros and intMacroValue(macros['__cpp_concepts']) >= 201507:
+self.config.available_features.add('concepts')
+elif self.cxx.hasCompileFlag('-fconcepts'):
+macros = self._dump_macros_verbose(flags=['-fconcepts'])
+if '__cpp_concepts' not in macros:
+self.lit_config.warning('-fconcepts is supported but '
+'__cpp_concepts is not defined')
+if intMacroValue(macros['__cpp_concepts']) >= 201507:
+self.config.available_features.add('concepts')
+self.config.available_features.add('fconcepts')
+
 def configure_modules(self):
 modules_flags = ['-fmodules']
 if platform.system() != 'Darwin':
Index: test/libcxx/min_max_macros.sh.cpp
===
--- test/libcxx/min_max_macros.sh.cpp
+++ test/libcxx/min_max_macros.sh.cpp
@@ -64,6 +64,8 @@
 TEST_MACROS();
 #include 
 TEST_MACROS();
+#include 
+TEST_MACROS();
 #include 
 TEST_MACROS();
 #include 
Index: test/libcxx/double_include.sh.cpp
===
--- test/libcxx/double_include.sh.cpp
+++ test/libcxx/double_include.sh.cpp
@@ -44,6 +44,9 @@
 #include 
 #include 
 #include 
+#ifndef _LIBCPP_HAS_NO_CONCEPTS
+#include 
+#endif
 #include 
 #include 
 #include 
Index: test/libcxx/concepts/version.pass.cpp
===
--- /dev/null
+++ test/libcxx/concepts/version.pass.cpp
@@ -0,0 +1,19 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+
+#include 
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main() {}
Index: test/libcxx/concepts/lit.local.cfg
===
--- /dev/null
+++ test/libcxx/concepts/lit.local.cfg
@@ -0,0 +1,9 @@
+# If the compiler doesn't support concepts, mark all of the tests under
+# this directory as unsupported.
+if 'concepts' not in config.available_features:
+  config.unsupported = True
+elif 'fconcepts' in config.available_features:
+  # The compiler supports concepts only with the flag - require it.
+  import copy
+  config.test_format.cxx = copy.deepcopy(config.test_format.cxx)
+  config.test_format.cxx.compile_flags += ['-fconcepts']
Index: include/module.modulemap
===
--- include/module.modulemap
+++ include/module.modulemap
@@ -251,6 +251,10 @@
 header "complex"
 export *
   }
+  module concepts {
+header "concepts"
+export *
+  }
   module condition_variable {
 header "condition_variable"
 export *
Index: include/concepts
===
--- /dev/null
+++ include/concepts
@@ -0,0 +1,417 @@
+// -*- C++ -*-
+//===-- concepts --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual 

[PATCH] D49118: [libc++] P0898R3 1 of 12: changes to common_type; implement common_reference

2018-07-09 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.
CaseyCarter added reviewers: mclow.lists, EricWF.

I'm breaking this up into independent bite-sized ~500 line reviews instead of a 
single 5200 line monster in hopes that we can turnaround changes quickly.

This first piece implements the new bullet for `common_type`, and all of 
`common_reference` and `basic_common_reference`. I've conservatively hidden 
everything behind `_LIBCPP_STD_VER > 17`, although it could be made available 
in C++11 mode with some edits.


https://reviews.llvm.org/D49118

Files:
  include/type_traits
  test/std/utilities/meta/meta.trans/meta.trans.other/common_reference.pass.cpp
  test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp

Index: test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
===
--- test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
+++ test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
@@ -83,13 +83,16 @@
 template 
 using TernaryOp = typename TernaryOpImp::type;
 
+// (4.1)
 // -- If sizeof...(T) is zero, there shall be no member type.
 void test_bullet_one() {
   static_assert(no_common_type<>::value, "");
 }
 
-// If sizeof...(T) is one, let T0 denote the sole type constituting the pack T.
-// The member typedef-name type shall denote the same type as decay_t.
+// (4.2)
+// -- If sizeof...(T) is one, let T0 denote the sole type constituting the pack
+//T. The member typedef-name type shall denote the same type, if any, as
+//common_type_t; otherwise there shall be no member type.
 void test_bullet_two() {
   static_assert(std::is_same, void>::value, "");
   static_assert(std::is_same, int>::value, "");
@@ -110,11 +113,11 @@
   static_assert(std::is_same, CommonType>::value, "");
 }
 
-// (3.3)
+// (4.3)
 // -- If sizeof...(T) is two, let the first and second types constituting T be
 //denoted by T1 and T2, respectively, and let D1 and D2 denote the same types
 //as decay_t and decay_t, respectively.
-// (3.3.1)
+// (4.3.1)
 //-- If is_same_v is false or is_same_v is false, let C
 //   denote the same type, if any, as common_type_t.
 void test_bullet_three_one() {
@@ -148,16 +151,19 @@
   }
 }
 
-// (3.3)
+// (4.3)
 // -- If sizeof...(T) is two, let the first and second types constituting T be
 //denoted by T1 and T2, respectively, and let D1 and D2 denote the same types
 //as decay_t and decay_t, respectively.
-// (3.3.1)
+// (4.3.1)
 //-- If [...]
-// (3.3.2)
-//-- Otherwise, let C denote the same type, if any, as
+// (4.3.2)
+//-- [Note: [...]
+// (4.3.3)
+//-- Otherwise, if
 //   decay_t() : declval())>
-void test_bullet_three_two() {
+//   denotes a type, let C denote that type.
+void test_bullet_three_three() {
   {
 using T1 = int const*;
 using T2 = int*;
@@ -188,7 +194,16 @@
   }
 }
 
-// (3.4)
+#if TEST_STD_VER > 17
+// (4.3.4)
+//-- Otherwise, if COND_RES(CREF(D1), CREF(D2)) denotes a type, let C denote
+//   the type decay_t.
+void test_bullet_three_four() {
+  static_assert(std::is_same_v, int>, int>);
+}
+#endif
+
+// (4.4)
 // -- If sizeof...(T) is greater than two, let T1, T2, and R, respectively,
 // denote the first, second, and (pack of) remaining types constituting T.
 // Let C denote the same type, if any, as common_type_t. If there is
@@ -291,7 +306,10 @@
   test_bullet_one();
   test_bullet_two();
   test_bullet_three_one();
-  test_bullet_three_two();
+  test_bullet_three_three();
+# if TEST_STD_VER > 17
+  test_bullet_three_four();
+# endif
   test_bullet_four();
 #endif
 
Index: test/std/utilities/meta/meta.trans/meta.trans.other/common_reference.pass.cpp
===
--- /dev/null
+++ test/std/utilities/meta/meta.trans/meta.trans.other/common_reference.pass.cpp
@@ -0,0 +1,226 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+
+// type_traits
+
+// common_reference
+
+#include 
+
+using std::common_reference;
+using std::common_reference_t;
+using std::is_same_v;
+using std::void_t;
+
+template 
+constexpr bool is_trait = false;
+template 
+constexpr bool is_trait> = true;
+
+// A slightly simplified variation of std::tuple
+template  struct Tuple {};
+
+template  struct Tuple_helper {};
+template 
+struct Tuple_helper...>, Tuple, Tuple>
+{
+using type = Tuple...>;
+};
+
+namespace std
+{
+template  class TQual, template  class UQual>
+struct basic_common_reference<::Tuple, ::Tuple, TQual, UQual>
+: ::Tuple_helper...>, Tuple...>>
+{};
+}
+

[PATCH] D45121: [coroutines] Add noop_coroutine to

2018-04-04 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter accepted this revision.
CaseyCarter added inline comments.



Comment at: include/experimental/coroutine:288
+
+coroutine_handle() {
+  this->__handle_ = __builtin_coro_noop();

EricWF wrote:
> GorNishanov wrote:
> > CaseyCarter wrote:
> > > CaseyCarter wrote:
> > > > GorNishanov wrote:
> > > > > EricWF wrote:
> > > > > > Can `__builtin_coro_noop` produce a constant expression?
> > > > > No. llvm generates this value, so from clang perspective, it is not a 
> > > > > constant.
> > > > > At llvm level it is a private per TU constant, so invocations of 
> > > > > noop_coroutine() in different TUs linked into the same program will 
> > > > > return you different values.
> > > > If this class type is not literal - since there's no `constexpr` 
> > > > constructor - applying `constexpr` to the member functions on 278-283 
> > > > is at best misleading and at worst ill-formed NDR due to 
> > > > http://eel.is/c++draft/dcl.constexpr#5.
> > > This constructor should be `_NOEXCEPT`, since it's invoked by 
> > > `noop_coroutine` which is `_NOEXCEPT`.
> > Issue for Rapperswil? These constexprs were approved by LEWG/LWG in 
> > Jacksonville 2018
> @CaseyCarter: I'm not sure this is true. Clang seems to be able to evaluate 
> constexpr member functions of a non-literal type so long as they don't depend 
> on the "argument value" of `this`. Example:
> 
> ```
> struct T {
>   T() {}
>   constexpr bool foo() const { return true; }
> };
> T t;
> static_assert(t.foo(), "");
> ```
@EricWF Yes, thank you - I'm forgetting that an invocation of a `constexpr` 
non-static member function with a non-constant-expression implicit object 
parameter can appear in a constant expression if it doesn't perform 
lvalue-to-rvalue conversion on the implicit object parameter.

These `constexpr`s aren't ill-formed NDR, but they do seem pointless. The base 
class versions aren't `constexpr`, so I can only use these when I know the 
concrete type of my handle is `noop_coroutine_handle`, in which case I know the 
results and have no need to call them at run time *or* compile time.

*shrug* I suppose they do no harm.


https://reviews.llvm.org/D45121



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45121: [coroutines] Add noop_coroutine to

2018-04-04 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a subscriber: STL_MSFT.
CaseyCarter added inline comments.



Comment at: include/experimental/coroutine:268
+: public coroutine_handle<> {
+  using _Base = coroutine_handle<>;
+  using _Promise = noop_coroutine_promise;

This file can't seem to decide if it's using two-space indents or four-space 
indents. It would be nice to pick one and make the whole thing consistent.



Comment at: include/experimental/coroutine:274
+_Promise& promise() const {
+return *reinterpret_cast<_Promise*>(
+__builtin_coro_promise(this->__handle_, __alignof(_Promise), 
false));

If `__builtin_coro_promise` returns a `void*`, this `reinterpret_cast` should 
be a `static_cast`. (and on 216.)



Comment at: include/experimental/coroutine:275
+return *reinterpret_cast<_Promise*>(
+__builtin_coro_promise(this->__handle_, __alignof(_Promise), 
false));
+}

Is `this->non_static_member_of_non_dependent_base_class` idiomatic in libc++? I 
typically reserve `this->` for forcing lookup into dependent bases. (and on 
217.)



Comment at: include/experimental/coroutine:278
+
+constexpr explicit operator bool() const noexcept { return true; }
+constexpr bool done() const noexcept { return false; }

Should these be `_LIBCPP_CONSTEXPR`?



Comment at: include/experimental/coroutine:286
+private:
+friend coroutine_handle noop_coroutine()  
_NOEXCEPT;
+

There's an extra space here between `()` and `_NOEXCEPT`.



Comment at: include/experimental/coroutine:288
+
+coroutine_handle() {
+  this->__handle_ = __builtin_coro_noop();

GorNishanov wrote:
> EricWF wrote:
> > Can `__builtin_coro_noop` produce a constant expression?
> No. llvm generates this value, so from clang perspective, it is not a 
> constant.
> At llvm level it is a private per TU constant, so invocations of 
> noop_coroutine() in different TUs linked into the same program will return 
> you different values.
If this class type is not literal - since there's no `constexpr` constructor - 
applying `constexpr` to the member functions on 278-283 is at best misleading 
and at worst ill-formed NDR due to http://eel.is/c++draft/dcl.constexpr#5.



Comment at: include/experimental/coroutine:288
+
+coroutine_handle() {
+  this->__handle_ = __builtin_coro_noop();

CaseyCarter wrote:
> GorNishanov wrote:
> > EricWF wrote:
> > > Can `__builtin_coro_noop` produce a constant expression?
> > No. llvm generates this value, so from clang perspective, it is not a 
> > constant.
> > At llvm level it is a private per TU constant, so invocations of 
> > noop_coroutine() in different TUs linked into the same program will return 
> > you different values.
> If this class type is not literal - since there's no `constexpr` constructor 
> - applying `constexpr` to the member functions on 278-283 is at best 
> misleading and at worst ill-formed NDR due to 
> http://eel.is/c++draft/dcl.constexpr#5.
This constructor should be `_NOEXCEPT`, since it's invoked by `noop_coroutine` 
which is `_NOEXCEPT`.



Comment at: 
test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp:20
+#include 
+#include 
+

My inner @STL_MSFT wants these includes to be sorted lexicographically ;)



Comment at: 
test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp:22
+
+namespace coro = std::experimental;
+

`coroutines_v1`?



Comment at: 
test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp:55
+
+  h.resume();
+  h.destroy();

Should we `assert(h && !h.done());` after each of these calls on 55-57 to 
validate that they have no effect?


https://reviews.llvm.org/D45121



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41748: [libcxx] [test] Fix Xxx_scan tests using nonstandard things and MSVC++ warnings

2018-01-05 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added inline comments.



Comment at: 
test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp:33
+template 
+constexpr auto operator()(T x) const noexcept {
+return static_cast(x + 10);

Although it doesn't matter to these tests, this notably doesn't have return 
type SFINAE as @mclow.lists suggested in his comment. Marshall, do you care, 
and if so, why?


https://reviews.llvm.org/D41748



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41748: [libcxx] [test] Fix Xxx_scan tests using nonstandard things and MSVC++ warnings

2018-01-04 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added inline comments.



Comment at: 
test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp:31
 
-template 
-struct identity : std::unary_function
-{
-constexpr const T& operator()(const T& x) const { return x;}
-};
-
-template <>
-struct identity
-{
-template 
-constexpr auto operator()(T&& x) const
-_NOEXCEPT_(noexcept(_VSTD::forward(x)))
--> decltype(_VSTD::forward(x))
-{ return_VSTD::forward(x); }
-};
+const auto identity = [](auto&& x) { return std::forward(x); };
 

Pre-existing: the identity transformation is an extremely poor choice for these 
`transform_foo` tests since failure to apply the transformation exactly once to 
each element does not affect the result of the algorithm.


https://reviews.llvm.org/D41748



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41048: [libcxx] workaround PR 28385 in __find_exactly_one_checked

2017-12-12 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL320500: workaround PR 28385 in __find_exactly_one_checked 
(authored by CaseyCarter, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41048?vs=126559=126564#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41048

Files:
  libcxx/trunk/include/tuple


Index: libcxx/trunk/include/tuple
===
--- libcxx/trunk/include/tuple
+++ libcxx/trunk/include/tuple
@@ -1012,10 +1012,10 @@
 
 template 
 struct __find_exactly_one_checked {
-  static constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
+static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, 
_Args>::value...};
 static constexpr size_t value = __find_detail::__find_idx(0, __matches);
-static_assert (value != __not_found, "type not found in type list" );
-static_assert(value != __ambiguous,"type occurs more than once in type 
list");
+static_assert(value != __not_found, "type not found in type list" );
+static_assert(value != __ambiguous, "type occurs more than once in type 
list");
 };
 
 template 


Index: libcxx/trunk/include/tuple
===
--- libcxx/trunk/include/tuple
+++ libcxx/trunk/include/tuple
@@ -1012,10 +1012,10 @@
 
 template 
 struct __find_exactly_one_checked {
-  static constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
+static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, _Args>::value...};
 static constexpr size_t value = __find_detail::__find_idx(0, __matches);
-static_assert (value != __not_found, "type not found in type list" );
-static_assert(value != __ambiguous,"type occurs more than once in type list");
+static_assert(value != __not_found, "type not found in type list" );
+static_assert(value != __ambiguous, "type occurs more than once in type list");
 };
 
 template 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41048: [libcxx] workaround PR 28385 in __find_exactly_one_checked

2017-12-12 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

This new-and-improved workaround - thanks to @lichray - is unintrusive enough 
that I can't imagine it being unnacceptable to anyone. I'm going to go ahead 
and check this in.


https://reviews.llvm.org/D41048



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41048: [libcxx] workaround PR 28385 in __find_exactly_one_checked

2017-12-12 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 126559.
CaseyCarter added a comment.

Better/simpler workaround from Zhihao.


https://reviews.llvm.org/D41048

Files:
  include/tuple


Index: include/tuple
===
--- include/tuple
+++ include/tuple
@@ -1012,10 +1012,10 @@
 
 template 
 struct __find_exactly_one_checked {
-  static constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
+static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, 
_Args>::value...};
 static constexpr size_t value = __find_detail::__find_idx(0, __matches);
-static_assert (value != __not_found, "type not found in type list" );
-static_assert(value != __ambiguous,"type occurs more than once in type 
list");
+static_assert(value != __not_found, "type not found in type list" );
+static_assert(value != __ambiguous, "type occurs more than once in type 
list");
 };
 
 template 


Index: include/tuple
===
--- include/tuple
+++ include/tuple
@@ -1012,10 +1012,10 @@
 
 template 
 struct __find_exactly_one_checked {
-  static constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
+static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, _Args>::value...};
 static constexpr size_t value = __find_detail::__find_idx(0, __matches);
-static_assert (value != __not_found, "type not found in type list" );
-static_assert(value != __ambiguous,"type occurs more than once in type list");
+static_assert(value != __not_found, "type not found in type list" );
+static_assert(value != __ambiguous, "type occurs more than once in type list");
 };
 
 template 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41048: [libcxx] workaround PR 28385 in __find_exactly_one_checked

2017-12-11 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter marked 2 inline comments as done.
CaseyCarter added a comment.

This unconditional workaround addresses Marshall's concerns about the naked 
version test.


https://reviews.llvm.org/D41048



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41048: [libcxx] workaround PR 28385 in __find_exactly_one_checked

2017-12-11 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 126406.
CaseyCarter added a comment.

Make the workaround unconditional.


https://reviews.llvm.org/D41048

Files:
  include/tuple


Index: include/tuple
===
--- include/tuple
+++ include/tuple
@@ -1012,10 +1012,15 @@
 
 template 
 struct __find_exactly_one_checked {
-  static constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
-static constexpr size_t value = __find_detail::__find_idx(0, __matches);
-static_assert (value != __not_found, "type not found in type list" );
-static_assert(value != __ambiguous,"type occurs more than once in type 
list");
+inline _LIBCPP_INLINE_VISIBILITY
+static constexpr size_t __index()
+{
+constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
+return __find_detail::__find_idx(0, __matches);
+}
+static constexpr size_t value = __index();
+static_assert(value != __not_found, "type not found in type list" );
+static_assert(value != __ambiguous, "type occurs more than once in type 
list");
 };
 
 template 


Index: include/tuple
===
--- include/tuple
+++ include/tuple
@@ -1012,10 +1012,15 @@
 
 template 
 struct __find_exactly_one_checked {
-  static constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
-static constexpr size_t value = __find_detail::__find_idx(0, __matches);
-static_assert (value != __not_found, "type not found in type list" );
-static_assert(value != __ambiguous,"type occurs more than once in type list");
+inline _LIBCPP_INLINE_VISIBILITY
+static constexpr size_t __index()
+{
+constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
+return __find_detail::__find_idx(0, __matches);
+}
+static constexpr size_t value = __index();
+static_assert(value != __not_found, "type not found in type list" );
+static_assert(value != __ambiguous, "type occurs more than once in type list");
 };
 
 template 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41048: [libcxx] workaround PR 28385 in __find_exactly_one_checked

2017-12-10 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added inline comments.



Comment at: include/tuple:1015
 struct __find_exactly_one_checked {
-  static constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
+#if defined(__clang__) && __clang_major__ > 5 && __cplusplus > 201402L
+// Workaround https://bugs.llvm.org/show_bug.cgi?id=28385

mclow.lists wrote:
> We try not to have naked tests like this in the code.
> 
> If we have to, maybe:
> 
> `#if defined(_LIBCPP_COMPILER_CLANG) && _LIBCPP_CLANG_VER > 500 && 
> _LIBCPP_STD_VER > 14`
> 
> but I would rather define a new macro in <__config> and give it a meaningful 
> name.
> 
Better?


https://reviews.llvm.org/D41048



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41048: [libcxx] workaround PR 28385 in __find_exactly_one_checked

2017-12-10 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 126297.
CaseyCarter added a comment.

Hide the ugly version test in `<__config>`, define a slightly-more-meaningful 
macro `_LIBCPP_WORKAROUND_CLANG_28385`.


https://reviews.llvm.org/D41048

Files:
  include/__config
  include/tuple


Index: include/tuple
===
--- include/tuple
+++ include/tuple
@@ -1012,10 +1012,20 @@
 
 template 
 struct __find_exactly_one_checked {
-  static constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
+#if defined(_LIBCPP_WORKAROUND_CLANG_28385) && _LIBCPP_WORKAROUND_CLANG_28385
+inline _LIBCPP_INLINE_VISIBILITY
+static constexpr size_t __index()
+{
+constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
+return __find_detail::__find_idx(0, __matches);
+}
+static constexpr size_t value = __index();
+#else // _LIBCPP_WORKAROUND_CLANG_28385
+static constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
 static constexpr size_t value = __find_detail::__find_idx(0, __matches);
-static_assert (value != __not_found, "type not found in type list" );
-static_assert(value != __ambiguous,"type occurs more than once in type 
list");
+#endif // _LIBCPP_WORKAROUND_CLANG_28385
+static_assert(value != __not_found, "type not found in type list" );
+static_assert(value != __ambiguous, "type occurs more than once in type 
list");
 };
 
 template 
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -456,7 +456,7 @@
 // Allow for build-time disabling of unsigned integer sanitization
 #if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && 
__has_attribute(no_sanitize)
 #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 
__attribute__((__no_sanitize__("unsigned-integer-overflow")))
-#endif 
+#endif
 
 #if __has_builtin(__builtin_launder)
 #define_LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
@@ -1273,6 +1273,14 @@
 # endif
 #endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
 
+#ifndef _LIBCPP_WORKAROUND_CLANG_28385
+ #if defined(_LIBCPP_COMPILER_CLANG) && _LIBCPP_CLANG_VER >= 600 && 
_LIBCPP_STD_VER > 14
+  #define _LIBCPP_WORKAROUND_CLANG_28385 1
+ #else
+  #define _LIBCPP_WORKAROUND_CLANG_28385 0
+ #endif
+#endif
+
 #endif // __cplusplus
 
 #endif // _LIBCPP_CONFIG


Index: include/tuple
===
--- include/tuple
+++ include/tuple
@@ -1012,10 +1012,20 @@
 
 template 
 struct __find_exactly_one_checked {
-  static constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
+#if defined(_LIBCPP_WORKAROUND_CLANG_28385) && _LIBCPP_WORKAROUND_CLANG_28385
+inline _LIBCPP_INLINE_VISIBILITY
+static constexpr size_t __index()
+{
+constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
+return __find_detail::__find_idx(0, __matches);
+}
+static constexpr size_t value = __index();
+#else // _LIBCPP_WORKAROUND_CLANG_28385
+static constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
 static constexpr size_t value = __find_detail::__find_idx(0, __matches);
-static_assert (value != __not_found, "type not found in type list" );
-static_assert(value != __ambiguous,"type occurs more than once in type list");
+#endif // _LIBCPP_WORKAROUND_CLANG_28385
+static_assert(value != __not_found, "type not found in type list" );
+static_assert(value != __ambiguous, "type occurs more than once in type list");
 };
 
 template 
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -456,7 +456,7 @@
 // Allow for build-time disabling of unsigned integer sanitization
 #if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize)
 #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
-#endif 
+#endif
 
 #if __has_builtin(__builtin_launder)
 #define	_LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
@@ -1273,6 +1273,14 @@
 # endif
 #endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
 
+#ifndef _LIBCPP_WORKAROUND_CLANG_28385
+ #if defined(_LIBCPP_COMPILER_CLANG) && _LIBCPP_CLANG_VER >= 600 && _LIBCPP_STD_VER > 14
+  #define _LIBCPP_WORKAROUND_CLANG_28385 1
+ #else
+  #define _LIBCPP_WORKAROUND_CLANG_28385 0
+ #endif
+#endif
+
 #endif // __cplusplus
 
 #endif // _LIBCPP_CONFIG
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41048: [libcxx] workaround PR 28385 in __find_exactly_one_checked

2017-12-10 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

In https://reviews.llvm.org/D41048#950635, @mclow.lists wrote:

> Ah - that was the factor I was missing.
>  The tests pass for me with `-std=c++2a`, but fail for `std=c++17`
>
> Casey's original post said they fail with `2a`, and I'm *still* not seeing 
> that.


They fail for me both with -std=c++2a and -std=c++17.


https://reviews.llvm.org/D41048



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41048: [libcxx] workaround PR 28385 in __find_exactly_one_checked

2017-12-10 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

In https://reviews.llvm.org/D41048#950601, @mclow.lists wrote:

> These tests don't fail for me. (using a clang I built two days ago)


What about the repro for #35578 ? 
That repro and these four tests trigger the bug for me (...could not match 
"const bool" against "const bool") with clang version 6.0.0-svn320282-1~exp1 
(trunk) freshly updated from apt.llvm.org on Ubuntu trusty running atop Windows 
Subsystem for Linux. (We've been shipping a workaround for 28385 
 in MSFT `` forever, and 
in range-v3 for even longer 
.)
 Both Godbolt  and Wandbox 
 agree.


https://reviews.llvm.org/D41048



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41048: [libcxx] workaround PR 28385 in __find_exactly_one_checked

2017-12-09 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

In https://reviews.llvm.org/D41048#950424, @lebedev.ri wrote:

> Test?


Four of the existing variant tests fail without this change (Using the clang-6 
dailies from apt.llvm.org and -std=c++2a):

Failing Tests (4):

libc++ :: std/utilities/variant/variant.get/get_if_type.pass.cpp
libc++ :: std/utilities/variant/variant.get/get_type.pass.cpp
libc++ :: std/utilities/variant/variant.get/holds_alternative.pass.cpp
libc++ :: 
std/utilities/variant/variant.variant/variant.mod/emplace_type_init_list_args.pass.cpp
  
  Expected Passes: 36
  Unexpected Failures: 4

I think that's plenty of test coverage.


https://reviews.llvm.org/D41048



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41048: [libcxx] workaround PR 28385 in __find_exactly_one_checked

2017-12-09 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.

Fixes #35578.


https://reviews.llvm.org/D41048

Files:
  include/tuple


Index: include/tuple
===
--- include/tuple
+++ include/tuple
@@ -1012,10 +1012,21 @@
 
 template 
 struct __find_exactly_one_checked {
-  static constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
+#if defined(__clang__) && __clang_major__ > 5 && __cplusplus > 201402L
+// Workaround https://bugs.llvm.org/show_bug.cgi?id=28385
+inline _LIBCPP_INLINE_VISIBILITY
+static constexpr size_t __index()
+{
+constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
+return __find_detail::__find_idx(0, __matches);
+}
+static constexpr size_t value = __index();
+#else
+static constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
 static constexpr size_t value = __find_detail::__find_idx(0, __matches);
-static_assert (value != __not_found, "type not found in type list" );
-static_assert(value != __ambiguous,"type occurs more than once in type 
list");
+#endif
+static_assert(value != __not_found, "type not found in type list" );
+static_assert(value != __ambiguous, "type occurs more than once in type 
list");
 };
 
 template 


Index: include/tuple
===
--- include/tuple
+++ include/tuple
@@ -1012,10 +1012,21 @@
 
 template 
 struct __find_exactly_one_checked {
-  static constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
+#if defined(__clang__) && __clang_major__ > 5 && __cplusplus > 201402L
+// Workaround https://bugs.llvm.org/show_bug.cgi?id=28385
+inline _LIBCPP_INLINE_VISIBILITY
+static constexpr size_t __index()
+{
+constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
+return __find_detail::__find_idx(0, __matches);
+}
+static constexpr size_t value = __index();
+#else
+static constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
 static constexpr size_t value = __find_detail::__find_idx(0, __matches);
-static_assert (value != __not_found, "type not found in type list" );
-static_assert(value != __ambiguous,"type occurs more than once in type list");
+#endif
+static_assert(value != __not_found, "type not found in type list" );
+static_assert(value != __ambiguous, "type occurs more than once in type list");
 };
 
 template 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39221: [libcxx] [test] Alignment must be > __STDCPP_DEFAULT_NEW_ALIGNMENT__ to call aligned new

2017-11-15 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318325: [test] Alignment must be > 
__STDCPP_DEFAULT_NEW_ALIGNMENT__ to call aligned new (authored by CaseyCarter).

Changed prior to commit:
  https://reviews.llvm.org/D39221?vs=119990=123062#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39221

Files:
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp

Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
@@ -35,7 +35,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 int unsized_delete_called = 0;
 int unsized_delete_nothrow_called = 0;
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
@@ -37,7 +37,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 int new_handler_called = 0;
 
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
@@ -37,7 +37,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 int new_handler_called = 0;
 
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp
@@ -24,7 +24,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 bool A_constructed = false;
 
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
@@ -35,7 +35,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 bool A_constructed = false;
 
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp

[PATCH] D39221: [libcxx] [test] Alignment must be > __STDCPP_DEFAULT_NEW_ALIGNMENT__ to call aligned new

2017-10-23 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.

Update aligned `new` tests to use `__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2` for 
"over-aligned" instead of `alignof(std::max_align_t) * 2`.


https://reviews.llvm.org/D39221

Files:
  
test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
  
test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
  
test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
  
test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
  
test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_replace.pass.cpp
  
test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
  
test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
  
test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
  
test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
  
test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp

Index: test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp
===
--- test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp
+++ test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp
@@ -24,7 +24,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 bool A_constructed = false;
 
Index: test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
===
--- test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
+++ test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
@@ -35,7 +35,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 bool A_constructed = false;
 
Index: test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
===
--- test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
+++ test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
@@ -37,7 +37,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 int new_handler_called = 0;
 
Index: test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
===
--- test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
+++ test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
@@ -37,7 +37,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 int new_handler_called = 0;
 
Index: test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
===
--- test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
+++ test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
@@ -35,7 +35,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 int unsized_delete_called = 0;
 int unsized_delete_nothrow_called = 0;
Index: test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_replace.pass.cpp
===
--- test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_replace.pass.cpp
+++ test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_replace.pass.cpp
@@ -24,7 +24,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 int A_constructed = 0;
 
Index: 

[PATCH] D37024: [libcxx] [test] Cleanup nullopt_t tests

2017-08-31 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL312256: [test] Cleanup nullopt_t tests (authored by 
CaseyCarter).

Changed prior to commit:
  https://reviews.llvm.org/D37024?vs=112224=113432#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37024

Files:
  
libcxx/trunk/test/std/utilities/optional/optional.nullopt/not_brace_initializable.fail.cpp
  libcxx/trunk/test/std/utilities/optional/optional.nullopt/nullopt_t.fail.cpp
  libcxx/trunk/test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp

Index: libcxx/trunk/test/std/utilities/optional/optional.nullopt/nullopt_t.fail.cpp
===
--- libcxx/trunk/test/std/utilities/optional/optional.nullopt/nullopt_t.fail.cpp
+++ libcxx/trunk/test/std/utilities/optional/optional.nullopt/nullopt_t.fail.cpp
@@ -11,15 +11,13 @@
 // 
 
 // struct nullopt_t{see below};
-// constexpr nullopt_t nullopt(unspecified);
+// inline constexpr nullopt_t nullopt(unspecified);
 
 // [optional.nullopt]/2:
-//   Type nullopt_t shall not have a default constructor or an initializer-list constructor.
-//   It shall not be an aggregate and shall be a literal type.
-//   Constant nullopt shall be initialized with an argument of literal type.
+//   Type nullopt_t shall not have a default constructor or an initializer-list
+//   constructor, and shall not be an aggregate.
 
 #include 
-#include "test_macros.h"
 
 int main()
 {
Index: libcxx/trunk/test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp
===
--- libcxx/trunk/test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp
+++ libcxx/trunk/test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp
@@ -11,33 +11,30 @@
 // 
 
 // struct nullopt_t{see below};
-// constexpr nullopt_t nullopt(unspecified);
+// inline constexpr nullopt_t nullopt(unspecified);
 
 // [optional.nullopt]/2:
-//   Type nullopt_t shall not have a default constructor or an initializer-list constructor.
-//   It shall not be an aggregate and shall be a literal type.
-//   Constant nullopt shall be initialized with an argument of literal type.
+//   Type nullopt_t shall not have a default constructor or an initializer-list
+//   constructor, and shall not be an aggregate.
 
 #include 
 #include 
 
-using std::optional;
 using std::nullopt_t;
 using std::nullopt;
 
-constexpr
-int
-test(const nullopt_t&)
+constexpr bool test()
 {
-return 3;
+nullopt_t foo{nullopt};
+(void)foo;
+return true;
 }
 
 int main()
 {
-static_assert(( std::is_class::value), "");
-static_assert(( std::is_empty::value), "");
-static_assert(( std::is_literal_type::value), "");
-static_assert((!std::is_default_constructible::value), "");
+static_assert(std::is_empty_v);
+static_assert(!std::is_default_constructible_v);
 
-static_assert(test(nullopt) == 3, "");
+static_assert(std::is_same_v);
+static_assert(test());
 }
Index: libcxx/trunk/test/std/utilities/optional/optional.nullopt/not_brace_initializable.fail.cpp
===
--- libcxx/trunk/test/std/utilities/optional/optional.nullopt/not_brace_initializable.fail.cpp
+++ libcxx/trunk/test/std/utilities/optional/optional.nullopt/not_brace_initializable.fail.cpp
@@ -1,25 +0,0 @@
-//===--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-// UNSUPPORTED: c++98, c++03, c++11, c++14
-// 
-
-// struct nullopt_t{see below};
-
-#include 
-
-using std::optional;
-using std::nullopt_t;
-
-int main()
-{
-// I roughly interpret LWG2736 as "it shall not be possible to copy-list-initialize nullopt_t with an
-// empty braced-init-list."
-nullopt_t foo = {};
-}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37024: [libcxx] [test] Cleanup nullopt_t tests

2017-08-22 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 112224.
CaseyCarter added a comment.

Don't unnecessarily fully qualify `std::nullopt`.


https://reviews.llvm.org/D37024

Files:
  test/std/utilities/optional/optional.nullopt/not_brace_initializable.fail.cpp
  test/std/utilities/optional/optional.nullopt/nullopt_t.fail.cpp
  test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp

Index: test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp
===
--- test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp
+++ test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp
@@ -11,33 +11,30 @@
 // 
 
 // struct nullopt_t{see below};
-// constexpr nullopt_t nullopt(unspecified);
+// inline constexpr nullopt_t nullopt(unspecified);
 
 // [optional.nullopt]/2:
-//   Type nullopt_t shall not have a default constructor or an initializer-list constructor.
-//   It shall not be an aggregate and shall be a literal type.
-//   Constant nullopt shall be initialized with an argument of literal type.
+//   Type nullopt_t shall not have a default constructor or an initializer-list
+//   constructor, and shall not be an aggregate.
 
 #include 
 #include 
 
-using std::optional;
 using std::nullopt_t;
 using std::nullopt;
 
-constexpr
-int
-test(const nullopt_t&)
+constexpr bool test()
 {
-return 3;
+nullopt_t foo{nullopt};
+(void)foo;
+return true;
 }
 
 int main()
 {
-static_assert(( std::is_class::value), "");
-static_assert(( std::is_empty::value), "");
-static_assert(( std::is_literal_type::value), "");
-static_assert((!std::is_default_constructible::value), "");
+static_assert(std::is_empty_v);
+static_assert(!std::is_default_constructible_v);
 
-static_assert(test(nullopt) == 3, "");
+static_assert(std::is_same_v);
+static_assert(test());
 }
Index: test/std/utilities/optional/optional.nullopt/nullopt_t.fail.cpp
===
--- test/std/utilities/optional/optional.nullopt/nullopt_t.fail.cpp
+++ test/std/utilities/optional/optional.nullopt/nullopt_t.fail.cpp
@@ -11,15 +11,13 @@
 // 
 
 // struct nullopt_t{see below};
-// constexpr nullopt_t nullopt(unspecified);
+// inline constexpr nullopt_t nullopt(unspecified);
 
 // [optional.nullopt]/2:
-//   Type nullopt_t shall not have a default constructor or an initializer-list constructor.
-//   It shall not be an aggregate and shall be a literal type.
-//   Constant nullopt shall be initialized with an argument of literal type.
+//   Type nullopt_t shall not have a default constructor or an initializer-list
+//   constructor, and shall not be an aggregate.
 
 #include 
-#include "test_macros.h"
 
 int main()
 {
Index: test/std/utilities/optional/optional.nullopt/not_brace_initializable.fail.cpp
===
--- test/std/utilities/optional/optional.nullopt/not_brace_initializable.fail.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//===--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-// UNSUPPORTED: c++98, c++03, c++11, c++14
-// 
-
-// struct nullopt_t{see below};
-
-#include 
-
-using std::optional;
-using std::nullopt_t;
-
-int main()
-{
-// I roughly interpret LWG2736 as "it shall not be possible to copy-list-initialize nullopt_t with an
-// empty braced-init-list."
-nullopt_t foo = {};
-}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37024: [libcxx] [test] Cleanup nullopt_t tests

2017-08-22 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.

- Update specification text from N4387

- Delete `not_brace_initializable.fail.cpp`: it's redundant with 
`nullopt_t.fail.cpp`

- `is_empty` implies `is_class`

- `is_literal` is deprecated; directly verify that we can create a `nullopt_t` 
in a `constexpr` context


https://reviews.llvm.org/D37024

Files:
  test/std/utilities/optional/optional.nullopt/not_brace_initializable.fail.cpp
  test/std/utilities/optional/optional.nullopt/nullopt_t.fail.cpp
  test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp

Index: test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp
===
--- test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp
+++ test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp
@@ -11,33 +11,30 @@
 // 
 
 // struct nullopt_t{see below};
-// constexpr nullopt_t nullopt(unspecified);
+// inline constexpr nullopt_t nullopt(unspecified);
 
 // [optional.nullopt]/2:
-//   Type nullopt_t shall not have a default constructor or an initializer-list constructor.
-//   It shall not be an aggregate and shall be a literal type.
-//   Constant nullopt shall be initialized with an argument of literal type.
+//   Type nullopt_t shall not have a default constructor or an initializer-list
+//   constructor, and shall not be an aggregate.
 
 #include 
 #include 
 
-using std::optional;
 using std::nullopt_t;
 using std::nullopt;
 
-constexpr
-int
-test(const nullopt_t&)
+constexpr bool test()
 {
-return 3;
+nullopt_t foo{nullopt};
+(void)foo;
+return true;
 }
 
 int main()
 {
-static_assert(( std::is_class::value), "");
-static_assert(( std::is_empty::value), "");
-static_assert(( std::is_literal_type::value), "");
-static_assert((!std::is_default_constructible::value), "");
+static_assert(std::is_empty_v);
+static_assert(!std::is_default_constructible_v);
 
-static_assert(test(nullopt) == 3, "");
+static_assert(std::is_same_v);
+static_assert(test());
 }
Index: test/std/utilities/optional/optional.nullopt/nullopt_t.fail.cpp
===
--- test/std/utilities/optional/optional.nullopt/nullopt_t.fail.cpp
+++ test/std/utilities/optional/optional.nullopt/nullopt_t.fail.cpp
@@ -11,15 +11,13 @@
 // 
 
 // struct nullopt_t{see below};
-// constexpr nullopt_t nullopt(unspecified);
+// inline constexpr nullopt_t nullopt(unspecified);
 
 // [optional.nullopt]/2:
-//   Type nullopt_t shall not have a default constructor or an initializer-list constructor.
-//   It shall not be an aggregate and shall be a literal type.
-//   Constant nullopt shall be initialized with an argument of literal type.
+//   Type nullopt_t shall not have a default constructor or an initializer-list
+//   constructor, and shall not be an aggregate.
 
 #include 
-#include "test_macros.h"
 
 int main()
 {
Index: test/std/utilities/optional/optional.nullopt/not_brace_initializable.fail.cpp
===
--- test/std/utilities/optional/optional.nullopt/not_brace_initializable.fail.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//===--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-// UNSUPPORTED: c++98, c++03, c++11, c++14
-// 
-
-// struct nullopt_t{see below};
-
-#include 
-
-using std::optional;
-using std::nullopt_t;
-
-int main()
-{
-// I roughly interpret LWG2736 as "it shall not be possible to copy-list-initialize nullopt_t with an
-// empty braced-init-list."
-nullopt_t foo = {};
-}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32385: [libcxx] optional: Implement LWG 2900 and P0602

2017-07-09 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL307505: optional: Implement LWG 2900 and P0602 (authored by 
CaseyCarter).

Changed prior to commit:
  https://reviews.llvm.org/D32385?vs=101631=105784#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32385

Files:
  libcxx/trunk/include/optional
  
libcxx/trunk/test/libcxx/utilities/optional/optional.object/special_member_gen.pass.cpp
  
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp
  
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
  
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
  
libcxx/trunk/test/std/utilities/optional/optional.object/special_member_gen.pass.cpp

Index: libcxx/trunk/include/optional
===
--- libcxx/trunk/include/optional
+++ libcxx/trunk/include/optional
@@ -439,46 +439,122 @@
 }
 };
 
-template ::value>
-struct __optional_storage;
-
-template 
-struct __optional_storage<_Tp, true> : __optional_storage_base<_Tp>
+template ::value>
+struct __optional_copy_base : __optional_storage_base<_Tp>
 {
 using __optional_storage_base<_Tp>::__optional_storage_base;
 };
 
 template 
-struct __optional_storage<_Tp, false> : __optional_storage_base<_Tp>
+struct __optional_copy_base<_Tp, false> : __optional_storage_base<_Tp>
 {
-using value_type = _Tp;
 using __optional_storage_base<_Tp>::__optional_storage_base;
 
 _LIBCPP_INLINE_VISIBILITY
-__optional_storage() = default;
+__optional_copy_base() = default;
 
 _LIBCPP_INLINE_VISIBILITY
-__optional_storage(const __optional_storage& __opt)
+__optional_copy_base(const __optional_copy_base& __opt)
 {
 this->__construct_from(__opt);
 }
 
 _LIBCPP_INLINE_VISIBILITY
-__optional_storage(__optional_storage&& __opt)
+__optional_copy_base(__optional_copy_base&&) = default;
+_LIBCPP_INLINE_VISIBILITY
+__optional_copy_base& operator=(const __optional_copy_base&) = default;
+_LIBCPP_INLINE_VISIBILITY
+__optional_copy_base& operator=(__optional_copy_base&&) = default;
+};
+
+template ::value>
+struct __optional_move_base : __optional_copy_base<_Tp>
+{
+using __optional_copy_base<_Tp>::__optional_copy_base;
+};
+
+template 
+struct __optional_move_base<_Tp, false> : __optional_copy_base<_Tp>
+{
+using value_type = _Tp;
+using __optional_copy_base<_Tp>::__optional_copy_base;
+
+_LIBCPP_INLINE_VISIBILITY
+__optional_move_base() = default;
+_LIBCPP_INLINE_VISIBILITY
+__optional_move_base(const __optional_move_base&) = default;
+
+_LIBCPP_INLINE_VISIBILITY
+__optional_move_base(__optional_move_base&& __opt)
 noexcept(is_nothrow_move_constructible_v)
 {
 this->__construct_from(_VSTD::move(__opt));
 }
 
 _LIBCPP_INLINE_VISIBILITY
-__optional_storage& operator=(const __optional_storage& __opt)
+__optional_move_base& operator=(const __optional_move_base&) = default;
+_LIBCPP_INLINE_VISIBILITY
+__optional_move_base& operator=(__optional_move_base&&) = default;
+};
+
+template ::value &&
+is_trivially_copy_constructible<_Tp>::value &&
+is_trivially_copy_assignable<_Tp>::value>
+struct __optional_copy_assign_base : __optional_move_base<_Tp>
+{
+using __optional_move_base<_Tp>::__optional_move_base;
+};
+
+template 
+struct __optional_copy_assign_base<_Tp, false> : __optional_move_base<_Tp>
+{
+using __optional_move_base<_Tp>::__optional_move_base;
+
+_LIBCPP_INLINE_VISIBILITY
+__optional_copy_assign_base() = default;
+_LIBCPP_INLINE_VISIBILITY
+__optional_copy_assign_base(const __optional_copy_assign_base&) = default;
+_LIBCPP_INLINE_VISIBILITY
+__optional_copy_assign_base(__optional_copy_assign_base&&) = default;
+
+_LIBCPP_INLINE_VISIBILITY
+__optional_copy_assign_base& operator=(const __optional_copy_assign_base& __opt)
 {
 this->__assign_from(__opt);
 return *this;
 }
 
 _LIBCPP_INLINE_VISIBILITY
-__optional_storage& operator=(__optional_storage&& __opt)
+__optional_copy_assign_base& operator=(__optional_copy_assign_base&&) = default;
+};
+
+template ::value &&
+is_trivially_move_constructible<_Tp>::value &&
+is_trivially_move_assignable<_Tp>::value>
+struct __optional_move_assign_base : __optional_copy_assign_base<_Tp>
+{
+using __optional_copy_assign_base<_Tp>::__optional_copy_assign_base;
+};
+
+template 
+struct __optional_move_assign_base<_Tp, false> : __optional_copy_assign_base<_Tp>
+{
+using value_type = _Tp;
+using __optional_copy_assign_base<_Tp>::__optional_copy_assign_base;
+
+_LIBCPP_INLINE_VISIBILITY
+__optional_move_assign_base() = default;
+_LIBCPP_INLINE_VISIBILITY
+__optional_move_assign_base(const __optional_move_assign_base& __opt) = default;
+_LIBCPP_INLINE_VISIBILITY
+

[PATCH] D33955: [libcxx] [test] Remove a Clang/C2 workaround.

2017-06-06 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter accepted this revision.
CaseyCarter added a comment.
This revision is now accepted and ready to land.

As the party who originally put this workaround in place, I'll happily certify 
that it never affected any platforms that anyone but we Microsofters care 
about. I'll take responsibility for any buildbot fallout - forward any nasty 
notices to me.


https://reviews.llvm.org/D33955



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32385: [libcxx] optional: Implement LWG 2900 and P0602

2017-06-06 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 101631.
CaseyCarter edited the summary of this revision.
CaseyCarter added a comment.

Incorporate the libcxx test tree `special_member_gen` test into the std test, 
making my per-SMF triviality tests unnecessary.


https://reviews.llvm.org/D32385

Files:
  include/optional
  test/libcxx/utilities/optional/optional.object/special_member_gen.pass.cpp
  
test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp
  test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
  test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
  test/std/utilities/optional/optional.object/special_member_gen.pass.cpp

Index: test/std/utilities/optional/optional.object/special_member_gen.pass.cpp
===
--- test/std/utilities/optional/optional.object/special_member_gen.pass.cpp
+++ test/std/utilities/optional/optional.object/special_member_gen.pass.cpp
@@ -33,10 +33,38 @@
 "optional is copy assignable if and only if T is both copy "
 "constructible and copy assignable.");
 static_assert(std::is_move_assignable_v ==
-((std::is_copy_constructible_v && std::is_copy_assignable_v) ||
- (std::is_move_constructible_v && std::is_move_assignable_v)),
-"optional is move assignable if and only if T is both move assignable and "
-"move constructible, or both copy constructible and copy assignable.");
+((std::is_move_constructible_v && std::is_move_assignable_v) ||
+ (std::is_copy_constructible_v && std::is_copy_assignable_v)),
+"optional is move assignable if and only if T is both move constructible and "
+"move assignable, or both copy constructible and copy assignable.");
+
+// The following tests are for not-yet-standardized behavior (P0602):
+static_assert(std::is_trivially_destructible_v ==
+std::is_trivially_destructible_v,
+"optional is trivially destructible if and only if T is.");
+static_assert(std::is_trivially_copy_constructible_v ==
+std::is_trivially_copy_constructible_v,
+"optional is trivially copy constructible if and only if T is.");
+static_assert(std::is_trivially_move_constructible_v ==
+std::is_trivially_move_constructible_v ||
+(!std::is_move_constructible_v && std::is_trivially_copy_constructible_v),
+"optional is trivially move constructible if T is trivially move constructible, "
+"or if T is trivially copy constructible and is not move constructible.");
+static_assert(std::is_trivially_copy_assignable_v ==
+(std::is_trivially_destructible_v &&
+ std::is_trivially_copy_constructible_v &&
+ std::is_trivially_copy_assignable_v),
+"optional is trivially copy assignable if and only if T is trivially destructible, "
+"trivially copy constructible, and trivially copy assignable.");
+static_assert(std::is_trivially_move_assignable_v ==
+(std::is_trivially_destructible_v &&
+ ((std::is_trivially_move_constructible_v && std::is_trivially_move_assignable_v) ||
+  ((!std::is_move_constructible_v || !std::is_move_assignable_v) &&
+   std::is_trivially_copy_constructible_v && std::is_trivially_copy_assignable_v))),
+"optional is trivially move assignable if T is trivially destructible, and either "
+"(1) trivially move constructible and trivially move assignable, or "
+"(2) not move constructible or not move assignable, and "
+"trivially copy constructible and trivially copy assignable.");
 };
 
 template  static void sink(Args&&...) {}
Index: test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
@@ -55,10 +55,10 @@
 void test_throwing_ctor() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 struct Z {
-  Z() : count(0) {}
-  Z(Z&& o) : count(o.count + 1)
-  { if (count == 2) throw 6; }
-  int count;
+Z() : count(0) {}
+Z(Z&& o) : count(o.count + 1)
+{ if (count == 2) throw 6; }
+int count;
 };
 Z z;
 optional rhs(std::move(z));
@@ -157,7 +157,7 @@
 test(3);
 static_assert(constexpr_test(), "" );
 static_assert(constexpr_test(3), "" );
-	
+
 {
 optional o(42);
 optional o2(std::move(o));
Index: test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
@@ -45,10 +45,10 @@
 void test_throwing_ctor() {
 

[PATCH] D27850: [libcxx] add missing constexpr to optional::value_or

2017-06-06 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304813: add missing constexpr to optional::value_or 
(authored by CaseyCarter).

Changed prior to commit:
  https://reviews.llvm.org/D27850?vs=82653=101597#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27850

Files:
  libcxx/trunk/include/optional
  
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp


Index: libcxx/trunk/include/optional
===
--- libcxx/trunk/include/optional
+++ libcxx/trunk/include/optional
@@ -897,7 +897,7 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
-value_type value_or(_Up&& __v) &&
+constexpr value_type value_or(_Up&& __v) &&
 {
 static_assert(is_move_constructible_v,
   "optional::value_or: T must be move constructible");
Index: 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp
===
--- 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp
+++ 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp
@@ -10,7 +10,7 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// template  T optional::value_or(U&& v) &&;
+// template  constexpr T optional::value_or(U&& v) &&;
 
 #include 
 #include 
@@ -26,22 +26,22 @@
 {
 int i_;
 
-Y(int i) : i_(i) {}
+constexpr Y(int i) : i_(i) {}
 };
 
 struct X
 {
 int i_;
 
-X(int i) : i_(i) {}
-X(X&& x) : i_(x.i_) {x.i_ = 0;}
-X(const Y& y) : i_(y.i_) {}
-X(Y&& y) : i_(y.i_+1) {}
+constexpr X(int i) : i_(i) {}
+constexpr X(X&& x) : i_(x.i_) {x.i_ = 0;}
+constexpr X(const Y& y) : i_(y.i_) {}
+constexpr X(Y&& y) : i_(y.i_+1) {}
 friend constexpr bool operator==(const X& x, const X& y)
 {return x.i_ == y.i_;}
 };
 
-int main()
+constexpr int test()
 {
 {
 optional opt(in_place, 2);
@@ -65,4 +65,10 @@
 assert(std::move(opt).value_or(Y(3)) == 4);
 assert(!opt);
 }
+return 0;
+}
+
+int main()
+{
+static_assert(test() == 0);
 }


Index: libcxx/trunk/include/optional
===
--- libcxx/trunk/include/optional
+++ libcxx/trunk/include/optional
@@ -897,7 +897,7 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
-value_type value_or(_Up&& __v) &&
+constexpr value_type value_or(_Up&& __v) &&
 {
 static_assert(is_move_constructible_v,
   "optional::value_or: T must be move constructible");
Index: libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp
===
--- libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp
+++ libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp
@@ -10,7 +10,7 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// template  T optional::value_or(U&& v) &&;
+// template  constexpr T optional::value_or(U&& v) &&;
 
 #include 
 #include 
@@ -26,22 +26,22 @@
 {
 int i_;
 
-Y(int i) : i_(i) {}
+constexpr Y(int i) : i_(i) {}
 };
 
 struct X
 {
 int i_;
 
-X(int i) : i_(i) {}
-X(X&& x) : i_(x.i_) {x.i_ = 0;}
-X(const Y& y) : i_(y.i_) {}
-X(Y&& y) : i_(y.i_+1) {}
+constexpr X(int i) : i_(i) {}
+constexpr X(X&& x) : i_(x.i_) {x.i_ = 0;}
+constexpr X(const Y& y) : i_(y.i_) {}
+constexpr X(Y&& y) : i_(y.i_+1) {}
 friend constexpr bool operator==(const X& x, const X& y)
 {return x.i_ == y.i_;}
 };
 
-int main()
+constexpr int test()
 {
 {
 optional opt(in_place, 2);
@@ -65,4 +65,10 @@
 assert(std::move(opt).value_or(Y(3)) == 4);
 assert(!opt);
 }
+return 0;
+}
+
+int main()
+{
+static_assert(test() == 0);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32515: [libcxx] [test] Changes to accommodate LWG 2904 "Make variant move-assignment more exception safe"

2017-06-05 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter abandoned this revision.
CaseyCarter added a comment.

Abandoning: these changes have been merged into https://reviews.llvm.org/D32671.


https://reviews.llvm.org/D32515



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32671: [libcxx] [test] variant: test coverage for LWG2904 and P0602

2017-06-05 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 101497.
CaseyCarter retitled this revision from "[libcxx] [test] variant: test coverage 
for P0602 extension" to "[libcxx] [test] variant: test coverage for LWG2904 and 
P0602".
CaseyCarter edited the summary of this revision.
CaseyCarter added a comment.

Massive update: Move the libcxx tree tests into std, merge my LWG2904 
differential.


https://reviews.llvm.org/D32671

Files:
  test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
  test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp
  test/libcxx/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
  test/libcxx/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
  test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp
  test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
  test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
  test/support/variant_test_helpers.hpp

Index: test/support/variant_test_helpers.hpp
===
--- test/support/variant_test_helpers.hpp
+++ test/support/variant_test_helpers.hpp
@@ -69,9 +69,9 @@
 void makeEmpty(Variant& v) {
 Variant v2(std::in_place_type);
 try {
-v = v2;
+v = std::move(v2);
 assert(false);
-}  catch (...) {
+} catch (...) {
 assert(v.valueless_by_exception());
 }
 }
Index: test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
===
--- test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
+++ test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
@@ -53,6 +53,34 @@
   MoveOnlyNT(MoveOnlyNT &) : value(other.value) { other.value = -1; }
 };
 
+struct NTMove {
+  constexpr NTMove(int v) : value(v) {}
+  NTMove(const NTMove &) = delete;
+  NTMove(NTMove &) : value(that.value) { that.value = -1; }
+  int value;
+};
+
+static_assert(!std::is_trivially_move_constructible::value, "");
+static_assert(std::is_move_constructible::value, "");
+
+struct TMove {
+  constexpr TMove(int v) : value(v) {}
+  TMove(const TMove &) = delete;
+  TMove(TMove &&) = default;
+  int value;
+};
+
+static_assert(std::is_trivially_move_constructible::value, "");
+
+struct TMoveNTCopy {
+  constexpr TMoveNTCopy(int v) : value(v) {}
+  TMoveNTCopy(const TMoveNTCopy& that) : value(that.value) {}
+  TMoveNTCopy(TMoveNTCopy&&) = default;
+  int value;
+};
+
+static_assert(std::is_trivially_move_constructible::value, "");
+
 #ifndef TEST_HAS_NO_EXCEPTIONS
 struct MakeEmptyT {
   static int alive;
@@ -73,7 +101,7 @@
 template  void makeEmpty(Variant ) {
   Variant v2(std::in_place_type);
   try {
-v = v2;
+v = std::move(v2);
 assert(false);
   } catch (...) {
 assert(v.valueless_by_exception());
@@ -117,8 +145,30 @@
 using V = std::variant;
 static_assert(!std::is_move_constructible::value, "");
   }
+
+  // The following tests are for not-yet-standardized behavior (P0602):
+  {
+using V = std::variant;
+static_assert(std::is_trivially_move_constructible::value, "");
+  }
+  {
+using V = std::variant;
+static_assert(!std::is_trivially_move_constructible::value, "");
+static_assert(std::is_move_constructible::value, "");
+  }
+  {
+using V = std::variant;
+static_assert(std::is_trivially_move_constructible::value, "");
+  }
+  {
+using V = std::variant;
+static_assert(std::is_trivially_move_constructible::value, "");
+  }
 }
 
+template 
+struct Result { size_t index; T value; };
+
 void test_move_ctor_basic() {
   {
 std::variant v(std::in_place_index<0>, 42);
@@ -162,6 +212,80 @@
 assert(std::get<1>(v).value == -1);
 assert(std::get<1>(v2).value == 42);
   }
+
+  // The following tests are for not-yet-standardized behavior (P0602):
+  {
+struct {
+  constexpr Result operator()() const {
+std::variant v(std::in_place_index<0>, 42);
+std::variant v2 = std::move(v);
+return {v2.index(), std::get<0>(std::move(v2))};
+  }
+} test;
+constexpr auto result = test();
+static_assert(result.index == 0, "");
+static_assert(result.value == 42, "");
+  }
+  {
+struct {
+  constexpr Result operator()() const {
+std::variant v(std::in_place_index<1>, 42);
+std::variant v2 = std::move(v);
+return {v2.index(), std::get<1>(std::move(v2))};
+  }
+} test;
+constexpr auto result = test();
+static_assert(result.index == 1, "");
+static_assert(result.value == 42, "");
+  }
+  {
+struct {
+  constexpr Result operator()() const {
+std::variant v(std::in_place_index<0>, 42);
+   

[PATCH] D32385: [libcxx] optional: Implement LWG 2900 and P0602

2017-06-04 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 101366.
CaseyCarter added a comment.

Fix merge conflicts.


https://reviews.llvm.org/D32385

Files:
  include/optional
  test/libcxx/utilities/optional/optional.object/special_member_gen.pass.cpp
  
test/std/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp
  
test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp
  test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
  test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
  test/std/utilities/optional/optional.object/special_member_gen.pass.cpp

Index: test/std/utilities/optional/optional.object/special_member_gen.pass.cpp
===
--- test/std/utilities/optional/optional.object/special_member_gen.pass.cpp
+++ test/std/utilities/optional/optional.object/special_member_gen.pass.cpp
@@ -33,10 +33,10 @@
 "optional is copy assignable if and only if T is both copy "
 "constructible and copy assignable.");
 static_assert(std::is_move_assignable_v ==
-((std::is_copy_constructible_v && std::is_copy_assignable_v) ||
- (std::is_move_constructible_v && std::is_move_assignable_v)),
-"optional is move assignable if and only if T is both move assignable and "
-"move constructible, or both copy constructible and copy assignable.");
+((std::is_move_constructible_v && std::is_move_assignable_v) ||
+ (std::is_copy_constructible_v && std::is_copy_assignable_v)),
+"optional is move assignable if and only if T is both move constructible and "
+"move assignable, or both copy constructible and copy assignable.");
 };
 
 template  static void sink(Args&&...) {}
Index: test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
@@ -55,10 +55,10 @@
 void test_throwing_ctor() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 struct Z {
-  Z() : count(0) {}
-  Z(Z&& o) : count(o.count + 1)
-  { if (count == 2) throw 6; }
-  int count;
+Z() : count(0) {}
+Z(Z&& o) : count(o.count + 1)
+{ if (count == 2) throw 6; }
+int count;
 };
 Z z;
 optional rhs(std::move(z));
@@ -150,6 +150,21 @@
 #endif
 }
 
+template
+constexpr bool triviality_test =
+std::is_trivially_move_constructible::value ==
+std::is_trivially_move_constructible::value;
+
+void test_triviality_extension() {
+#if defined(_LIBCPP_VER) || defined(_MSVC_STL_VER)
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+#endif
+}
 
 int main()
 {
@@ -200,9 +215,9 @@
 test();
 test(42);
 }
-{
-test_throwing_ctor();
-}
+
+test_throwing_ctor();
+
 {
 struct ThrowsMove {
   ThrowsMove() noexcept(false) {}
@@ -217,9 +232,10 @@
 };
 static_assert(std::is_nothrow_move_constructible::value, "");
 }
-{
-test_reference_extension();
-}
+
+test_reference_extension();
+test_triviality_extension();
+
 {
 constexpr std::optional o1{4};
 constexpr std::optional o2 = std::move(o1);
Index: test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
@@ -45,10 +45,10 @@
 void test_throwing_ctor() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 struct Z {
-  Z() : count(0) {}
-  Z(Z const& o) : count(o.count + 1)
-  { if (count == 2) throw 6; }
-  int count;
+Z() : count(0) {}
+Z(Z const& o) : count(o.count + 1)
+{ if (count == 2) throw 6; }
+int count;
 };
 const Z z;
 const optional rhs(z);
@@ -114,6 +114,22 @@
 #endif
 }
 
+template
+constexpr bool triviality_test =
+std::is_trivially_copy_constructible::value ==
+std::is_trivially_copy_constructible::value;
+
+void test_triviality_extension() {
+#if defined(_LIBCPP_VER) || defined(_MSVC_STL_VER)
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+#endif
+}
+
 int main()
 {
 test();
@@ -159,12 +175,9 @@
 test();
 test(42);
 }
-{

[PATCH] D33741: [libc++] Undef min/max in test_macros.h

2017-05-31 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

In https://reviews.llvm.org/D33741#769381, @EricWF wrote:

> In https://reviews.llvm.org/D33741#769371, @STL_MSFT wrote:
>
> > I haven't seen min/max test failures, probably because our CRT/STL headers 
> > never drag in Windows.h.
>
>
> Ah, that makes sense. Libc++ currently does although the plan is to fix that 
> eventually. :-S


Are you aware that Windows.h won't define `min` and `max` if you define 
`NOMINMAX` before including it? You could solve the problem by adding 
`-DNOMINMAX` to your test compile parameters.


https://reviews.llvm.org/D33741



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33290: [libcxx] [test] Remove workaround for C1XX conversion-to-nullptr bug

2017-05-25 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
CaseyCarter marked an inline comment as done.
Closed by commit rL303889: [test] Remove workaround for C1XX 
conversion-to-nullptr bug (authored by CaseyCarter).

Changed prior to commit:
  https://reviews.llvm.org/D33290?vs=99336=100265#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33290

Files:
  libcxx/trunk/test/support/poisoned_hash_helper.hpp
  
libcxx/trunk/test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
  libcxx/trunk/test/support/test_workarounds.h


Index: 
libcxx/trunk/test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
===
--- 
libcxx/trunk/test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
+++ 
libcxx/trunk/test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
@@ -1,29 +0,0 @@
-//===--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-// UNSUPPORTED: c++98, c++03
-
-// Verify TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR.
-
-#include 
-
-#include "test_workarounds.h"
-
-struct ConvertsToNullptr {
-  using DestType = decltype(nullptr);
-  operator DestType() const { return nullptr; }
-};
-
-int main() {
-#if defined(TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR)
-  static_assert(!std::is_convertible::value, "");
-#else
-  static_assert(std::is_convertible::value, "");
-#endif
-}
Index: libcxx/trunk/test/support/test_workarounds.h
===
--- libcxx/trunk/test/support/test_workarounds.h
+++ libcxx/trunk/test/support/test_workarounds.h
@@ -14,15 +14,14 @@
 #include "test_macros.h"
 
 #if defined(TEST_COMPILER_EDG)
-# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR // VSO#424280
 #endif
 
 #if defined(TEST_COMPILER_C1XX)
-# define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
-# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
-# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
+# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE // VSO#117743
+# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION // VSO#109062
 # ifndef _MSC_EXTENSIONS
-#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
+#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK // VSO#119998
 # endif
 #endif
 
Index: libcxx/trunk/test/support/poisoned_hash_helper.hpp
===
--- libcxx/trunk/test/support/poisoned_hash_helper.hpp
+++ libcxx/trunk/test/support/poisoned_hash_helper.hpp
@@ -50,11 +50,9 @@
 // specializations of hash for nullptr t and all cv-unqualified
 // arithmetic, enumeration, and pointer types.
 using LibraryHashTypes = TypeList<
-#if !defined(TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR)
 #if TEST_STD_VER > 14
   decltype(nullptr),
 #endif
-#endif
   bool,
   char,
   signed char,


Index: libcxx/trunk/test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
===
--- libcxx/trunk/test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
+++ libcxx/trunk/test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
@@ -1,29 +0,0 @@
-//===--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-// UNSUPPORTED: c++98, c++03
-
-// Verify TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR.
-
-#include 
-
-#include "test_workarounds.h"
-
-struct ConvertsToNullptr {
-  using DestType = decltype(nullptr);
-  operator DestType() const { return nullptr; }
-};
-
-int main() {
-#if defined(TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR)
-  static_assert(!std::is_convertible::value, "");
-#else
-  static_assert(std::is_convertible::value, "");
-#endif
-}
Index: libcxx/trunk/test/support/test_workarounds.h
===
--- libcxx/trunk/test/support/test_workarounds.h
+++ libcxx/trunk/test/support/test_workarounds.h
@@ -14,15 +14,14 @@
 #include "test_macros.h"
 
 #if 

[PATCH] D33214: [libcxx] [test] Workaround C1XX bug in uses_allocator_types.hpp

2017-05-25 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303888: [test] Workaround C1XX bug in 
uses_allocator_types.hpp (authored by CaseyCarter).

Changed prior to commit:
  https://reviews.llvm.org/D33214?vs=99086=100264#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33214

Files:
  
libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair.pass.cpp
  
libcxx/trunk/test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp
  libcxx/trunk/test/support/test_workarounds.h
  libcxx/trunk/test/support/uses_alloc_types.hpp

Index: libcxx/trunk/test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp
===
--- libcxx/trunk/test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp
+++ libcxx/trunk/test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp
@@ -0,0 +1,49 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// Verify TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION.
+
+#include 
+
+#include "test_workarounds.h"
+
+template
+struct identity {
+using type = T;
+};
+
+template struct list {};
+
+// C1XX believes this function template is not viable when LArgs is an empty
+// parameter pack.
+template 
+int f2(typename identity::type..., int i) {
+return i;
+}
+
+#ifdef TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
+// C1XX believes this function template *is* viable when LArgs is an empty
+// parameter pack. Conforming compilers believe the two overloads are
+// ambiguous when LArgs is an empty pack.
+template 
+int f2(int i) {
+return i;
+}
+#endif
+
+template 
+int f1(list, Args&&... args) {
+return f2(args...);
+}
+
+int main() {
+f1(list<>{}, 42);
+}
Index: libcxx/trunk/test/support/uses_alloc_types.hpp
===
--- libcxx/trunk/test/support/uses_alloc_types.hpp
+++ libcxx/trunk/test/support/uses_alloc_types.hpp
@@ -15,6 +15,7 @@
 #include 
 
 #include "test_macros.h"
+#include "test_workarounds.h"
 #include "type_id.h"
 
 // There are two forms of uses-allocator construction:
@@ -256,6 +257,13 @@
 return alloc;
 }
 
+#ifdef TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
+template 
+static CtorAlloc getAllocatorFromPackImp(CtorAlloc const& alloc) {
+return alloc;
+}
+#endif
+
 bool has_alloc() const { return alloc_store.get_allocator() != nullptr; }
 const CtorAlloc *get_alloc() const { return alloc_store.get_allocator(); }
 public:
Index: libcxx/trunk/test/support/test_workarounds.h
===
--- libcxx/trunk/test/support/test_workarounds.h
+++ libcxx/trunk/test/support/test_workarounds.h
@@ -20,6 +20,7 @@
 #if defined(TEST_COMPILER_C1XX)
 # define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
 # define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
+# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
 # ifndef _MSC_EXTENSIONS
 #  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 # endif
Index: libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair.pass.cpp
===
--- libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair.pass.cpp
+++ libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair.pass.cpp
@@ -39,6 +39,7 @@
 using SA = std::scoped_allocator_adaptor;
 static_assert(std::uses_allocator::value, "");
 Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
+assert(ptr);
 Alloc CA(P);
 SA A(CA);
 A.construct(ptr);
@@ -61,6 +62,7 @@
 using SA = std::scoped_allocator_adaptor;
 static_assert(std::uses_allocator::value, "");
 Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
+assert(ptr);
 Alloc CA(P);
 SA A(CA);
 A.construct(ptr);
@@ -77,7 +79,6 @@
 
 void test_with_inner_alloc()
 {
-using VoidAlloc1 = CountingAllocator;
 using VoidAlloc2 = CountingAllocator;
 
 AllocController POuter;
@@ -93,6 +94,7 @@
 static_assert(!std::uses_allocator::value, "");
 static_assert(std::uses_allocator::value, "");
 Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
+assert(ptr);
 Outer O(POuter);
 Inner I(PInner);
 SA A(O, I);
@@ -119,6 +121,7 @@
   

[PATCH] D33290: [libcxx] [test] Remove workaround for C1XX conversion-to-nullptr bug

2017-05-17 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter marked an inline comment as done.
CaseyCarter added inline comments.



Comment at: test/support/test_workarounds.h:21
 #if defined(TEST_COMPILER_C1XX)
-# define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
-# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE

STL_MSFT wrote:
> Do you need to go update the tests that were using this?
Yes, thanks, `poisoned_hash_helper.hpp` didn't make it into the commit.


https://reviews.llvm.org/D33290



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33290: [libcxx] [test] Remove workaround for C1XX conversion-to-nullptr bug

2017-05-17 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 99336.
CaseyCarter added a comment.

Commit the change to the affected test code as well.


https://reviews.llvm.org/D33290

Files:
  test/support/poisoned_hash_helper.hpp
  test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
  test/support/test_workarounds.h


Index: test/support/test_workarounds.h
===
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -14,15 +14,14 @@
 #include "test_macros.h"
 
 #if defined(TEST_COMPILER_EDG)
-# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR // VSO#424280
 #endif
 
 #if defined(TEST_COMPILER_C1XX)
-# define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
-# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
-# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
+# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE // VSO#117743
+# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION // VSO#109062
 # ifndef _MSC_EXTENSIONS
-#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
+#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK // VSO#119998
 # endif
 #endif
 
Index: 
test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
===
--- 
test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-//===--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-// UNSUPPORTED: c++98, c++03
-
-// Verify TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR.
-
-#include 
-
-#include "test_workarounds.h"
-
-struct ConvertsToNullptr {
-  using DestType = decltype(nullptr);
-  operator DestType() const { return nullptr; }
-};
-
-int main() {
-#if defined(TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR)
-  static_assert(!std::is_convertible::value, "");
-#else
-  static_assert(std::is_convertible::value, "");
-#endif
-}
Index: test/support/poisoned_hash_helper.hpp
===
--- test/support/poisoned_hash_helper.hpp
+++ test/support/poisoned_hash_helper.hpp
@@ -50,11 +50,9 @@
 // specializations of hash for nullptr t and all cv-unqualified
 // arithmetic, enumeration, and pointer types.
 using LibraryHashTypes = TypeList<
-#if !defined(TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR)
 #if TEST_STD_VER > 14
   decltype(nullptr),
 #endif
-#endif
   bool,
   char,
   signed char,


Index: test/support/test_workarounds.h
===
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -14,15 +14,14 @@
 #include "test_macros.h"
 
 #if defined(TEST_COMPILER_EDG)
-# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR // VSO#424280
 #endif
 
 #if defined(TEST_COMPILER_C1XX)
-# define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
-# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
-# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
+# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE // VSO#117743
+# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION // VSO#109062
 # ifndef _MSC_EXTENSIONS
-#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
+#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK // VSO#119998
 # endif
 #endif
 
Index: test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
===
--- test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-//===--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-// UNSUPPORTED: c++98, c++03
-
-// Verify TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR.
-
-#include 
-
-#include "test_workarounds.h"
-
-struct ConvertsToNullptr {
-  using DestType = decltype(nullptr);
-  operator DestType() const { return nullptr; }
-};
-
-int main() {
-#if defined(TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR)
-  static_assert(!std::is_convertible::value, "");
-#else
-  

[PATCH] D33290: [libcxx] [test] Remove workaround for C1XX conversion-to-nullptr bug

2017-05-17 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.

VSO#391542 "Types can't be convertible to nullptr_t," which will be fixed in 
the next release of Visual C++.

Also put internal bug numbers on the workarounds in test_workarounds.h for ease 
of correlation.


https://reviews.llvm.org/D33290

Files:
  test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
  test/support/test_workarounds.h


Index: test/support/test_workarounds.h
===
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -14,15 +14,14 @@
 #include "test_macros.h"
 
 #if defined(TEST_COMPILER_EDG)
-# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR // VSO#424280
 #endif
 
 #if defined(TEST_COMPILER_C1XX)
-# define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
-# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
-# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
+# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE // VSO#117743
+# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION // VSO#109062
 # ifndef _MSC_EXTENSIONS
-#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
+#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK // VSO#119998
 # endif
 #endif
 
Index: 
test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
===
--- 
test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-//===--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-// UNSUPPORTED: c++98, c++03
-
-// Verify TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR.
-
-#include 
-
-#include "test_workarounds.h"
-
-struct ConvertsToNullptr {
-  using DestType = decltype(nullptr);
-  operator DestType() const { return nullptr; }
-};
-
-int main() {
-#if defined(TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR)
-  static_assert(!std::is_convertible::value, "");
-#else
-  static_assert(std::is_convertible::value, "");
-#endif
-}


Index: test/support/test_workarounds.h
===
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -14,15 +14,14 @@
 #include "test_macros.h"
 
 #if defined(TEST_COMPILER_EDG)
-# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR // VSO#424280
 #endif
 
 #if defined(TEST_COMPILER_C1XX)
-# define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
-# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
-# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
+# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE // VSO#117743
+# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION // VSO#109062
 # ifndef _MSC_EXTENSIONS
-#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
+#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK // VSO#119998
 # endif
 #endif
 
Index: test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
===
--- test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-//===--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-// UNSUPPORTED: c++98, c++03
-
-// Verify TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR.
-
-#include 
-
-#include "test_workarounds.h"
-
-struct ConvertsToNullptr {
-  using DestType = decltype(nullptr);
-  operator DestType() const { return nullptr; }
-};
-
-int main() {
-#if defined(TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR)
-  static_assert(!std::is_convertible::value, "");
-#else
-  static_assert(std::is_convertible::value, "");
-#endif
-}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33214: [libcxx] [test] Workaround C1XX bug in uses_allocator_types.hpp

2017-05-15 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 99086.
CaseyCarter edited the summary of this revision.
CaseyCarter added a comment.

Silence warnings.


https://reviews.llvm.org/D33214

Files:
  
test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair.pass.cpp
  test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp
  test/support/test_workarounds.h
  test/support/uses_alloc_types.hpp

Index: test/support/uses_alloc_types.hpp
===
--- test/support/uses_alloc_types.hpp
+++ test/support/uses_alloc_types.hpp
@@ -15,6 +15,7 @@
 #include 
 
 #include "test_macros.h"
+#include "test_workarounds.h"
 #include "type_id.h"
 
 // There are two forms of uses-allocator construction:
@@ -256,6 +257,13 @@
 return alloc;
 }
 
+#ifdef TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
+template 
+static CtorAlloc getAllocatorFromPackImp(CtorAlloc const& alloc) {
+return alloc;
+}
+#endif
+
 bool has_alloc() const { return alloc_store.get_allocator() != nullptr; }
 const CtorAlloc *get_alloc() const { return alloc_store.get_allocator(); }
 public:
Index: test/support/test_workarounds.h
===
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -20,6 +20,7 @@
 #if defined(TEST_COMPILER_C1XX)
 # define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
 # define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
+# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
 # ifndef _MSC_EXTENSIONS
 #  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 # endif
Index: test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp
===
--- /dev/null
+++ test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp
@@ -0,0 +1,49 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// Verify TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION.
+
+#include 
+
+#include "test_workarounds.h"
+
+template
+struct identity {
+using type = T;
+};
+
+template struct list {};
+
+// C1XX believes this function template is not viable when LArgs is an empty
+// parameter pack.
+template 
+int f2(typename identity::type..., int i) {
+return i;
+}
+
+#ifdef TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
+// C1XX believes this function template *is* viable when LArgs is an empty
+// parameter pack. Conforming compilers believe the two overloads are
+// ambiguous when LArgs is an empty pack.
+template 
+int f2(int i) {
+return i;
+}
+#endif
+
+template 
+int f1(list, Args&&... args) {
+return f2(args...);
+}
+
+int main() {
+f1(list<>{}, 42);
+}
Index: test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair.pass.cpp
===
--- test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair.pass.cpp
+++ test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair.pass.cpp
@@ -39,6 +39,7 @@
 using SA = std::scoped_allocator_adaptor;
 static_assert(std::uses_allocator::value, "");
 Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
+assert(ptr);
 Alloc CA(P);
 SA A(CA);
 A.construct(ptr);
@@ -61,6 +62,7 @@
 using SA = std::scoped_allocator_adaptor;
 static_assert(std::uses_allocator::value, "");
 Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
+assert(ptr);
 Alloc CA(P);
 SA A(CA);
 A.construct(ptr);
@@ -77,7 +79,6 @@
 
 void test_with_inner_alloc()
 {
-using VoidAlloc1 = CountingAllocator;
 using VoidAlloc2 = CountingAllocator;
 
 AllocController POuter;
@@ -93,6 +94,7 @@
 static_assert(!std::uses_allocator::value, "");
 static_assert(std::uses_allocator::value, "");
 Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
+assert(ptr);
 Outer O(POuter);
 Inner I(PInner);
 SA A(O, I);
@@ -119,6 +121,7 @@
 static_assert(!std::uses_allocator::value, "");
 static_assert(std::uses_allocator::value, "");
 Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
+assert(ptr);
 Outer O(POuter);
 Inner I(PInner);
 SA A(O, I);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D33214: [libcxx] [test] Workaround C1XX bug in uses_allocator_types.hpp

2017-05-15 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.

Needed by IIRC 
allocator.adaptor\allocator.adaptor.members\construct_pair.pass.cpp.


https://reviews.llvm.org/D33214

Files:
  test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp
  test/support/test_workarounds.h
  test/support/uses_alloc_types.hpp


Index: test/support/uses_alloc_types.hpp
===
--- test/support/uses_alloc_types.hpp
+++ test/support/uses_alloc_types.hpp
@@ -15,6 +15,7 @@
 #include 
 
 #include "test_macros.h"
+#include "test_workarounds.h"
 #include "type_id.h"
 
 // There are two forms of uses-allocator construction:
@@ -256,6 +257,13 @@
 return alloc;
 }
 
+#ifdef TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
+template 
+static CtorAlloc getAllocatorFromPackImp(CtorAlloc const& alloc) {
+return alloc;
+}
+#endif
+
 bool has_alloc() const { return alloc_store.get_allocator() != nullptr; }
 const CtorAlloc *get_alloc() const { return alloc_store.get_allocator(); }
 public:
Index: test/support/test_workarounds.h
===
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -20,6 +20,7 @@
 #if defined(TEST_COMPILER_C1XX)
 # define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
 # define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
+# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
 # ifndef _MSC_EXTENSIONS
 #  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 # endif
Index: 
test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp
===
--- /dev/null
+++ test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp
@@ -0,0 +1,49 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// Verify TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION.
+
+#include 
+
+#include "test_workarounds.h"
+
+template
+struct identity {
+using type = T;
+};
+
+template struct list {};
+
+// C1XX believes this function template is not viable when LArgs is an empty
+// parameter pack.
+template 
+int f2(typename identity::type..., int i) {
+return i;
+}
+
+#ifdef TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
+// C1XX believes this function template *is* viable when LArgs is an empty
+// parameter pack. Conforming compilers believe the two overloads are
+// ambiguous when LArgs is an empty pack.
+template 
+int f2(int i) {
+return i;
+}
+#endif
+
+template 
+int f1(list, Args&&... args) {
+return f2(args...);
+}
+
+int main() {
+f1(list<>{}, 42);
+}


Index: test/support/uses_alloc_types.hpp
===
--- test/support/uses_alloc_types.hpp
+++ test/support/uses_alloc_types.hpp
@@ -15,6 +15,7 @@
 #include 
 
 #include "test_macros.h"
+#include "test_workarounds.h"
 #include "type_id.h"
 
 // There are two forms of uses-allocator construction:
@@ -256,6 +257,13 @@
 return alloc;
 }
 
+#ifdef TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
+template 
+static CtorAlloc getAllocatorFromPackImp(CtorAlloc const& alloc) {
+return alloc;
+}
+#endif
+
 bool has_alloc() const { return alloc_store.get_allocator() != nullptr; }
 const CtorAlloc *get_alloc() const { return alloc_store.get_allocator(); }
 public:
Index: test/support/test_workarounds.h
===
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -20,6 +20,7 @@
 #if defined(TEST_COMPILER_C1XX)
 # define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
 # define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
+# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
 # ifndef _MSC_EXTENSIONS
 #  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 # endif
Index: test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp
===
--- /dev/null
+++ test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp
@@ -0,0 +1,49 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// Verify 

[PATCH] D32778: [libcxx] [test] Conditionally workaround C1XX/EDG bugs

2017-05-10 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302707: [test] support machinery changes for EDG & C1XX /Za 
(authored by CaseyCarter).

Changed prior to commit:
  https://reviews.llvm.org/D32778?vs=97530=98503#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32778

Files:
  libcxx/trunk/test/support/archetypes.hpp
  libcxx/trunk/test/support/archetypes.ipp
  libcxx/trunk/test/support/msvc_stdlib_force_include.hpp
  libcxx/trunk/test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
  libcxx/trunk/test/support/test_macros.h
  libcxx/trunk/test/support/test_workarounds.h

Index: libcxx/trunk/test/support/test_macros.h
===
--- libcxx/trunk/test/support/test_macros.h
+++ libcxx/trunk/test/support/test_macros.h
@@ -52,10 +52,12 @@
 #define TEST_HAS_BUILTIN_IDENTIFIER(X) 0
 #endif
 
-#if defined(__clang__)
-#define TEST_COMPILER_CLANG
+#if defined(__EDG__)
+# define TEST_COMPILER_EDG
+#elif defined(__clang__)
+# define TEST_COMPILER_CLANG
 # if defined(__apple_build_version__)
-#   define TEST_COMPILER_APPLE_CLANG
+#  define TEST_COMPILER_APPLE_CLANG
 # endif
 #elif defined(_MSC_VER)
 # define TEST_COMPILER_C1XX
Index: libcxx/trunk/test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
===
--- libcxx/trunk/test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
+++ libcxx/trunk/test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
@@ -0,0 +1,41 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// Verify TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK.
+
+#include 
+
+#include "test_workarounds.h"
+
+struct X {
+X(int) {}
+
+X(X&&) = default;
+X& operator=(X&&) = default;
+
+private:
+X(const X&) = default;
+X& operator=(const X&) = default;
+};
+
+void PushFront(X&&) {}
+
+template
+auto test(int) -> decltype(PushFront(std::declval()), std::true_type{});
+auto test(long) -> std::false_type;
+
+int main() {
+#if defined(TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK)
+static_assert(!decltype(test(0))::value, "");
+#else
+static_assert(decltype(test(0))::value, "");
+#endif
+}
Index: libcxx/trunk/test/support/test_workarounds.h
===
--- libcxx/trunk/test/support/test_workarounds.h
+++ libcxx/trunk/test/support/test_workarounds.h
@@ -13,9 +13,16 @@
 
 #include "test_macros.h"
 
+#if defined(TEST_COMPILER_EDG)
+# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+#endif
+
 #if defined(TEST_COMPILER_C1XX)
 # define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
 # define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
+# ifndef _MSC_EXTENSIONS
+#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
+# endif
 #endif
 
 #endif // SUPPORT_TEST_WORKAROUNDS_H
Index: libcxx/trunk/test/support/archetypes.ipp
===
--- libcxx/trunk/test/support/archetypes.ipp
+++ libcxx/trunk/test/support/archetypes.ipp
@@ -6,7 +6,11 @@
 #define DEFINE_EXPLICIT
 #endif
 #ifndef DEFINE_CONSTEXPR
+#ifdef TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+#define DEFINE_CONSTEXPR
+#else // TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
 #define DEFINE_CONSTEXPR constexpr
+#endif // TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
 #endif
 #ifndef DEFINE_ASSIGN_CONSTEXPR
 #if TEST_STD_VER >= 14
Index: libcxx/trunk/test/support/archetypes.hpp
===
--- libcxx/trunk/test/support/archetypes.hpp
+++ libcxx/trunk/test/support/archetypes.hpp
@@ -5,6 +5,7 @@
 #include 
 
 #include "test_macros.h"
+#include "test_workarounds.h"
 
 #if TEST_STD_VER >= 11
 
@@ -14,7 +15,9 @@
 struct DepType : T {};
 
 struct NullBase {
+#ifndef TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
   NullBase() = default;
   NullBase(NullBase const&) = default;
   NullBase& operator=(NullBase const&) = default;
@@ -81,7 +84,9 @@
   ++assigned; ++value_assigned;
   return *this;
 }
+#ifndef TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 ~TestBase() {
   assert(value != -999); assert(alive > 0);
   --alive; ++destroyed; value = -999;
@@ -144,7 +149,9 @@
 }
 //~ValueBase() { assert(value != -999); value = -999; }
 int value;
+#ifndef TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 constexpr static int check_value(int const& 

[PATCH] D32510: [libcxx] Fix C1XX implementation of DoNotOptimize

2017-05-04 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302162: [test] Name the local variable in the C1XX 
implementation of DoNotOptmize (authored by CaseyCarter).

Changed prior to commit:
  https://reviews.llvm.org/D32510?vs=96648=97837#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32510

Files:
  libcxx/trunk/test/support/test_macros.h


Index: libcxx/trunk/test/support/test_macros.h
===
--- libcxx/trunk/test/support/test_macros.h
+++ libcxx/trunk/test/support/test_macros.h
@@ -209,7 +209,8 @@
 #include 
 template 
 inline void DoNotOptimize(Tp const& value) {
-  const volatile void* volatile = __builtin_addressof(value);
+  const volatile void* volatile unused = __builtin_addressof(value);
+  static_cast(unused);
   _ReadWriteBarrier();
 }
 #endif


Index: libcxx/trunk/test/support/test_macros.h
===
--- libcxx/trunk/test/support/test_macros.h
+++ libcxx/trunk/test/support/test_macros.h
@@ -209,7 +209,8 @@
 #include 
 template 
 inline void DoNotOptimize(Tp const& value) {
-  const volatile void* volatile = __builtin_addressof(value);
+  const volatile void* volatile unused = __builtin_addressof(value);
+  static_cast(unused);
   _ReadWriteBarrier();
 }
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32385: [libcxx] optional: Implement LWG 2900 and P0602

2017-05-04 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

In https://reviews.llvm.org/D32385#745771, @EricWF wrote:

> So Itanium ABI has this quirk where trivial types are passed using different 
> conventions than non-trivial types. This means changing the triviality of 
> `std::optional` for any instantiation is potentially ABI breaking. I'll need 
> to do more investigation to find out how this will affect libc++, and if we 
> can take this change.


libc++ committed to ABI stability for `optional`, a new feature of C++17, 
before the standard shipped?


https://reviews.llvm.org/D32385



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32671: [libcxx] [test] variant: test coverage for P0602 extension

2017-05-04 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 97834.
CaseyCarter added a comment.

The constexpr variant tests were enabled separate commit 
(https://reviews.llvm.org/rL302158). This differential now contains only the 
fine-grained SMF triviality extension test.


https://reviews.llvm.org/D32671

Files:
  test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
  test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp

Index: test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
===
--- test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
+++ test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
@@ -197,10 +197,30 @@
 #endif
 }
 
+template
+constexpr bool triviality_test =
+  std::is_trivially_move_constructible::value ==
+std::conjunction::value;
+
+void test_triviality_extension() {
+#if defined(_MSVC_STL_VER)
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+#endif
+}
+
 int main() {
   test_move_ctor_basic();
   test_move_ctor_valueless_by_exception();
   test_move_noexcept();
   test_move_ctor_sfinae();
   test_constexpr_move_ctor_extension();
+  test_triviality_extension();
 }
Index: test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
===
--- test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
+++ test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
@@ -159,9 +159,27 @@
 #endif
 }
 
+template
+constexpr bool triviality_test =
+  std::is_trivially_copy_constructible::value ==
+std::conjunction::value;
+
+void test_triviality_extension() {
+#if defined(_MSVC_STL_VER)
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+#endif
+}
+
 int main() {
   test_copy_ctor_basic();
   test_copy_ctor_valueless_by_exception();
   test_copy_ctor_sfinae();
   test_constexpr_copy_ctor_extension();
+  test_triviality_extension();
 }
Index: test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
===
--- test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
+++ test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
@@ -308,12 +308,63 @@
 #endif
 }
 
+template
+constexpr bool triviality_test =
+  // move assignment of variant is trivial when
+  std::is_trivially_move_assignable::value ==
+std::conjunction<
+  // All Ts are trivially destructible and
+  std::is_trivially_destructible...,
+  // either
+  std::disjunction<
+// All Ts are trivially move (constructible and assignable) so that
+// variant's move assignment operator is non-deleted and trivial, or
+std::conjunction<
+  std::is_trivially_move_constructible...,
+  std::is_trivially_move_assignable...>,
+// At least one of the Ts is not move (constructible or assignable) so
+// that variant's move assignment operator is *implicitly* deleted but
+// all of the Ts are trivially *copy* (constructible and assignable) so
+// that move assignment actually invokes the trivial copy assignment
+// operator.
+std::conjunction<
+  std::disjunction<
+std::negation...,
+std::negation...>,
+  std::is_trivially_copy_constructible...,
+  std::is_trivially_copy_assignable...>>>::value;
+
+void test_triviality_extension() {
+#if defined(_MSVC_STL_VER)
+  struct TrivialCopyNontrivialMove {
+TrivialCopyNontrivialMove(TrivialCopyNontrivialMove const&) = default;
+TrivialCopyNontrivialMove(TrivialCopyNontrivialMove&&) noexcept {}
+TrivialCopyNontrivialMove& operator=(TrivialCopyNontrivialMove const&) = default;
+TrivialCopyNontrivialMove& operator=(TrivialCopyNontrivialMove&&) noexcept {
+  return *this;
+}
+  };
+
+  static_assert(triviality_test, 

[PATCH] D32385: [libcxx] optional: Implement LWG 2900 and P0602

2017-05-03 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 97769.
CaseyCarter added a comment.

Polish: clarify `static_assert` messages, DeMorgan a clause so it more 
precisely reflects the `static_assert` message.


https://reviews.llvm.org/D32385

Files:
  include/optional
  test/libcxx/utilities/optional/optional.object/special_member_gen.pass.cpp
  
test/std/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp
  
test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp
  test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
  test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
  test/std/utilities/optional/optional.object/special_member_gen.pass.cpp
  test/support/msvc_stdlib_force_include.hpp

Index: test/support/msvc_stdlib_force_include.hpp
===
--- test/support/msvc_stdlib_force_include.hpp
+++ test/support/msvc_stdlib_force_include.hpp
@@ -26,6 +26,11 @@
 #error This header may not be used when targeting libc++
 #endif
 
+// Indicates that we are using the MSVC standard library.
+#ifndef _MSVC_STL_VER
+#define _MSVC_STL_VER 42
+#endif
+
 struct AssertionDialogAvoider {
 AssertionDialogAvoider() {
 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
Index: test/std/utilities/optional/optional.object/special_member_gen.pass.cpp
===
--- test/std/utilities/optional/optional.object/special_member_gen.pass.cpp
+++ test/std/utilities/optional/optional.object/special_member_gen.pass.cpp
@@ -33,10 +33,10 @@
 "optional is copy assignable if and only if T is both copy "
 "constructible and copy assignable.");
 static_assert(std::is_move_assignable_v ==
-((std::is_copy_constructible_v && std::is_copy_assignable_v) ||
- (std::is_move_constructible_v && std::is_move_assignable_v)),
-"optional is move assignable if and only if T is both move assignable and "
-"move constructible, or both copy constructible and copy assignable.");
+((std::is_move_constructible_v && std::is_move_assignable_v) ||
+ (std::is_copy_constructible_v && std::is_copy_assignable_v)),
+"optional is move assignable if and only if T is both move constructible and "
+"move assignable, or both copy constructible and copy assignable.");
 };
 
 template  static void sink(Args&&...) {}
Index: test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
@@ -10,7 +10,10 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// optional(optional&& rhs);
+// constexpr optional(optional&& rhs);
+//   If is_trivially_move_constructible_v is true,
+//this constructor shall be a constexpr constructor.
+
 
 #include 
 #include 
@@ -36,10 +39,10 @@
 void test_throwing_ctor() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 struct Z {
-  Z() : count(0) {}
-  Z(Z&& o) : count(o.count + 1)
-  { if (count == 2) throw 6; }
-  int count;
+Z() : count(0) {}
+Z(Z&& o) : count(o.count + 1)
+{ if (count == 2) throw 6; }
+int count;
 };
 Z z;
 optional rhs(std::move(z));
@@ -131,6 +134,48 @@
 #endif
 }
 
+constexpr bool test_constexpr()
+{
+{
+using T = int;
+optional o1{};
+optional o2 = std::move(o1);
+static_cast(o2);
+optional o3{T{42}};
+optional o4 = std::move(o3);
+static_cast(o4);
+}
+{
+struct T {
+constexpr T(int) {}
+T(T&&) = default;
+};
+optional o1{};
+optional o2 = std::move(o1);
+static_cast(o2);
+optional o3{T{42}};
+optional o4 = std::move(o3);
+static_cast(o4);
+}
+return true;
+}
+static_assert(test_constexpr(), "");
+
+template
+constexpr bool triviality_test =
+std::is_trivially_move_constructible::value ==
+std::is_trivially_move_constructible::value;
+
+void test_triviality_extension() {
+#if defined(_LIBCPP_VER) || defined(_MSVC_STL_VER)
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+#endif
+}
 
 int main()
 {
@@ -178,9 +223,9 @@
 test();
 test(42);
 }
-{
-test_throwing_ctor();
-}
+
+test_throwing_ctor();
+
 {
 struct ThrowsMove {
   ThrowsMove() noexcept(false) {}
@@ -195,7 +240,7 @@
 };
 static_assert(std::is_nothrow_move_constructible::value, "");
 }
-{
-  

[PATCH] D32671: [libcxx] [test] variant: test coverage for P0602 extension

2017-05-03 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 97768.
CaseyCarter added a comment.

Fix typos in 
test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp.


https://reviews.llvm.org/D32671

Files:
  test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
  test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
  test/support/msvc_stdlib_force_include.hpp
  test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
  test/support/test_workarounds.h

Index: test/support/test_workarounds.h
===
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -15,6 +15,7 @@
 
 #if defined(TEST_COMPILER_C1XX)
 # define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
+# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
 #endif
 
 #endif // SUPPORT_TEST_WORKAROUNDS_H
Index: test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
===
--- /dev/null
+++ test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
@@ -0,0 +1,31 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// Verify TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE.
+
+#include 
+
+#include "test_workarounds.h"
+
+struct S {
+  S(S const&) = default;
+  S(S&&) = default;
+  S& operator=(S const&) = delete;
+  S& operator=(S&&) = delete;
+};
+
+int main() {
+#if defined(TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE)
+  static_assert(!std::is_trivially_copyable::value, "");
+#else
+  static_assert(std::is_trivially_copyable::value, "");
+#endif
+}
Index: test/support/msvc_stdlib_force_include.hpp
===
--- test/support/msvc_stdlib_force_include.hpp
+++ test/support/msvc_stdlib_force_include.hpp
@@ -26,6 +26,11 @@
 #error This header may not be used when targeting libc++
 #endif
 
+// Indicates that we are using the MSVC standard library.
+#ifndef _MSVC_STL_VER
+#define _MSVC_STL_VER 42
+#endif
+
 struct AssertionDialogAvoider {
 AssertionDialogAvoider() {
 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
Index: test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
===
--- test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
+++ test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
@@ -22,6 +22,7 @@
 #include 
 
 #include "test_macros.h"
+#include "test_workarounds.h"
 
 struct ThrowsMove {
   ThrowsMove(ThrowsMove &&) noexcept(false) {}
@@ -178,20 +179,48 @@
 }
 
 void test_constexpr_move_ctor_extension() {
-#ifdef _LIBCPP_VERSION
+#if defined(_LIBCPP_VER) || defined(_MSVC_STL_VER)
   using V = std::variant;
+#ifdef TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
+  static_assert(std::is_trivially_destructible::value, "");
+  static_assert(std::is_trivially_copy_constructible::value, "");
+  static_assert(std::is_trivially_move_constructible::value, "");
+  static_assert(!std::is_copy_assignable::value, "");
+  static_assert(!std::is_move_assignable::value, "");
+#else
   static_assert(std::is_trivially_copyable::value, "");
+#endif
   static_assert(std::is_trivially_move_constructible::value, "");
   static_assert(test_constexpr_ctor_extension_imp<0>(V(42l)), "");
   static_assert(test_constexpr_ctor_extension_imp<1>(V(nullptr)), "");
   static_assert(test_constexpr_ctor_extension_imp<2>(V(101)), "");
 #endif
 }
 
+template
+constexpr bool triviality_test =
+  std::is_trivially_move_constructible::value ==
+std::conjunction::value;
+
+void test_triviality_extension() {
+#if defined(_MSVC_STL_VER)
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+#endif
+}
+
 int main() {
   test_move_ctor_basic();
   test_move_ctor_valueless_by_exception();
   test_move_noexcept();
   test_move_ctor_sfinae();
   test_constexpr_move_ctor_extension();
+  

[PATCH] D32778: [libcxx] [test] Conditionally workaround C1XX/EDG bugs

2017-05-02 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added inline comments.



Comment at: test/support/archetypes.hpp:20
 protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
   NullBase() = default;

STL_MSFT wrote:
> I think that this comment doesn't match the ifndef check, but it's a style 
> question.
I know which style *I* prefer, because I wrote it, and I know which style *you* 
prefer, because you commented. I'll change this when Marshall or Eric let me 
know what they prefer here.



Comment at: test/support/archetypes.ipp:10
+#ifdef TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+#define DEFINE_CONSTEXPR
+#else // TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR

STL_MSFT wrote:
> Should you define it to be `inline` instead of nothing?
This macro is typically defined to either `constexpr` or nothing - see the 
definitions in `archetypes.hpp` above.


https://reviews.llvm.org/D32778



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32778: [libcxx] [test] Conditionally workaround C1XX/EDG bugs

2017-05-02 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.

Test support machinery changes needed to parse with EDG and compile with C1XX's 
/Za flag that disables MS extensions.

I try to make changes to `` and the `optional`/`variant` tests 
simultaneously in the MS STL and in libc++, which realistically requires that I 
keep the tests largely synchronized between libc++ and our internal test suite. 
As a first step toward automating that integration, I'd like to upstream this 
patch.

This change works around a couple of bugs:

1. EDG doesn't like explicit constexpr in a derived class. This program:

  struct Base {};
  
  struct Derived : Base {
  constexpr Derived() = default;
  };

triggers "error: defaulted default constructor cannot be constexpr."

2. C1XX with /Za has no idea which constructor needs to be valid for copy 
elision.

The change also conditionally disables parts of the 
msvc_stdlib_force_include.hpp header that conflict with external configuration 
when `_LIBCXX_IN_DEVCRT` is defined.


https://reviews.llvm.org/D32778

Files:
  test/support/archetypes.hpp
  test/support/archetypes.ipp
  test/support/msvc_stdlib_force_include.hpp
  test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
  test/support/test_macros.h
  test/support/test_workarounds.h

Index: test/support/test_workarounds.h
===
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -13,9 +13,16 @@
 
 #include "test_macros.h"
 
+#if defined(TEST_COMPILER_EDG)
+# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+#endif
+
 #if defined(TEST_COMPILER_C1XX)
 # define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
 # define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
+# ifndef _MSC_EXTENSIONS
+#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
+# endif
 #endif
 
 #endif // SUPPORT_TEST_WORKAROUNDS_H
Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -52,10 +52,12 @@
 #define TEST_HAS_BUILTIN_IDENTIFIER(X) 0
 #endif
 
-#if defined(__clang__)
-#define TEST_COMPILER_CLANG
+#if defined(__EDG__)
+# define TEST_COMPILER_EDG
+#elif defined(__clang__)
+# define TEST_COMPILER_CLANG
 # if defined(__apple_build_version__)
-#   define TEST_COMPILER_APPLE_CLANG
+#  define TEST_COMPILER_APPLE_CLANG
 # endif
 #elif defined(_MSC_VER)
 # define TEST_COMPILER_C1XX
Index: test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
===
--- /dev/null
+++ test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
@@ -0,0 +1,41 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// Verify TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK.
+
+#include 
+
+#include "test_workarounds.h"
+
+struct X {
+X(int) {}
+
+X(X&&) = default;
+X& operator=(X&&) = default;
+
+private:
+X(const X&) = default;
+X& operator=(const X&) = default;
+};
+
+void PushFront(X&&) {}
+
+template
+auto test(int) -> decltype(PushFront(std::declval()), std::true_type{});
+auto test(long) -> std::false_type;
+
+int main() {
+#if defined(TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK)
+static_assert(!decltype(test(0))::value, "");
+#else
+static_assert(decltype(test(0))::value, "");
+#endif
+}
Index: test/support/msvc_stdlib_force_include.hpp
===
--- test/support/msvc_stdlib_force_include.hpp
+++ test/support/msvc_stdlib_force_include.hpp
@@ -13,11 +13,13 @@
 // This header is force-included when running the libc++ tests against the
 // MSVC standard library.
 
-// Silence warnings about CRT machinery.
-#define _CRT_SECURE_NO_WARNINGS
+#ifndef _LIBCXX_IN_DEVCRT
+// Silence warnings about CRT machinery.
+#define _CRT_SECURE_NO_WARNINGS
 
-// Avoid assertion dialogs.
-#define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()
+// Avoid assertion dialogs.
+#define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()
+#endif // _LIBCXX_IN_DEVCRT
 
 #include 
 #include 
@@ -31,6 +33,7 @@
 #define _MSVC_STL_VER 42
 #endif
 
+#ifndef _LIBCXX_IN_DEVCRT
 struct AssertionDialogAvoider {
 AssertionDialogAvoider() {
 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
@@ -42,6 +45,7 @@
 };
 
 const AssertionDialogAvoider assertion_dialog_avoider{};
+#endif // _LIBCXX_IN_DEVCRT
 
 // MSVC frontend only configurations
 #if !defined(__clang__)
@@ -69,15 +73,17 @@
 // MSVC has quick_exit() and at_quick_exit().
 #define _LIBCPP_HAS_QUICK_EXIT
 
-// atomic_is_lock_free.pass.cpp needs this 

[PATCH] D32671: [libcxx] [test] variant: test coverage for P0602 extension

2017-05-01 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 97367.
CaseyCarter added a comment.

Fix missing indent in msvc_stdlib_force_include.hpp


https://reviews.llvm.org/D32671

Files:
  test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
  test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
  test/support/msvc_stdlib_force_include.hpp
  test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
  test/support/test_workarounds.h

Index: test/support/test_workarounds.h
===
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -15,6 +15,7 @@
 
 #if defined(TEST_COMPILER_C1XX)
 # define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
+# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
 #endif
 
 #endif // SUPPORT_TEST_WORKAROUNDS_H
Index: test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
===
--- /dev/null
+++ test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
@@ -0,0 +1,31 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// Verify TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE.
+
+#include 
+
+#include "test_workarounds.h"
+
+struct S {
+  S(S const&) = default;
+  S(S&&) = default;
+  S& operator=(S const&) = delete;
+  S& operator=(S&&) = delete;
+};
+
+int main() {
+#if defined(TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE)
+  static_assert(!std::is_trivially_copyable::value, "");
+#else
+  static_assert(std::is_trivially_copyable::value, "");
+#endif
+}
Index: test/support/msvc_stdlib_force_include.hpp
===
--- test/support/msvc_stdlib_force_include.hpp
+++ test/support/msvc_stdlib_force_include.hpp
@@ -26,6 +26,11 @@
 #error This header may not be used when targeting libc++
 #endif
 
+// Indicates that we are using the MSVC standard library.
+#ifndef _MSVC_STL_VER
+#define _MSVC_STL_VER 42
+#endif
+
 struct AssertionDialogAvoider {
 AssertionDialogAvoider() {
 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
Index: test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
===
--- test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
+++ test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
@@ -22,6 +22,7 @@
 #include 
 
 #include "test_macros.h"
+#include "test_workarounds.h"
 
 struct ThrowsMove {
   ThrowsMove(ThrowsMove &&) noexcept(false) {}
@@ -178,20 +179,48 @@
 }
 
 void test_constexpr_move_ctor_extension() {
-#ifdef _LIBCPP_VERSION
+#if defined(_LIBCPP_VER) || defined(_MSVC_STL_VER)
   using V = std::variant;
+#ifdef TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
+  static_assert(std::is_trivially_destructible::value, "");
+  static_assert(std::is_trivially_copy_constructible::value, "");
+  static_assert(std::is_trivially_move_constructible::value, "");
+  static_assert(!std::is_copy_assignable::value, "");
+  static_assert(!std::is_move_assignable::value, "");
+#else
   static_assert(std::is_trivially_copyable::value, "");
+#endif
   static_assert(std::is_trivially_move_constructible::value, "");
   static_assert(test_constexpr_ctor_extension_imp<0>(V(42l)), "");
   static_assert(test_constexpr_ctor_extension_imp<1>(V(nullptr)), "");
   static_assert(test_constexpr_ctor_extension_imp<2>(V(101)), "");
 #endif
 }
 
+template
+constexpr bool triviality_test =
+  std::is_trivially_move_constructible::value ==
+std::conjunction::value;
+
+void test_triviality_extension() {
+#if defined(_MSVC_STL_VER)
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+#endif
+}
+
 int main() {
   test_move_ctor_basic();
   test_move_ctor_valueless_by_exception();
   test_move_noexcept();
   test_move_ctor_sfinae();
   test_constexpr_move_ctor_extension();
+  test_triviality_extension();
 }
Index: 

[PATCH] D32385: [libcxx] optional: Implement LWG 2900 and P0602

2017-05-01 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 97366.
CaseyCarter added a comment.

Fix a missing indent in the `msvc_stdlib_force_include.hpp` change.


https://reviews.llvm.org/D32385

Files:
  include/optional
  test/libcxx/utilities/optional/optional.object/special_member_gen.pass.cpp
  
test/std/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp
  
test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp
  test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
  test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
  test/support/msvc_stdlib_force_include.hpp

Index: test/support/msvc_stdlib_force_include.hpp
===
--- test/support/msvc_stdlib_force_include.hpp
+++ test/support/msvc_stdlib_force_include.hpp
@@ -26,6 +26,11 @@
 #error This header may not be used when targeting libc++
 #endif
 
+// Indicates that we are using the MSVC standard library.
+#ifndef _MSVC_STL_VER
+#define _MSVC_STL_VER 42
+#endif
+
 struct AssertionDialogAvoider {
 AssertionDialogAvoider() {
 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
Index: test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
@@ -10,7 +10,10 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// optional(optional&& rhs);
+// constexpr optional(optional&& rhs);
+//   If is_trivially_move_constructible_v is true,
+//this constructor shall be a constexpr constructor.
+
 
 #include 
 #include 
@@ -36,10 +39,10 @@
 void test_throwing_ctor() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 struct Z {
-  Z() : count(0) {}
-  Z(Z&& o) : count(o.count + 1)
-  { if (count == 2) throw 6; }
-  int count;
+Z() : count(0) {}
+Z(Z&& o) : count(o.count + 1)
+{ if (count == 2) throw 6; }
+int count;
 };
 Z z;
 optional rhs(std::move(z));
@@ -131,6 +134,48 @@
 #endif
 }
 
+constexpr bool test_constexpr()
+{
+{
+using T = int;
+optional o1{};
+optional o2 = std::move(o1);
+static_cast(o2);
+optional o3{T{42}};
+optional o4 = std::move(o3);
+static_cast(o4);
+}
+{
+struct T {
+constexpr T(int) {}
+T(T&&) = default;
+};
+optional o1{};
+optional o2 = std::move(o1);
+static_cast(o2);
+optional o3{T{42}};
+optional o4 = std::move(o3);
+static_cast(o4);
+}
+return true;
+}
+static_assert(test_constexpr(), "");
+
+template
+constexpr bool triviality_test =
+std::is_trivially_move_constructible::value ==
+std::is_trivially_move_constructible::value;
+
+void test_triviality_extension() {
+#if defined(_LIBCPP_VER) || defined(_MSVC_STL_VER)
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+#endif
+}
 
 int main()
 {
@@ -178,9 +223,9 @@
 test();
 test(42);
 }
-{
-test_throwing_ctor();
-}
+
+test_throwing_ctor();
+
 {
 struct ThrowsMove {
   ThrowsMove() noexcept(false) {}
@@ -195,7 +240,7 @@
 };
 static_assert(std::is_nothrow_move_constructible::value, "");
 }
-{
-test_reference_extension();
-}
+
+test_reference_extension();
+test_triviality_extension();
 }
Index: test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
@@ -10,7 +10,9 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// optional(const optional& rhs);
+// constexpr optional(const optional& rhs);
+//   If is_trivially_copy_constructible_v is true,
+//this constructor shall be a constexpr constructor.
 
 #include 
 #include 
@@ -35,10 +37,10 @@
 void test_throwing_ctor() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 struct Z {
-  Z() : count(0) {}
-  Z(Z const& o) : count(o.count + 1)
-  { if (count == 2) throw 6; }
-  int count;
+Z() : count(0) {}
+Z(Z const& o) : count(o.count + 1)
+{ if (count == 2) throw 6; }
+int count;
 };
 const Z z;
 const optional rhs(z);
@@ -104,6 +106,48 @@
 #endif
 }
 
+constexpr bool test_constexpr()
+{
+{
+using T = int;
+optional o1{};
+optional o2 = o1;
+

[PATCH] D32309: [libcxx] [test] Resolve compiler warnings in LCM/GCD tests

2017-04-30 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added inline comments.



Comment at: test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp:144
+auto res1 = std::lcm(static_cast(1234), INT32_MIN);
+(void)std::lcm(INT_MIN, 2UL);  // this used to trigger UBSAN
+static_assert(std::is_same::value, "");

`INT_MIN` is in `` .


https://reviews.llvm.org/D32309



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32385: [libcxx] optional: Implement LWG 2900 and P0602

2017-04-30 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 97217.
CaseyCarter added a comment.

Update libc++-specific special member test for extended P0602 implementation.


https://reviews.llvm.org/D32385

Files:
  include/optional
  test/libcxx/utilities/optional/optional.object/special_member_gen.pass.cpp
  
test/std/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp
  
test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp
  test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
  test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
  test/support/msvc_stdlib_force_include.hpp

Index: test/support/msvc_stdlib_force_include.hpp
===
--- test/support/msvc_stdlib_force_include.hpp
+++ test/support/msvc_stdlib_force_include.hpp
@@ -26,6 +26,11 @@
 #error This header may not be used when targeting libc++
 #endif
 
+// Indicates that we are using the MSVC standard library.
+#ifndef _MSVC_STL_VER
+#define _MSVC_STL_VER 42
+#endif
+
 struct AssertionDialogAvoider {
 AssertionDialogAvoider() {
 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
Index: test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
@@ -10,7 +10,10 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// optional(optional&& rhs);
+// constexpr optional(optional&& rhs);
+//   If is_trivially_move_constructible_v is true,
+//this constructor shall be a constexpr constructor.
+
 
 #include 
 #include 
@@ -36,10 +39,10 @@
 void test_throwing_ctor() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 struct Z {
-  Z() : count(0) {}
-  Z(Z&& o) : count(o.count + 1)
-  { if (count == 2) throw 6; }
-  int count;
+Z() : count(0) {}
+Z(Z&& o) : count(o.count + 1)
+{ if (count == 2) throw 6; }
+int count;
 };
 Z z;
 optional rhs(std::move(z));
@@ -131,6 +134,48 @@
 #endif
 }
 
+constexpr bool test_constexpr()
+{
+{
+using T = int;
+optional o1{};
+optional o2 = std::move(o1);
+static_cast(o2);
+optional o3{T{42}};
+optional o4 = std::move(o3);
+static_cast(o4);
+}
+{
+struct T {
+constexpr T(int) {}
+T(T&&) = default;
+};
+optional o1{};
+optional o2 = std::move(o1);
+static_cast(o2);
+optional o3{T{42}};
+optional o4 = std::move(o3);
+static_cast(o4);
+}
+return true;
+}
+static_assert(test_constexpr(), "");
+
+template
+constexpr bool triviality_test =
+std::is_trivially_move_constructible::value ==
+std::is_trivially_move_constructible::value;
+
+void test_triviality_extension() {
+#if defined(_LIBCPP_VER) || defined(_MSVC_STL_VER)
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+#endif
+}
 
 int main()
 {
@@ -178,9 +223,9 @@
 test();
 test(42);
 }
-{
-test_throwing_ctor();
-}
+
+test_throwing_ctor();
+
 {
 struct ThrowsMove {
   ThrowsMove() noexcept(false) {}
@@ -195,7 +240,7 @@
 };
 static_assert(std::is_nothrow_move_constructible::value, "");
 }
-{
-test_reference_extension();
-}
+
+test_reference_extension();
+test_triviality_extension();
 }
Index: test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
@@ -10,7 +10,9 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// optional(const optional& rhs);
+// constexpr optional(const optional& rhs);
+//   If is_trivially_copy_constructible_v is true,
+//this constructor shall be a constexpr constructor.
 
 #include 
 #include 
@@ -35,10 +37,10 @@
 void test_throwing_ctor() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 struct Z {
-  Z() : count(0) {}
-  Z(Z const& o) : count(o.count + 1)
-  { if (count == 2) throw 6; }
-  int count;
+Z() : count(0) {}
+Z(Z const& o) : count(o.count + 1)
+{ if (count == 2) throw 6; }
+int count;
 };
 const Z z;
 const optional rhs(z);
@@ -104,6 +106,48 @@
 #endif
 }
 
+constexpr bool test_constexpr()
+{
+{
+using T = int;
+optional o1{};
+optional o2 = o1;
+   

[PATCH] D32671: [libcxx] [test] variant: test coverage for P0602 extension

2017-04-29 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 97204.
CaseyCarter added a comment.

Fix a weird corner case in variant's move assignment triviality test.


https://reviews.llvm.org/D32671

Files:
  test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
  test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
  test/support/msvc_stdlib_force_include.hpp
  test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
  test/support/test_workarounds.h

Index: test/support/test_workarounds.h
===
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -15,6 +15,7 @@
 
 #if defined(TEST_COMPILER_C1XX)
 # define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
+# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
 #endif
 
 #endif // SUPPORT_TEST_WORKAROUNDS_H
Index: test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
===
--- /dev/null
+++ test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
@@ -0,0 +1,31 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// Verify TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE.
+
+#include 
+
+#include "test_workarounds.h"
+
+struct S {
+  S(S const&) = default;
+  S(S&&) = default;
+  S& operator=(S const&) = delete;
+  S& operator=(S&&) = delete;
+};
+
+int main() {
+#if defined(TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE)
+  static_assert(!std::is_trivially_copyable::value, "");
+#else
+  static_assert(std::is_trivially_copyable::value, "");
+#endif
+}
Index: test/support/msvc_stdlib_force_include.hpp
===
--- test/support/msvc_stdlib_force_include.hpp
+++ test/support/msvc_stdlib_force_include.hpp
@@ -26,6 +26,11 @@
 #error This header may not be used when targeting libc++
 #endif
 
+// Indicates that we are using the MSVC standard library.
+#ifndef _MSVC_STL_VER
+#define _MSVC_STL_VER 42
+#endif
+
 struct AssertionDialogAvoider {
 AssertionDialogAvoider() {
 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
Index: test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
===
--- test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
+++ test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
@@ -22,6 +22,7 @@
 #include 
 
 #include "test_macros.h"
+#include "test_workarounds.h"
 
 struct ThrowsMove {
   ThrowsMove(ThrowsMove &&) noexcept(false) {}
@@ -178,20 +179,48 @@
 }
 
 void test_constexpr_move_ctor_extension() {
-#ifdef _LIBCPP_VERSION
+#if defined(_LIBCPP_VER) || defined(_MSVC_STL_VER)
   using V = std::variant;
+#ifdef TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
+  static_assert(std::is_trivially_destructible::value, "");
+  static_assert(std::is_trivially_copy_constructible::value, "");
+  static_assert(std::is_trivially_move_constructible::value, "");
+  static_assert(!std::is_copy_assignable::value, "");
+  static_assert(!std::is_move_assignable::value, "");
+#else
   static_assert(std::is_trivially_copyable::value, "");
+#endif
   static_assert(std::is_trivially_move_constructible::value, "");
   static_assert(test_constexpr_ctor_extension_imp<0>(V(42l)), "");
   static_assert(test_constexpr_ctor_extension_imp<1>(V(nullptr)), "");
   static_assert(test_constexpr_ctor_extension_imp<2>(V(101)), "");
 #endif
 }
 
+template
+constexpr bool triviality_test =
+  std::is_trivially_move_constructible::value ==
+std::conjunction::value;
+
+void test_triviality_extension() {
+#if defined(_MSVC_STL_VER)
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+#endif
+}
+
 int main() {
   test_move_ctor_basic();
   test_move_ctor_valueless_by_exception();
   test_move_noexcept();
   test_move_ctor_sfinae();
   test_constexpr_move_ctor_extension();
+  test_triviality_extension();
 }
Index: 

[PATCH] D32385: [libcxx] optional: Implement LWG 2900 and P0602

2017-04-29 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 97203.
CaseyCarter added a comment.

Fix comment typo in optional.object.assign/move.pass.cpp


https://reviews.llvm.org/D32385

Files:
  include/optional
  
test/std/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp
  
test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp
  test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
  test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
  test/support/msvc_stdlib_force_include.hpp

Index: test/support/msvc_stdlib_force_include.hpp
===
--- test/support/msvc_stdlib_force_include.hpp
+++ test/support/msvc_stdlib_force_include.hpp
@@ -26,6 +26,11 @@
 #error This header may not be used when targeting libc++
 #endif
 
+// Indicates that we are using the MSVC standard library.
+#ifndef _MSVC_STL_VER
+#define _MSVC_STL_VER 42
+#endif
+
 struct AssertionDialogAvoider {
 AssertionDialogAvoider() {
 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
Index: test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
@@ -10,7 +10,10 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// optional(optional&& rhs);
+// constexpr optional(optional&& rhs);
+//   If is_trivially_move_constructible_v is true,
+//this constructor shall be a constexpr constructor.
+
 
 #include 
 #include 
@@ -36,10 +39,10 @@
 void test_throwing_ctor() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 struct Z {
-  Z() : count(0) {}
-  Z(Z&& o) : count(o.count + 1)
-  { if (count == 2) throw 6; }
-  int count;
+Z() : count(0) {}
+Z(Z&& o) : count(o.count + 1)
+{ if (count == 2) throw 6; }
+int count;
 };
 Z z;
 optional rhs(std::move(z));
@@ -131,6 +134,48 @@
 #endif
 }
 
+constexpr bool test_constexpr()
+{
+{
+using T = int;
+optional o1{};
+optional o2 = std::move(o1);
+static_cast(o2);
+optional o3{T{42}};
+optional o4 = std::move(o3);
+static_cast(o4);
+}
+{
+struct T {
+constexpr T(int) {}
+T(T&&) = default;
+};
+optional o1{};
+optional o2 = std::move(o1);
+static_cast(o2);
+optional o3{T{42}};
+optional o4 = std::move(o3);
+static_cast(o4);
+}
+return true;
+}
+static_assert(test_constexpr(), "");
+
+template
+constexpr bool triviality_test =
+std::is_trivially_move_constructible::value ==
+std::is_trivially_move_constructible::value;
+
+void test_triviality_extension() {
+#if defined(_LIBCPP_VER) || defined(_MSVC_STL_VER)
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+#endif
+}
 
 int main()
 {
@@ -178,9 +223,9 @@
 test();
 test(42);
 }
-{
-test_throwing_ctor();
-}
+
+test_throwing_ctor();
+
 {
 struct ThrowsMove {
   ThrowsMove() noexcept(false) {}
@@ -195,7 +240,7 @@
 };
 static_assert(std::is_nothrow_move_constructible::value, "");
 }
-{
-test_reference_extension();
-}
+
+test_reference_extension();
+test_triviality_extension();
 }
Index: test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
@@ -10,7 +10,9 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// optional(const optional& rhs);
+// constexpr optional(const optional& rhs);
+//   If is_trivially_copy_constructible_v is true,
+//this constructor shall be a constexpr constructor.
 
 #include 
 #include 
@@ -35,10 +37,10 @@
 void test_throwing_ctor() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 struct Z {
-  Z() : count(0) {}
-  Z(Z const& o) : count(o.count + 1)
-  { if (count == 2) throw 6; }
-  int count;
+Z() : count(0) {}
+Z(Z const& o) : count(o.count + 1)
+{ if (count == 2) throw 6; }
+int count;
 };
 const Z z;
 const optional rhs(z);
@@ -104,6 +106,48 @@
 #endif
 }
 
+constexpr bool test_constexpr()
+{
+{
+using T = int;
+optional o1{};
+optional o2 = o1;
+static_cast(o2);
+optional o3{T{42}};
+optional o4 = o3;
+

[PATCH] D32671: [libcxx] [test] variant: test coverage for P0602 extension

2017-04-29 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.

NOTE: Unlike my typical `variant` test PRs, this one is actually safe to merge 
- crazy, I know - since it only adds coverage while testing the VC++ STL.



- Define a new macro `_MSVC_STL_VER` to distinguish testing the VC++ standard 
library implementation in the style of `_LIBCPP_VER`.

- Enable the "constexpr extension" tests for variant's copy/move constructors 
on VC++

- Add some new "triviality extension" tests for variant's conformance to P0602, 
currently only enabled on VC++

- Workaround C1XX's buggy `__is_trivially_copyable` in the variant tests.


https://reviews.llvm.org/D32671

Files:
  test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
  test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
  test/support/msvc_stdlib_force_include.hpp
  test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
  test/support/test_workarounds.h

Index: test/support/test_workarounds.h
===
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -15,6 +15,7 @@
 
 #if defined(TEST_COMPILER_C1XX)
 # define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
+# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
 #endif
 
 #endif // SUPPORT_TEST_WORKAROUNDS_H
Index: test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
===
--- /dev/null
+++ test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
@@ -0,0 +1,31 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// Verify TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE.
+
+#include 
+
+#include "test_workarounds.h"
+
+struct S {
+  S(S const&) = default;
+  S(S&&) = default;
+  S& operator=(S const&) = delete;
+  S& operator=(S&&) = delete;
+};
+
+int main() {
+#if defined(TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE)
+  static_assert(!std::is_trivially_copyable::value, "");
+#else
+  static_assert(std::is_trivially_copyable::value, "");
+#endif
+}
Index: test/support/msvc_stdlib_force_include.hpp
===
--- test/support/msvc_stdlib_force_include.hpp
+++ test/support/msvc_stdlib_force_include.hpp
@@ -26,6 +26,11 @@
 #error This header may not be used when targeting libc++
 #endif
 
+// Indicates that we are using the MSVC standard library.
+#ifndef _MSVC_STL_VER
+#define _MSVC_STL_VER 42
+#endif
+
 struct AssertionDialogAvoider {
 AssertionDialogAvoider() {
 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
Index: test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
===
--- test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
+++ test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
@@ -22,6 +22,7 @@
 #include 
 
 #include "test_macros.h"
+#include "test_workarounds.h"
 
 struct ThrowsMove {
   ThrowsMove(ThrowsMove &&) noexcept(false) {}
@@ -178,20 +179,48 @@
 }
 
 void test_constexpr_move_ctor_extension() {
-#ifdef _LIBCPP_VERSION
+#if defined(_LIBCPP_VER) || defined(_MSVC_STL_VER)
   using V = std::variant;
+#ifdef TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
+  static_assert(std::is_trivially_destructible::value, "");
+  static_assert(std::is_trivially_copy_constructible::value, "");
+  static_assert(std::is_trivially_move_constructible::value, "");
+  static_assert(!std::is_copy_assignable::value, "");
+  static_assert(!std::is_move_assignable::value, "");
+#else
   static_assert(std::is_trivially_copyable::value, "");
+#endif
   static_assert(std::is_trivially_move_constructible::value, "");
   static_assert(test_constexpr_ctor_extension_imp<0>(V(42l)), "");
   static_assert(test_constexpr_ctor_extension_imp<1>(V(nullptr)), "");
   static_assert(test_constexpr_ctor_extension_imp<2>(V(101)), "");
 #endif
 }
 
+template
+constexpr bool triviality_test =
+  std::is_trivially_move_constructible::value ==
+std::conjunction::value;
+
+void test_triviality_extension() {
+#if defined(_MSVC_STL_VER)
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  

[PATCH] D32385: [libcxx] optional: Implement LWG 2900 and P0602

2017-04-29 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 97188.
CaseyCarter retitled this revision from "[libcxx] Implement LWG 2900 "The copy 
and move constructors of optional are not constexpr"" to "[libcxx] optional: 
Implement LWG 2900 and P0602".
CaseyCarter edited the summary of this revision.
CaseyCarter added a comment.

- Define new macro `_MSVC_STL_VER` in msvc_stdlib_force_include.hpp to indicate 
that the VC++ standard library is being tested.
- Implement test coverage for P0602 "variant and optional should propagate 
copy/move triviality".


https://reviews.llvm.org/D32385

Files:
  include/optional
  
test/std/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp
  
test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp
  test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
  test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
  test/support/msvc_stdlib_force_include.hpp

Index: test/support/msvc_stdlib_force_include.hpp
===
--- test/support/msvc_stdlib_force_include.hpp
+++ test/support/msvc_stdlib_force_include.hpp
@@ -26,6 +26,11 @@
 #error This header may not be used when targeting libc++
 #endif
 
+// Indicates that we are using the MSVC standard library.
+#ifndef _MSVC_STL_VER
+#define _MSVC_STL_VER 42
+#endif
+
 struct AssertionDialogAvoider {
 AssertionDialogAvoider() {
 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
Index: test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
@@ -10,7 +10,10 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// optional(optional&& rhs);
+// constexpr optional(const optional&& rhs);
+//   If is_trivially_move_constructible_v is true,
+//this constructor shall be a constexpr constructor.
+
 
 #include 
 #include 
@@ -36,10 +39,10 @@
 void test_throwing_ctor() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 struct Z {
-  Z() : count(0) {}
-  Z(Z&& o) : count(o.count + 1)
-  { if (count == 2) throw 6; }
-  int count;
+Z() : count(0) {}
+Z(Z&& o) : count(o.count + 1)
+{ if (count == 2) throw 6; }
+int count;
 };
 Z z;
 optional rhs(std::move(z));
@@ -131,6 +134,48 @@
 #endif
 }
 
+constexpr bool test_constexpr()
+{
+{
+using T = int;
+optional o1{};
+optional o2 = std::move(o1);
+static_cast(o2);
+optional o3{T{42}};
+optional o4 = std::move(o3);
+static_cast(o4);
+}
+{
+struct T {
+constexpr T(int) {}
+T(T&&) = default;
+};
+optional o1{};
+optional o2 = std::move(o1);
+static_cast(o2);
+optional o3{T{42}};
+optional o4 = std::move(o3);
+static_cast(o4);
+}
+return true;
+}
+static_assert(test_constexpr(), "");
+
+template
+constexpr bool triviality_test =
+std::is_trivially_move_constructible::value ==
+std::is_trivially_move_constructible::value;
+
+void test_triviality_extension() {
+#if defined(_LIBCPP_VER) || defined(_MSVC_STL_VER)
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+#endif
+}
 
 int main()
 {
@@ -178,9 +223,9 @@
 test();
 test(42);
 }
-{
-test_throwing_ctor();
-}
+
+test_throwing_ctor();
+
 {
 struct ThrowsMove {
   ThrowsMove() noexcept(false) {}
@@ -195,7 +240,7 @@
 };
 static_assert(std::is_nothrow_move_constructible::value, "");
 }
-{
-test_reference_extension();
-}
+
+test_reference_extension();
+test_triviality_extension();
 }
Index: test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
@@ -10,7 +10,9 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// optional(const optional& rhs);
+// constexpr optional(const optional& rhs);
+//   If is_trivially_copy_constructible_v is true,
+//this constructor shall be a constexpr constructor.
 
 #include 
 #include 
@@ -35,10 +37,10 @@
 void test_throwing_ctor() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 struct Z {
-  Z() : count(0) {}
-  Z(Z const& o) : count(o.count + 1)
-  { if (count == 2) throw 6; }
-  int count;
+Z() : count(0) 

  1   2   >