aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMatthew Woehlke <matthew.woehlke@kitware.com>2014-04-16 10:02:21 -0400
committerJohn Ehresman <jpe@wingware.com>2014-04-16 20:59:54 +0200
commitebf3ba51187b6bb54cf819e5a0101c2f75e11de1 (patch)
tree531936f7d2240a151c5bd72774b247f6bc629700 /tests
parent35d006a7bf9b33807c1df93f5f9439ff83cd32c0 (diff)
Add parsing of 'noexcept' keyword
Teach Shiboken to parse the 'noexcept' keyword. This doesn't add any features (and we only support unconditional 'noexcept' for now), but addresses an internal error that causes shiboken to SEGV trying to parse modern versions of boost::intrusive_ptr. A test case to replicate the crash (without the other changes) is also added. Change-Id: I4713593dfd189c02ef4a2d7447d785b6d378019c Reviewed-by: John Ehresman <jpe@wingware.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/libsample/photon.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/libsample/photon.h b/tests/libsample/photon.h
index 18917e26c..1f8483ef4 100644
--- a/tests/libsample/photon.h
+++ b/tests/libsample/photon.h
@@ -96,6 +96,38 @@ LIBSAMPLE_API int callCalculateForValueDuplicatorReference(ValueDuplicator& valu
LIBSAMPLE_API int countValueIdentities(const std::list<ValueIdentity>& values);
LIBSAMPLE_API int countValueDuplicators(const std::list<TemplateBase<DuplicatorType> >& values);
+// This simulates an internal error (SEGV) caused by 'noexcept' in
+// boost::intrusive_ptr before support for 'noexcept' was added. The ENTIRE
+// code below is needed to trigger the exception; it isn't seen with just a
+// 'noexcept' following a declaration.
+//
+// NOTE: For reasons that should be fairly obvious, this test unfortunately can
+// only be "run" when building in C++11 mode.
+#if __cplusplus < 201103L
+#define noexcept
+#endif
+class Pointer
+{
+public:
+ Pointer() noexcept : px(0) {}
+ Pointer(int* p) : px(p) {}
+
+ void reset() noexcept { Pointer().swap(*this); }
+
+ int* get() const noexcept { return px; }
+ int& operator*() const { return *px; }
+
+ void swap(Pointer& rhs) noexcept
+ {
+ int* tmp = px;
+ px = rhs.px;
+ rhs.px = tmp;
+ }
+
+private:
+ int* px;
+};
+
} // namespace Photon
#endif // PHOTON_H