diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 94f0f0328..6b09411f2 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3297,7 +3297,7 @@ void Tokenizer::setVarId() // Variable declarations can't start with "return" etc. -#define NOTSTART_C "case", "default", "goto", "NOT", "return", "sizeof", "typedef" +#define NOTSTART_C "NOT", "case", "default", "goto", "not", "return", "sizeof", "typedef" static const std::set notstart_c = { NOTSTART_C }; static const std::set notstart_cpp = { NOTSTART_C, "delete", "friend", "new", "throw", "using", "virtual", "explicit", "const_cast", "dynamic_cast", "reinterpret_cast", "static_cast", "template" diff --git a/test/testvarid.cpp b/test/testvarid.cpp index ba3bb6318..b3a1a6e47 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -167,8 +167,8 @@ private: TEST_CASE(varid_trailing_return1); // #8889 TEST_CASE(varid_trailing_return2); // #9066 TEST_CASE(varid_parameter_pack); // #9383 - TEST_CASE(varid_for_auto_cpp17); + TEST_CASE(varid_not); // #9689 'not x' TEST_CASE(varidclass1); TEST_CASE(varidclass2); @@ -2598,6 +2598,16 @@ private: ASSERT_EQUALS(exp1, tokenize(code)); } + void varid_not() { // #9689 'not x' + const char code1[] = "void foo(int x) const {\n" + " if (not x) {}\n" + "}"; + const char exp1[] = "1: void foo ( int x@1 ) const {\n" + "2: if ( not x@1 ) { }\n" + "3: }\n"; + ASSERT_EQUALS(exp1, tokenize(code1)); + } + void varidclass1() { const std::string actual = tokenize( "class Fred\n"