From 908bc664a49b563eff04e395dacb7de9536b4498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 27 Dec 2015 14:08:16 +0100 Subject: [PATCH] Evaluation order: ignore usage in sizeof --- lib/checkother.cpp | 2 ++ test/testother.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 98085b740..4f68418da 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2537,6 +2537,8 @@ void CheckOther::checkEvaluationOrder() continue; if (tok3->str() == "&" && !tok3->astOperand2()) continue; // don't handle adress-of for now + if (tok3->str() == "(" && Token::simpleMatch(tok3->previous(), "sizeof")) + continue; // don't care about sizeof usage tokens.push(tok3->astOperand1()); tokens.push(tok3->astOperand2()); if (isSameExpression(_tokenizer->isCPP(), false, tok->astOperand1(), tok3, _settings->library.functionpure)) { diff --git a/test/testother.cpp b/test/testother.cpp index d44726f03..b5e20882c 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -6143,6 +6143,12 @@ private: "}", "test.c"); TODO_ASSERT_EQUALS("error", "", errout.str()); } + + // sizeof + check("void f(char *buf) {\n" + " dostuff(buf++, sizeof(*buf));" + "}", "test.c"); + ASSERT_EQUALS("", errout.str()); } };