From 2b48c7624c99d5bcd2a95922cc48751c4a82b96e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 27 Jul 2011 10:43:44 +0200 Subject: [PATCH] Auto Variables: Reverted fix for #1514 because my idea was wrong. See ticket: #2944 --- lib/checkautovariables.cpp | 11 ----------- test/testautovariables.cpp | 15 ++------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/lib/checkautovariables.cpp b/lib/checkautovariables.cpp index 1a6f18bff..8529f3a94 100644 --- a/lib/checkautovariables.cpp +++ b/lib/checkautovariables.cpp @@ -134,17 +134,6 @@ void CheckAutoVariables::autoVariables() } tok = tok->tokAt(4); } - else if (Token::Match(tok, "[;{}] %var% = & %var% ;")) - { - const Variable * var1 = symbolDatabase->getVariableFromVarId(tok->tokAt(1)->varId()); - if (var1 && var1->isArgument() && Token::Match(var1->nameToken()->tokAt(-2), "%type% *")) - { - const Variable * var2 = symbolDatabase->getVariableFromVarId(tok->tokAt(4)->varId()); - if (var2 && var2->isLocal() && !var2->isStatic()) - errorAutoVariableAssignment(tok); - } - tok = tok->tokAt(4); - } else if (Token::Match(tok, "[;{}] %var% [ %any% ] = & %var%") && errorAv(tok->tokAt(1), tok->tokAt(7))) { errorAutoVariableAssignment(tok); diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index 0d6e3b8d8..13dfcde02 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -72,8 +72,7 @@ private: TEST_CASE(testautovar3); // ticket #2925 TEST_CASE(testautovar4); // ticket #2928 TEST_CASE(testautovar5); // ticket #2926 - TEST_CASE(testautovar6); // ticket #1514 - TEST_CASE(testautovar7); // ticket #2931 + TEST_CASE(testautovar6); // ticket #2931 TEST_CASE(testautovar_array1); TEST_CASE(testautovar_array2); TEST_CASE(testautovar_return1); @@ -188,17 +187,7 @@ private: ASSERT_EQUALS("[test.cpp:3]: (error) Assigning address of local auto-variable to a function parameter.\n", errout.str()); } - void testautovar6() // ticket #1514 - { - check("void foo(int * x)\n" - "{\n" - " int y;\n" - " x = &y;\n" - "}"); - ASSERT_EQUALS("[test.cpp:3]: (error) Assigning address of local auto-variable to a function parameter.\n", errout.str()); - } - - void testautovar7() // ticket #2931 + void testautovar6() // ticket #2931 { check("void foo(struct X *x)\n" "{\n"