diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 979ea4ffdad..3b8cb899248 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3794,6 +3794,8 @@ void CheckOther::checkEvaluationOrder() continue; if (!tok->astOperand1()) continue; + if (tok->astOperand1()->str() == "." && !tok->astOperand1()->astOperand2()) + continue; for (const Token *tok2 = tok;; tok2 = tok2->astParent()) { // If ast parent is a sequence point then break const Token * const parent = tok2->astParent(); diff --git a/test/testother.cpp b/test/testother.cpp index 55fbe3830f1..0cfa173faf6 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -11935,9 +11935,9 @@ class TestOther : public TestFixture { // TODO: only used in a single place #define checkCustomSettings(...) checkCustomSettings_(__FILE__, __LINE__, __VA_ARGS__) template - void checkCustomSettings_(const char* file, int line, const char (&code)[size], const Settings& settings) { + void checkCustomSettings_(const char* file, int line, const char (&code)[size], const Settings& settings, bool cpp = true) { // Tokenize.. - SimpleTokenizer tokenizer(settings, *this); + SimpleTokenizer tokenizer(settings, *this, cpp); ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. @@ -12010,6 +12010,12 @@ class TestOther : public TestFixture { " i = i++ + 2;\n" "}", settings11); ASSERT_EQUALS("[test.cpp:2:11]: (error) Expression 'i+++2' depends on order of evaluation of side effects [unknownEvaluationOrder]\n", errout_str()); + + // #14431 + checkCustomSettings("int f(void) {\n" + " struct baz baz = {.bar = {.foo = {.foo = 1}}};\n" + "}\n", settings0, false); + ASSERT_EQUALS("", errout_str()); } void testEvaluationOrderSelfAssignment() {