diff -urp global-6.3.3/libparser/Cpp.c global-6.3-3/libparser/Cpp.c --- global-6.3.3/libparser/Cpp.c 2014-12-07 11:49:33 +1000 +++ global-6.3-3/libparser/Cpp.c 2014-12-07 11:18:41 +1000 @@ -79,8 +79,7 @@ Cpp(const struct parser_param *param) char *terminate; int level; } stack[MAXCLASSSTACK]; - const char *interested_class = "<:{}=;~"; - const char *interested = interested_class + 2; + const char *interested = "{}=;~"; STRBUF *sb = strbuf_open(0); *classname = *completename = 0; @@ -186,7 +185,7 @@ Cpp(const struct parser_param *param) case CPP_STRUCT: case CPP_CLASS: DBG_PRINT(level, cc == CPP_CLASS ? "class" : "struct"); - while ((c = nexttoken(interested_class, cpp_reserved_word)) == CPP___ATTRIBUTE__ || c == '\n') + while ((c = nexttoken(NULL, cpp_reserved_word)) == CPP___ATTRIBUTE__ || c == '\n') if (c == CPP___ATTRIBUTE__) process_attribute(param); if (c == SYMBOL) { @@ -200,20 +199,33 @@ Cpp(const struct parser_param *param) saveline = strbuf_value(sb); strlimcpy(classname, token, sizeof(classname)); } - c = nexttoken(interested_class, cpp_reserved_word); + c = nexttoken(NULL, cpp_reserved_word); + if (c == SYMBOL) + PUT(PARSER_REF_SYM, classname, savelineno, saveline); + else if (c == '<') { + int templates = 1; + for (;;) { + c = nexttoken(NULL, cpp_reserved_word); + if (c == SYMBOL) + PUT(PARSER_REF_SYM, token, lineno, sp); + else if (c == '<') + ++templates; + else if (c == '>') { + if (--templates == 0) + break; + } else if (c == EOF) + die("failed to parse template [+%d %s].", savelineno, curfile); + } + c = nexttoken(NULL, cpp_reserved_word); + } } while (c == SYMBOL || c == '\n'); - /* - * Ignore forward definitions. - * "class name;" - */ - if (c == '<' || c == ':' || c == '{') /* } */ { + if (c == ':' || c == '{') /* } */ { startclass = 1; PUT(PARSER_DEF, classname, savelineno, saveline); - } else if (c != ';') + } else PUT(PARSER_REF_SYM, classname, savelineno, saveline); } - if (c != '<' && c != ':') - pushbacktoken(); + pushbacktoken(); break; case '{': /* } */ DBG_PRINT(level, "{"); /* } */