@@ -192,7 +192,9 @@ def test_read_ctu_info_line(checker):
192192 ('MisraTypedefInfo' , 203 , False ),
193193 ('MisraTypedefInfo' , 203 , True ),
194194 ('MisraTagName' , 204 , False ),
195- ('MisraTagName' , 204 , True )
195+ ('MisraTagName' , 204 , True ),
196+ ('MisraMacro' , 205 , False ),
197+ ('MisraMacro' , 205 , True )
196198])
197199def test_ctu_unused_declaration (checker , tmp_path , summary , rule , used_first ):
198200 # The same name declared in two files, unused in a.c and used in b.c
@@ -206,6 +208,18 @@ def test_ctu_unused_declaration(checker, tmp_path, summary, rule, used_first):
206208 assert 'a.c-1-13-%d' % rule in checker .existing_violations
207209 assert 'b.c-1-13-%d' % rule not in checker .existing_violations
208210
211+ @pytest .mark .parametrize ('summary' , ['MisraTypedefInfo' , 'MisraTagName' , 'MisraMacro' ])
212+ def test_ctu_declaration_path_spelling (checker , tmp_path , summary ):
213+ # The same declaration in h.h, reached through a relative and an absolute path
214+ unused = {'name' : 'X' , 'file' : 'h.h' , 'line' : 1 , 'column' : 13 , 'used' : False }
215+ used = {'name' : 'X' , 'file' : os .path .abspath ('h.h' ), 'line' : 1 , 'column' : 13 , 'used' : True }
216+ ctu_info = tmp_path / 'test.ctu-info'
217+ with open (ctu_info , 'wt' ) as f :
218+ for declaration in [unused , used ]:
219+ f .write (json .dumps ({'summary' : summary , 'data' : [declaration ]}) + '\n ' )
220+ checker .analyse_ctu_info ([str (ctu_info )])
221+ assert not checker .existing_violations
222+
209223def test_platform (checker ):
210224 test_file = os .path .join ('addons' ,'test' ,'misra' ,'misra-test.c' )
211225 dump_create (test_file , "--language=c++" )
0 commit comments