fix -Wodr warning/violation putting struct 'VarInfo' into anonyous namespace

Was:

lib/checkclass.cpp:1994:8: warning: type ‘struct VarInfo’ violates one definition rule [-Wodr]
 struct VarInfo {
        ^
lib/checkleakautovar.h:32:7: note: a different type is defined in another translation unit
 class CPPCHECKLIB VarInfo {
       ^
lib/checkclass.cpp:1998:21: note: the first difference of corresponding definitions is field ‘var’
     const Variable *var;
                     ^
lib/checkleakautovar.h:40:39: note: a field with different name is defined in another translation unit
     std::map<unsigned int, AllocInfo> alloctype;
This commit is contained in:
Matthias Krüger 2015-09-08 15:11:17 +02:00
parent e929e9e7d9
commit 49e2573b5c
1 changed files with 8 additions and 6 deletions

View File

@ -1991,6 +1991,7 @@ void CheckClass::checkConstError2(const Token *tok1, const Token *tok2, const st
// ClassCheck: Check that initializer list is in declared order.
//---------------------------------------------------------------------------
namespace { // avoid one-definition-rule violation
struct VarInfo {
VarInfo(const Variable *_var, const Token *_tok)
: var(_var), tok(_tok) { }
@ -1998,6 +1999,7 @@ struct VarInfo {
const Variable *var;
const Token *tok;
};
}
void CheckClass::initializerListOrder()
{