Skip to content

Commit bd20909

Browse files
committed
Proper detection of non-default constructible types
Prior to CastXML/CastXML#55 being fixed, CastXML would incorrectly generate default constructor definitions for types with const data members. This caused pygccxml to incorrectly flag such types as trivially constructible. These tests have now been fixed, and the tests are being executed conditionally only for GCCXML (which handles them correctly), or, if CastXML is being used, then for xml_output_version >= 1.138. Change-Id: If1e164eeb467a569689696cf34c2c668317e6fb1
1 parent 446bc0c commit bd20909

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

unittests/data/type_traits.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,6 @@ namespace yes{
589589
struct x{
590590
x(){}
591591
};
592-
#ifdef __castxml__
593-
typedef details::const_item const_item;
594-
typedef details::const_container const_container;
595-
#endif
596592
}
597593

598594
namespace no{
@@ -613,6 +609,9 @@ namespace no{
613609
public:
614610
static singleton_t* instance();
615611
};
612+
613+
typedef details::const_item const_item;
614+
typedef details::const_container const_container;
616615
} }
617616

618617
namespace has_public_constructor{

unittests/type_traits_tester.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ def __test_type_category(self, ns_name, controller):
6060
decl.name.startswith('test_'):
6161
continue
6262

63+
if ("CastXML" in utils.xml_generator and
64+
utils.xml_output_version < 1.138 and
65+
decl.name in ['const_item', 'const_container']):
66+
# Skip this test to workaround CastXML bug.
67+
# See https://github.com/CastXML/CastXML/issues/55
68+
continue
69+
6370
self.assertFalse(
6471
controller(decl),
6572
er % (decl.decl_string, ns_name))
@@ -360,12 +367,13 @@ def test(self):
360367
code = "struct const_item{ const int values[10]; };"
361368
global_ns = parser.parse_string(code, config)[0]
362369
ci = global_ns.class_('const_item')
363-
if 'CastXML' in utils.xml_generator:
364-
# Constructor, copy constructor, destructor, variable
365-
self.assertTrue(len(ci.declarations) == 4)
366-
else:
370+
if ("CastXML" not in utils.xml_generator or
371+
utils.xml_output_version >= 1.138):
372+
# Prior to version 1.138, CastXML would incorrect create a default
373+
# constructor definition.
374+
# See https://github.com/CastXML/CastXML/issues/55
367375
# Copy constructor, destructor, variable
368-
self.assertTrue(len(ci.declarations) == 3)
376+
self.assertEqual(len(ci.declarations), 3)
369377

370378
# class tester_diff_t( parser_test_case.parser_test_case_t ):
371379
# COMPILATION_MODE = parser.COMPILATION_MODE.ALL_AT_ONCE

0 commit comments

Comments
 (0)