Mark namespaces for user defined literals as 'inline'

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@192047 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/chrono b/include/chrono
index afc5181..2c65eee 100644
--- a/include/chrono
+++ b/include/chrono
@@ -942,12 +942,9 @@
 
 } // chrono
 
-#if _LIBCPP_STD_VER > 11 
-// Literal suffixes for chrono types
-// inline // Deviation from N3690.
-//    We believe the inline to be a defect and have submitted an LWG issue.
-//    An LWG issue number has not yet been assigned.
-namespace literals
+#if _LIBCPP_STD_VER > 11
+// Suffixes for duration literals [time.duration.literals]
+inline namespace literals
 { 
   inline namespace chrono_literals
   {
@@ -1018,6 +1015,11 @@
     }
 
 }}
+
+namespace chrono { // hoist the literals into namespace std::chrono
+   using namespace literals::chrono_literals;
+}
+
 #endif
 
 _LIBCPP_END_NAMESPACE_STD
diff --git a/include/string b/include/string
index 1ad8159..c98e22f 100644
--- a/include/string
+++ b/include/string
@@ -4158,10 +4158,7 @@
 
 #if _LIBCPP_STD_VER > 11 
 // Literal suffixes for basic_string [basic.string.literals]
-// inline // Deviation from N3690.
-//    We believe the inline to be a defect and have submitted an LWG issue.
-//    An LWG issue number has not yet been assigned.
-namespace literals
+inline namespace literals
 {
   inline namespace string_literals
   {
diff --git a/test/strings/basic.string.literals/literal1.fail.cpp b/test/strings/basic.string.literals/literal1.fail.cpp
index 16641f2..6ba0b30 100644
--- a/test/strings/basic.string.literals/literal1.fail.cpp
+++ b/test/strings/basic.string.literals/literal1.fail.cpp
@@ -13,9 +13,9 @@
 int main()
 {
 #if _LIBCPP_STD_VER > 11 
-    using namespace std;
+    using std::string;
 
-    std::string foo  =   ""s;  // should fail w/conversion operator not found
+    string foo  =   ""s;  // should fail w/conversion operator not found
 #else
 #error
 #endif
diff --git a/test/strings/basic.string.literals/literal3.pass.cpp b/test/strings/basic.string.literals/literal3.pass.cpp
new file mode 100644
index 0000000..98e3e40
--- /dev/null
+++ b/test/strings/basic.string.literals/literal3.pass.cpp
@@ -0,0 +1,20 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11 
+    using namespace std;
+
+    string foo  =   ""s;
+#endif
+}
diff --git a/test/utilities/time/time.duration/time.duration.literals/literals1.fail.cpp b/test/utilities/time/time.duration/time.duration.literals/literals1.fail.cpp
new file mode 100644
index 0000000..46aaa30
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.literals/literals1.fail.cpp
@@ -0,0 +1,21 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11 
+    std::chrono::hours h  = 4h;  // should fail w/conversion operator not found
+#else
+#error
+#endif
+}
+
diff --git a/test/utilities/time/time.duration/time.duration.literals/literals1.pass.cpp b/test/utilities/time/time.duration/time.duration.literals/literals1.pass.cpp
new file mode 100644
index 0000000..574f9bc
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.literals/literals1.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.
+//
+//===----------------------------------------------------------------------===//
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11 
+    using namespace std::chrono;
+
+    hours h = 4h;
+    assert ( h == hours(4));
+    auto h2 = 4.0h;
+    assert ( h == h2 );
+    
+    minutes min = 36min;
+    assert ( min == minutes(36));
+    auto min2 = 36.0min;
+    assert ( min == min2 );
+
+    seconds s = 24s;
+    assert ( s == seconds(24));
+    auto s2 = 24.0s;
+    assert ( s == s2 );
+
+    milliseconds ms = 247ms;
+    assert ( ms == milliseconds(247));
+    auto ms2 = 247.0ms;
+    assert ( ms == ms2 );
+
+    microseconds us = 867us;
+    assert ( us == microseconds(867));
+    auto us2 = 867.0us;
+    assert ( us == us2 );
+
+    nanoseconds ns = 645ns;
+    assert ( ns == nanoseconds(645));
+    auto ns2 = 645.ns;
+    assert ( ns == ns2 );
+#endif
+}
diff --git a/test/utilities/time/time.duration/time.duration.literals/literals2.fail.cpp b/test/utilities/time/time.duration/time.duration.literals/literals2.fail.cpp
new file mode 100644
index 0000000..17358e5
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.literals/literals2.fail.cpp
@@ -0,0 +1,22 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11 
+    using std::chrono::hours;
+
+    hours foo  =  4h;  // should fail w/conversion operator not found
+#else
+#error
+#endif
+}
diff --git a/test/utilities/time/time.duration/time.duration.literals/literals2.pass.cpp b/test/utilities/time/time.duration/time.duration.literals/literals2.pass.cpp
new file mode 100644
index 0000000..e37bc6e
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.literals/literals2.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11 
+    using namespace std::literals;
+
+    std::chrono::hours h = 4h;
+    assert ( h == std::chrono::hours(4));
+    auto h2 = 4.0h;
+    assert ( h == h2 );
+    
+    std::chrono::minutes min = 36min;
+    assert ( min == std::chrono::minutes(36));
+    auto min2 = 36.0min;
+    assert ( min == min2 );
+
+    std::chrono::seconds s = 24s;
+    assert ( s == std::chrono::seconds(24));
+    auto s2 = 24.0s;
+    assert ( s == s2 );
+
+    std::chrono::milliseconds ms = 247ms;
+    assert ( ms == std::chrono::milliseconds(247));
+    auto ms2 = 247.0ms;
+    assert ( ms == ms2 );
+
+    std::chrono::microseconds us = 867us;
+    assert ( us == std::chrono::microseconds(867));
+    auto us2 = 867.0us;
+    assert ( us == us2 );
+
+    std::chrono::nanoseconds ns = 645ns;
+    assert ( ns == std::chrono::nanoseconds(645));
+    auto ns2 = 645.ns;
+    assert ( ns == ns2 );
+#endif
+}