From be90080976627e72668d4045ebabe9539a6dff33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 7 May 2016 19:51:37 +0200 Subject: [PATCH] Fixed #7481 (False positive AssignmentAddressToInteger - pointer to enum) --- lib/symboldatabase.cpp | 2 +- test/testsymboldatabase.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index d0e56e836..14df71eca 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -4047,7 +4047,7 @@ static void setValueType(Token *tok, const Variable &var, bool cpp, ValueType::S setValueType(tok, valuetype, cpp, defaultSignedness, lib); valuetype.originalTypeName = var.type()->classScope->className; } - } else { + } else if (parsedecl(var.typeStartToken(), &valuetype, defaultSignedness, lib)) { valuetype.sign = ValueType::SIGNED; valuetype.type = ValueType::INT; setValueType(tok, valuetype, cpp, defaultSignedness, lib); diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index dcdcff94a..4a8ac8a71 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -3220,6 +3220,7 @@ private: ASSERT_EQUALS("signed int", typeOf("struct X {int i;}; void f(struct X x) { x.i }", ".")); ASSERT_EQUALS("signed int *", typeOf("int *p; a = p++;", "++")); ASSERT_EQUALS("signed int", typeOf("int x; a = x++;", "++")); + ASSERT_EQUALS("signed int *", typeOf("enum AB {A,B}; enum AB *ab; x=ab+2;", "+")); // Unary arithmetic/bit operators ASSERT_EQUALS("signed int", typeOf("int x; a = -x;", "-"));