Skip to content

Commit ca8b8d6

Browse files
committed
patch 8.0.0092
Problem: C indenting does not support nested namespaces that C++ 17 has. Solution: Add check that passes double colon inside a name. (Pauli, closes #1214)
1 parent 9f0e423 commit ca8b8d6

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

src/misc1.c

+9
Original file line numberDiff line numberDiff line change
@@ -5762,6 +5762,7 @@ cin_is_cpp_namespace(char_u *s)
57625762
{
57635763
char_u *p;
57645764
int has_name = FALSE;
5765+
int has_name_start = FALSE;
57655766

57665767
s = cin_skipcomment(s);
57675768
if (STRNCMP(s, "namespace", 9) == 0 && (s[9] == NUL || !vim_iswordc(s[9])))
@@ -5780,10 +5781,18 @@ cin_is_cpp_namespace(char_u *s)
57805781
}
57815782
else if (vim_iswordc(*p))
57825783
{
5784+
has_name_start = TRUE;
57835785
if (has_name)
57845786
return FALSE; /* word character after skipping past name */
57855787
++p;
57865788
}
5789+
else if (p[0] == ':' && p[1] == ':' && vim_iswordc(p[2]))
5790+
{
5791+
if (!has_name_start || has_name)
5792+
return FALSE;
5793+
/* C++ 17 nested namespace */
5794+
p += 3;
5795+
}
57875796
else
57885797
{
57895798
return FALSE;

src/testdir/test3.in

+20
Original file line numberDiff line numberDiff line change
@@ -1932,6 +1932,26 @@ namespace test
19321932
{
19331933
111111111111111111;
19341934
}
1935+
namespace test::cpp17
1936+
{
1937+
111111111111111111;
1938+
}
1939+
namespace ::incorrectcpp17
1940+
{
1941+
111111111111111111;
1942+
}
1943+
namespace test::incorrectcpp17::
1944+
{
1945+
111111111111111111;
1946+
}
1947+
namespace test:incorrectcpp17
1948+
{
1949+
111111111111111111;
1950+
}
1951+
namespace test:::incorrectcpp17
1952+
{
1953+
111111111111111111;
1954+
}
19351955
namespace{
19361956
111111111111111111;
19371957
}

src/testdir/test3.ok

+20
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,26 @@ namespace test
17301730
{
17311731
111111111111111111;
17321732
}
1733+
namespace test::cpp17
1734+
{
1735+
111111111111111111;
1736+
}
1737+
namespace ::incorrectcpp17
1738+
{
1739+
111111111111111111;
1740+
}
1741+
namespace test::incorrectcpp17::
1742+
{
1743+
111111111111111111;
1744+
}
1745+
namespace test:incorrectcpp17
1746+
{
1747+
111111111111111111;
1748+
}
1749+
namespace test:::incorrectcpp17
1750+
{
1751+
111111111111111111;
1752+
}
17331753
namespace{
17341754
111111111111111111;
17351755
}

src/version.c

+2
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
92,
767769
/**/
768770
91,
769771
/**/

0 commit comments

Comments
 (0)