[libcxx] r232384 - Fix a problem when calling throw_with_nested with a class marked 'final'. Thanks to STL @ Microsoft for the bug report.

Marshall Clow mclow.lists at gmail.com
Mon Mar 16 08:10:29 PDT 2015


Author: marshall
Date: Mon Mar 16 10:10:28 2015
New Revision: 232384

URL: http://llvm.org/viewvc/llvm-project?rev=232384&view=rev
Log:
Fix a problem when calling throw_with_nested with a class marked 'final'. Thanks to STL @ Microsoft for the bug report.

Modified:
    libcxx/trunk/include/exception
    libcxx/trunk/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp

Modified: libcxx/trunk/include/exception
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/exception?rev=232384&r1=232383&r2=232384&view=diff
==============================================================================
--- libcxx/trunk/include/exception (original)
+++ libcxx/trunk/include/exception Mon Mar 16 10:10:28 2015
@@ -193,6 +193,9 @@ void
 throw_with_nested(_Tp&& __t, typename enable_if<
                   is_class<typename remove_reference<_Tp>::type>::value &&
                   !is_base_of<nested_exception, typename remove_reference<_Tp>::type>::value
+#if _LIBCPP_STD_VER > 11
+                  && !is_final<typename remove_reference<_Tp>::type>::value
+#endif
                                     >::type* = 0)
 #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 throw_with_nested (_Tp& __t, typename enable_if<
@@ -212,6 +215,9 @@ void
 throw_with_nested(_Tp&& __t, typename enable_if<
                   !is_class<typename remove_reference<_Tp>::type>::value ||
                   is_base_of<nested_exception, typename remove_reference<_Tp>::type>::value
+#if _LIBCPP_STD_VER > 11
+                  || is_final<typename remove_reference<_Tp>::type>::value
+#endif
                                     >::type* = 0)
 #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 throw_with_nested (_Tp& __t, typename enable_if<

Modified: libcxx/trunk/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp?rev=232384&r1=232383&r2=232384&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp Mon Mar 16 10:10:28 2015
@@ -36,6 +36,10 @@ public:
     friend bool operator==(const B& x, const B& y) {return x.data_ == y.data_;}
 };
 
+#if __cplusplus > 201103L
+struct Final final {};
+#endif
+
 int main()
 {
     {
@@ -100,4 +104,16 @@ int main()
             assert(i == 7);
         }
     }
+#if __cplusplus > 201103L
+    {
+        try
+        {
+            std::throw_with_nested(Final());
+            assert(false);
+        }
+        catch (const Final &f)
+        {
+        }
+    }
+#endif
 }





More information about the cfe-commits mailing list