From e304e5ffff9718d99ab5767c8399225b79204c1f Mon Sep 17 00:00:00 2001 From: Daniel Garcia Date: Tue, 23 Feb 2016 17:16:58 -0800 Subject: [PATCH 1/2] Handle template expressions that may use the << or >> operators --- c.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/c.c b/c.c index 40db0e5..b975453 100644 --- a/c.c +++ b/c.c @@ -1392,20 +1392,34 @@ static void skipToMatch (const char *const pair) if (c == begin) { - ++matchLevel; - if (braceFormatting && getDirectiveNestLevel () != initialLevel) - { - skipToFormattedBraceMatch (); - break; + // watch out for '<<' in template arguments + int x = cppGetc (); + if(c == '<' && x == '<') { + // we've found a << - do nothing + } else { + cppUngetc (x); + ++matchLevel; + if (braceFormatting && getDirectiveNestLevel () != initialLevel) + { + skipToFormattedBraceMatch (); + break; + } } } else if (c == end) { - --matchLevel; - if (braceFormatting && getDirectiveNestLevel () != initialLevel) - { - skipToFormattedBraceMatch (); - break; + // watch out for '>>' in template arguments + int x = cppGetc (); + if(c == '>' && x == '>') { + // we've found a >> in a template - skip it + } else { + cppUngetc (x); + --matchLevel; + if (braceFormatting && getDirectiveNestLevel () != initialLevel) + { + skipToFormattedBraceMatch (); + break; + } } } } From fe0ba956daf1f3940543e3dce8ec0befcab4d386 Mon Sep 17 00:00:00 2001 From: Daniel Garcia Date: Wed, 24 Feb 2016 00:59:15 -0800 Subject: [PATCH 2/2] Make sure we don't throw things away while collecting the signature, though --- c.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/c.c b/c.c index b975453..386af29 100644 --- a/c.c +++ b/c.c @@ -1395,7 +1395,9 @@ static void skipToMatch (const char *const pair) // watch out for '<<' in template arguments int x = cppGetc (); if(c == '<' && x == '<') { - // we've found a << - do nothing + // we've found a << - do nothing except record the signature + if (CollectingSignature) + vStringPut(Signature, x); } else { cppUngetc (x); ++matchLevel; @@ -1411,7 +1413,9 @@ static void skipToMatch (const char *const pair) // watch out for '>>' in template arguments int x = cppGetc (); if(c == '>' && x == '>') { - // we've found a >> in a template - skip it + // we've found a >> - do nothing except record the signature + if (CollectingSignature) + vStringPut(Signature, x); } else { cppUngetc (x); --matchLevel;