universal-ctags / ctags

A maintained ctags implementation
https://ctags.io
GNU General Public License v2.0
6.39k stars 618 forks source link

C++: crash when a variable template is given #3963

Closed masatake closed 3 months ago

masatake commented 3 months ago

ctags reports

ctags: parsers/cxx/cxx_scope.c:228: cxxScopePushTop: Assertion `false' failed.                                                                                                                
ctags: parsers/cxx/cxx_scope.c:228: parsing /tmp/z.cpp:3 as C++                                                                                                                               

for the input

template<> int A<X>[] = {                                                                                                                                                                     
        0,                                                                                                                                                                                    
};                                                                                                                                                                                            

With --options=NONE --kinds-C++='Z' -o - z.cpp.

gcc doesn't accept the about input. However, ctags should not crash.

gcc accepts the following input.

num chip {                                                                                                                                                                                   
        A6XX = 6,                                                                                                                                                                             
};                                                                                                                                                                                            

template<chip CHIP>  int CMD_REGS[] = {};                                                                                                                                                     
template<>           int CMD_REGS<A6XX>[] = {                                                                                                                                                 
        0x3,                                                                                                                                                                                  
};                                                                                                                                                                                            

int main(void)                                                                                                                                                                                
{                                                                                                                                                                                             
  int CMD_REGS                                                                                                                                                                                
}