Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

C++: mitigate matching error on generics containing an expression

Mitigate parse error with generics like `foo<X<Y> x;` by avoiding
matching past a semicolon (";") or open curly brace ("{"), which
can't be part of the generic.  This isn't a proper fix, but mitigates
the impact of such constructs.
  • Loading branch information...
commit d40932ce4d05e57573a6d6c8f89f4aea8c42d4f3 1 parent f227076
@b4n b4n authored
Showing with 12 additions and 0 deletions.
  1. +10 −0 tagmanager/ctags/c.c
  2. +2 −0  tests/ctags/bug1563476.cpp.tags
View
10 tagmanager/ctags/c.c
@@ -1650,6 +1650,16 @@ static void skipToMatch (const char *const pair)
break;
}
}
+ /* early out if matching "<>" and we encounter a ";" or "{" to mitigate
+ * match problems with C++ generics containing a static expression like
+ * foo<X<Y> bar;
+ * normally neither ";" nor "{" could appear inside "<>" anyway. */
+ else if (isLanguage (Lang_cpp) && begin == '<' &&
+ (c == ';' || c == '{'))
+ {
+ cppUngetc (c);
+ break;
+ }
}
if (c == EOF)
{
View
2  tests/ctags/bug1563476.cpp.tags
@@ -1,3 +1,5 @@
# format=tagmanager
+IntroduceBitDef�2048�0
IntroduceBitDef�32768�0
+f�16�()�IntroduceBitDef�0�int
g�16�()�0�int
Please sign in to comment.
Something went wrong with that request. Please try again.