Skip to content

Commit e01f4f8

Browse files
committed
patch 7.4.912
Problem: Wrong indenting for C++ constructor. Solution: Recognize ::. (Anhong)
1 parent 450ca43 commit e01f4f8

4 files changed

Lines changed: 29 additions & 0 deletions

File tree

src/misc1.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6250,6 +6250,19 @@ cin_isfuncdecl(sp, first_lnum, min_lnum)
62506250
{
62516251
if (cin_iscomment(s)) /* ignore comments */
62526252
s = cin_skipcomment(s);
6253+
else if (*s == ':')
6254+
{
6255+
if (*(s + 1) == ':')
6256+
s += 2;
6257+
else
6258+
/* To avoid a mistake in the following situation:
6259+
* A::A(int a, int b)
6260+
* : a(0) // <--not a function decl
6261+
* , b(0)
6262+
* {...
6263+
*/
6264+
return FALSE;
6265+
}
62536266
else
62546267
++s;
62556268
}

src/testdir/test3.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,13 @@ Constructor::Constructor(int a,
663663
{
664664
}
665665

666+
A::A(int a, int b)
667+
: aa(a),
668+
bb(b),
669+
cc(c)
670+
{
671+
}
672+
666673
class CAbc :
667674
public BaseClass1,
668675
protected BaseClass2

src/testdir/test3.ok

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,13 @@ Constructor::Constructor(int a,
651651
{
652652
}
653653

654+
A::A(int a, int b)
655+
: aa(a),
656+
bb(b),
657+
cc(c)
658+
{
659+
}
660+
654661
class CAbc :
655662
public BaseClass1,
656663
protected BaseClass2

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
912,
744746
/**/
745747
911,
746748
/**/

0 commit comments

Comments
 (0)