Skip to content

Commit 85e2700

Browse files
committed
Add test to demonstrate issue #45
This is failing with gcc5 + castxml + std=c++11 flag with the following error: parsing files - started DEBUG Reading project files: file by file INFO Parsing source file "test.h" ... DEBUG Reading source file: [test.h]. DEBUG File has not been found in cache, parsing... DEBUG castxml cmd: /usr/bin/castxml -std=c++11 -I. -c -x c++ --castxml-cc-gnu "(" /usr/bin/clang -std=c++11 ")" --castxml-gccxml -o /tmp/tmpmsq0r7kr.xml test.h DEBUG CASTXML version - None ( 1.136 ) <snip> File "/usr/local/lib/python3.4/dist-packages/pygccxml-1.7.2-py3.4.egg/pygccxml/parser/project_reader.py", line 544, in _relink_declarated_types Exception: Unable to find out actual class definition: ''. Class definition has been changed from one compilation to an other. Why did it happen to me? Here is a short list of reasons: 1. There are different preprocessor definitions applied on same file during compilation 2. Bug in pygccxml.
1 parent 9bf7d01 commit 85e2700

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed

unittests/data/test_map_gcc5.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2014-2016 Insight Software Consortium.
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// See http://www.boost.org/LICENSE_1_0.txt
4+
5+
#include <map>
6+
7+
using namespace std;
8+
9+
class mytest {
10+
map<int, int> mymap;
11+
};

unittests/test_all.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
import test_copy_constructor
7171
import test_cpp_standards
7272
import unnamed_classes_tester
73+
import test_map_gcc5
7374

7475
testers = [
7576
# , demangled_tester # failing right now
@@ -132,7 +133,8 @@
132133
test_va_list_tag_removal,
133134
test_copy_constructor,
134135
test_cpp_standards,
135-
unnamed_classes_tester
136+
unnamed_classes_tester,
137+
test_map_gcc5
136138
]
137139

138140
if 'posix' in os.name:

unittests/test_map_gcc5.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright 2014-2016 Insight Software Consortium.
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# See http://www.boost.org/LICENSE_1_0.txt
4+
5+
import unittest
6+
import parser_test_case
7+
8+
from pygccxml import parser
9+
from pygccxml import utils
10+
from pygccxml import declarations
11+
12+
13+
class tester_t(parser_test_case.parser_test_case_t):
14+
15+
def __init__(self, *args):
16+
parser_test_case.parser_test_case_t.__init__(self, *args)
17+
self.header = "test_map_gcc5.hpp"
18+
self.config.cflags = "-std=c++11"
19+
20+
def test_map_gcc5(self):
21+
"""
22+
The code in test_map_gcc5.hpp was breaking pygccxml.
23+
24+
Test that case (gcc5 + castxml + c++11). See issue #45
25+
26+
"""
27+
28+
if self.config.xml_generator == "gccxml":
29+
return
30+
31+
decls = parser.parse([self.header], self.config)
32+
self.global_ns = declarations.get_global_namespace(decls)
33+
34+
35+
def create_suite():
36+
suite = unittest.TestSuite()
37+
suite.addTest(unittest.makeSuite(tester_t))
38+
return suite
39+
40+
41+
def run_suite():
42+
unittest.TextTestRunner(verbosity=2).run(create_suite())
43+
44+
if __name__ == "__main__":
45+
run_suite()

0 commit comments

Comments
 (0)