From d6968f804ab817c29f9f0ca408279adf82b006f9 Mon Sep 17 00:00:00 2001 From: Jean Abou-Samra Date: Mon, 15 Aug 2022 11:45:13 +0200 Subject: CFamilyLexer: refuse quotes between parentheses for function definitions and declarations (#2208) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Something like id id2("){ ... }"); is no longer wrongly recognized as a "function" id id2(") { ... } "); As the difference in the tests shows, this has the unfortunate side effect that we no longer highlight something like int f(param="default"); as a function declaration, but it is hard to imagine another way to fix this (cf. “most vexing parse” problem). Fixes #2207 --- .../snippets/c/test_string_resembling_decl_end.txt | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/snippets/c/test_string_resembling_decl_end.txt (limited to 'tests/snippets') diff --git a/tests/snippets/c/test_string_resembling_decl_end.txt b/tests/snippets/c/test_string_resembling_decl_end.txt new file mode 100644 index 00000000..17ce2233 --- /dev/null +++ b/tests/snippets/c/test_string_resembling_decl_end.txt @@ -0,0 +1,41 @@ +---input--- +// This should not be recognized as a function declaration followed by +// garbage. +string xyz(");"); + +// This should not be recognized as a function definition. + +string xyz("){ }"); + +---tokens--- +'// This should not be recognized as a function declaration followed by\n' Comment.Single + +'// garbage.\n' Comment.Single + +'string' Name +' ' Text.Whitespace +'xyz' Name +'(' Punctuation +'"' Literal.String +');' Literal.String +'"' Literal.String +')' Punctuation +';' Punctuation +'\n' Text.Whitespace + +'\n' Text.Whitespace + +'// This should not be recognized as a function definition.\n' Comment.Single + +'\n' Text.Whitespace + +'string' Name +' ' Text.Whitespace +'xyz' Name +'(' Punctuation +'"' Literal.String +'){ }' Literal.String +'"' Literal.String +')' Punctuation +';' Punctuation +'\n' Text.Whitespace -- cgit v1.2.1