Skip to content

Commit 83664f5

Browse files
Fix #14621 Invalid test code in other_test.py::test:addon_misc (#8366)
1 parent 682810d commit 83664f5

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

lib/tokenize.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8765,6 +8765,8 @@ void Tokenizer::findGarbageCode() const
87658765
syntaxError(tok, prev == tok->previous() ? (prev->str() + " " + tok->str()) : (prev->str() + " .. " + tok->str()));
87668766
}
87678767
}
8768+
else if (tok->isStandardType() && tok->next() && tok->str() == tok->strAt(1) && tok->str() != "long")
8769+
syntaxError(tok);
87688770
}
87698771

87708772
// invalid struct declaration

test/cli/other_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ def test_addon_misc(tmpdir):
788788
f.write("""
789789
extern void f()
790790
{
791-
char char* [] = {"a" "b"}
791+
const char* c[] = {"a" "b"};
792792
}
793793
""")
794794

@@ -800,7 +800,7 @@ def test_addon_misc(tmpdir):
800800
assert lines == [
801801
'Checking {} ...'.format(test_file)
802802
]
803-
assert stderr == '{}:4:26: style: String concatenation in array initialization, missing comma? [misc-stringConcatInArrayInit]\n'.format(test_file)
803+
assert stderr == '{}:4:28: style: String concatenation in array initialization, missing comma? [misc-stringConcatInArrayInit]\n'.format(test_file)
804804

805805

806806
def test_invalid_addon_json(tmpdir):

test/testgarbage.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ class TestGarbage : public TestFixture {
259259
TEST_CASE(garbageCode228);
260260
TEST_CASE(garbageCode229);
261261
TEST_CASE(garbageCode230);
262+
TEST_CASE(garbageCode231);
262263

263264
TEST_CASE(garbageCodeFuzzerClientMode1); // test cases created with the fuzzer client, mode 1
264265

@@ -1775,6 +1776,9 @@ class TestGarbage : public TestFixture {
17751776
void garbageCode230() { // #14432
17761777
ASSERT_THROW_INTERNAL(checkCode("e U U,i"), SYNTAX);
17771778
}
1779+
void garbageCode231() {
1780+
ASSERT_THROW_INTERNAL(checkCode("char char* [] = {\"a\" \"b\"}"), SYNTAX);
1781+
}
17781782

17791783

17801784
void syntaxErrorFirstToken() {

0 commit comments

Comments
 (0)