Problem: c++17 extends namespace declaration syntax to allow nested
namespaces defination (namespace A::B::C)
Solution: Add check that passes double colon inside a name
---
src/misc1.c | 10 ++++++++++
src/testdir/test3.in | 20 ++++++++++++++++++++
src/testdir/test3.ok | 20 ++++++++++++++++++++
3 files changed, 50 insertions(+)
diff --git a/src/misc1.c b/src/misc1.c
index 6bf7d75..f760f7b 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -5762,6 +5762,7 @@ cin_is_cpp_namespace(char_u *s)
{
char_u *p;
int has_name = FALSE;
+ int has_name_start = FALSE;
s = cin_skipcomment(s);
if (STRNCMP(s, "namespace", 9) == 0 && (s[9] == NUL || !vim_iswordc(s[9])))
@@ -5780,10 +5781,19 @@ cin_is_cpp_namespace(char_u *s)
}
else if (vim_iswordc(*p))
{
+ has_name_start = TRUE;
if (has_name)
return FALSE; /* word character after skipping past name */
++p;
}
+ else if (p[0] == ':' &&
+ p[1] == ':' &&
+ vim_iswordc(p[2]))
+ {
+ if (!has_name_start || has_name)
+ return FALSE;
+ p += 3;
+ }
else
{
return FALSE;
diff --git a/src/testdir/test3.in b/src/testdir/test3.in
index c0a68d0..096f152 100644
--- a/src/testdir/test3.in
+++ b/src/testdir/test3.in
@@ -1932,6 +1932,26 @@ namespace test
{
111111111111111111;
}
+namespace test::cpp17
+{
+ 111111111111111111;
+}
+namespace ::incorrectcpp17
+{
+ 111111111111111111;
+}
+namespace test::incorrectcpp17::
+{
+ 111111111111111111;
+}
+namespace test:incorrectcpp17
+{
+ 111111111111111111;
+}
+namespace test:::incorrectcpp17
+{
+ 111111111111111111;
+}
namespace{
111111111111111111;
}
diff --git a/src/testdir/test3.ok b/src/testdir/test3.ok
index c4c01a3..2f9572c 100644
--- a/src/testdir/test3.ok
+++ b/src/testdir/test3.ok
@@ -1730,6 +1730,26 @@ namespace test
{
111111111111111111;
}
+namespace test::cpp17
+{
+111111111111111111;
+}
+namespace ::incorrectcpp17
+{
+ 111111111111111111;
+}
+namespace test::incorrectcpp17::
+{
+ 111111111111111111;
+}
+namespace test:incorrectcpp17
+{
+ 111111111111111111;
+}
+namespace test:::incorrectcpp17
+{
+ 111111111111111111;
+}
namespace{
111111111111111111;
}
--
2.9.3
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.