@@ -489,9 +489,9 @@ class TestValueFlow : public TestFixture {
489489 }
490490
491491#define tokenValues (...) tokenValues_(__FILE__, __LINE__, __VA_ARGS__)
492- std::list<ValueFlow::Value> tokenValues_ (const char * file, int line, const char code[], const char tokstr[], const Settings *s = nullptr ) {
492+ std::list<ValueFlow::Value> tokenValues_ (const char * file, int line, const char code[], const char tokstr[], const Settings *s = nullptr , bool cpp = true ) {
493493 SimpleTokenizer tokenizer (s ? *s : settings, *this );
494- ASSERT_LOC (tokenizer.tokenize (code), file, line);
494+ ASSERT_LOC (tokenizer.tokenize (code, cpp ), file, line);
495495 const Token *tok = Token::findmatch (tokenizer.tokens (), tokstr);
496496 return tok ? tok->values () : std::list<ValueFlow::Value>();
497497 }
@@ -523,9 +523,9 @@ class TestValueFlow : public TestFixture {
523523 return result;
524524 }
525525
526- #define valueOfTok (code, tokstr ) valueOfTok_(code, tokstr, __FILE__, __LINE__)
527- ValueFlow::Value valueOfTok_ (const char code[], const char tokstr[], const char * file, int line ) {
528- std::list<ValueFlow::Value> values = removeImpossible (tokenValues_ (file, line, code, tokstr));
526+ #define valueOfTok (... ) valueOfTok_(__FILE__, __LINE__, __VA_ARGS__ )
527+ ValueFlow::Value valueOfTok_ (const char * file, int line, const char code[], const char tokstr[], const Settings *s = nullptr , bool cpp = true ) {
528+ std::list<ValueFlow::Value> values = removeImpossible (tokenValues_ (file, line, code, tokstr, s, cpp ));
529529 return values.size () == 1U && !values.front ().isTokValue () ? values.front () : ValueFlow::Value ();
530530 }
531531
@@ -557,6 +557,14 @@ class TestValueFlow : public TestFixture {
557557 ASSERT_EQUALS_DOUBLE (16 , valueOfTok (" x=(double)16;" , " (" ).floatValue , 1e-5 );
558558 ASSERT_EQUALS_DOUBLE (0.0625 , valueOfTok (" x=1/(double)16;" , " /" ).floatValue , 1e-5 );
559559
560+ const Settings settingsC23 = settingsBuilder ().c (Standards::C23).build ();
561+ ASSERT_EQUALS (1 , valueOfTok (" x=true;" , " true" , &settingsC23, false ).intvalue );
562+ ASSERT_EQUALS (0 , valueOfTok (" x=false;" , " false" , &settingsC23, false ).intvalue );
563+
564+ const Settings settingsC17 = settingsBuilder ().c (Standards::C17).build ();
565+ ASSERT (!valueOfTok (" x=true;" , " true" , &settingsC17, false ).isKnown ());
566+ ASSERT (!valueOfTok (" x=false;" , " false" , &settingsC17, false ).isKnown ());
567+
560568 // scope
561569 {
562570 const char code[] = " namespace N { enum E {e0,e1}; }\n "
0 commit comments