diff --git a/Makefile b/Makefile index 6053f1c83..b95c9e7a2 100644 --- a/Makefile +++ b/Makefile @@ -16,9 +16,9 @@ ifeq ($(HAVE_RULES),yes) endif endif -ifndef CXX - CXX=g++ -endif +#ifndef CXX + CXX=clang++ +#endif ifndef PREFIX PREFIX=/usr diff --git a/lib/checkautovariables.cpp b/lib/checkautovariables.cpp index 5c040d424..1d648e120 100644 --- a/lib/checkautovariables.cpp +++ b/lib/checkautovariables.cpp @@ -107,7 +107,7 @@ void CheckAutoVariables::autoVariables() if (var1 && var1->isArgument() && Token::Match(var1->nameToken()->tokAt(-3), "%type% * *")) { const Variable * var2 = symbolDatabase->getVariableFromVarId(tok->tokAt(4)->varId()); - if (var2 && var2->isLocal() && var2->isArray()) + if (var2 && var2->isLocal() && var2->isArray() && !var2->isStatic()) errorAutoVariableAssignment(tok); } tok = tok->tokAt(4); diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index 8d81b6e2f..1837ac707 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -70,6 +70,7 @@ private: TEST_CASE(testautovar1); TEST_CASE(testautovar2); TEST_CASE(testautovar3); // ticket #2925 + TEST_CASE(testautovar4); // ticket #2928 TEST_CASE(testautovar_array1); TEST_CASE(testautovar_array2); TEST_CASE(testautovar_return1); @@ -164,6 +165,16 @@ private: ASSERT_EQUALS("[test.cpp:3]: (error) Assigning address of local auto-variable to a function parameter.\n", errout.str()); } + void testautovar4() // ticket #2928 + { + check("void foo(int **p)\n" + "{\n" + " static int x[100];\n" + " *p = x;\n" + "}"); + ASSERT_EQUALS("", errout.str()); + } + void testautovar_array1() { check("void func1(int* arr[2])\n"