eranif / codelite

A multi purpose IDE specialized in C/C++/Rust/Python/PHP and Node.js. Written in C++
https://codelite.org
GNU General Public License v2.0
2.09k stars 449 forks source link

Some warnings #1748

Closed zufuliu closed 4 years ago

zufuliu commented 6 years ago
codelite/CodeFormatter/codeformatter.cpp: In member function 'void CodeFormatter::DoFormatWithClang(wxString&, const wxFileName&, int&, const int&, const int&)':
codelite/CodeFormatter/codeformatter.cpp:486:58: warning: 'tailLength' may be used uninitialized in this function [-Wmaybe-uninitialized]
         content = content.Mid(selStart, content.length() - tailLength - selStart);
                                         ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~

codelite/CallGraph/dotwriter.cpp: In member function 'wxString DotWriter::OptionsShortNameAndParameters(const wxString&)':
codelite/CallGraph/dotwriter.cpp:220:48: warning: 'end' may be used uninitialized in this function [-Wmaybe-uninitialized]
                 out.Replace(out.Mid(start, end - start + 1), wxT("%STL%"));
                                            ~~~~^~~~~~~
codelite/CallGraph/dotwriter.cpp:220:48: warning: 'start' may be used uninitialized in this function [-Wmaybe-uninitialized]

codelite/codelite_vim/vimCommands.cpp: In member function 'bool VimCommand::OnEscapeDown()':
codelite/codelite_vim/vimCommands.cpp:88:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
codelite/codelite_vim/vimCommands.cpp: In member function 'wxString VimCommand::get_text_at_position(VimCommand::eTypeTextSearch)':
codelite/codelite_vim/vimCommands.cpp:1087:43: warning: 'end' may be used uninitialized in this function [-Wmaybe-uninitialized]
     return m_ctrl->GetTextRange(start, end);
                                           ^
codelite/codelite_vim/vimCommands.cpp:1087:43: warning: 'start' may be used uninitialized in this function [-Wmaybe-uninitialized]

codelite/PHPLint/lintoptions.cpp: In constructor 'LintOptions::LintOptions()':
codelite/PHPLint/lintoptions.cpp:24:65: warning: 'm_flags' may be used uninitialized in this function [-Wmaybe-uninitialized]
         size_t m_flags = oldJson.namedObject("m_flags").toSize_t(m_flags) & (1 << 1);
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
codelite/PHPLint/phplint.cpp: In member function 'bool PHPLint::IsWarning(wxXmlNode*, const wxString&)':
codelite/PHPLint/phplint.cpp:303:45: warning: comparison of constant '2' with boolean expression is always false [-Wbool-compare]
         return priority.ToCLong(&nPriority) > 2;
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
zufuliu commented 6 years ago
codelite/CodeLite/performance.cpp: In function 'void PERF_START(const char*)':
codelite/CodeLite/performance.cpp:50:82: warning: field width specifier '*' expects argument of type 'int', but argument 3 has type 'std::vector<std::pair<long unsigned int, long unsigned int> >::size_type {aka long long unsigned int}' [-Wformat=]
  fprintf(dbgFile, "%*c<block name=\"%s\">\n", 4*tickCounts.size(), ' ', func_name);
                                               ~~~~~~~~~~~~~~~~~~~                ^
codelite/CodeLite/performance.cpp: In function 'void PERF_END()':
codelite/CodeLite/performance.cpp:57:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if (tickCounts.empty())
     ^~
codelite/CodeLite/performance.cpp:60:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  DWORD tickCount   = GetTickCount();
  ^~~~~
codelite/CodeLite/performance.cpp:64:83: warning: field width specifier '*' expects argument of type 'int', but argument 3 has type 'std::vector<std::pair<long unsigned int, long unsigned int> >::size_type {aka long long unsigned int}' [-Wformat=]
     fprintf(dbgFile, "%*c<elapsed time=\"%ld\"", 4*tickCounts.size(), ' ', elapsed);
                                                  ~~~~~~~~~~~~~~~~~~~              ^
codelite/CodeLite/performance.cpp:75:63: warning: field width specifier '*' expects argument of type 'int', but argument 3 has type 'std::vector<std::pair<long unsigned int, long unsigned int> >::size_type {aka long long unsigned int}' [-Wformat=]
     fprintf(dbgFile, "%*c</block>\n", 4*tickCounts.size(), ' ');
                                       ~~~~~~~~~~~~~~~~~~~     ^

codelite/CodeLite/lex.yy.cpp: In member function 'virtual int flex::yyFlexLexer::yylex()':
codelite/CodeLite/lex.yy.cpp:1118:10: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
          if (m_keepComments)
          ^~
codelite/CodeLite/lex.yy.cpp:1120:11: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
           while ((c = yyinput()) != '\n' && c != EOF)
           ^~~~~

In file included from codelite/SpellChecker/hunspell/affixmgr.cxx:12:0:
codelite/SpellChecker/hunspell/affentry.hxx:30:105: warning: converting to non-pointer type 'short unsigned int' from NULL [-Wconversion-null]
   struct hentry *      check_twosfx(const char * word, int len, char in_compound, const FLAG needflag = NULL);
                                                                                                         ^~~~
codelite/SpellChecker/hunspell/affentry.hxx:93:114: warning: converting to non-pointer type 'short unsigned int' from NULL [-Wconversion-null]
   struct hentry *   check_twosfx(const char * word, int len, int optflags, PfxEntry* ppfx, const FLAG needflag = NULL);
                                                                                                                  ^~~~
zufuliu commented 6 years ago
codelite/CodeLite/scope_parser.cpp: In function 'int cl_scope_parse()':
codelite/CodeLite/scope_parser.cpp:856:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
     if (yyn = yydefred[yystate]) goto yyreduce;
         ~~~~^~~~~~~~~~~~~~~~~~~
codelite/CodeLite/scope_parser.cpp:900:27: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     yyerror("syntax error");
                           ^
codelite/CodeLite/scope_parser.cpp:1355:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     yyerror("yacc stack overflow");
                                  ^
codelite/CodeLite/cpp_expr_parser.cpp: In function 'int cl_expr_parse()':
codelite/CodeLite/cpp_expr_parser.cpp:554:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
     if (yyn = yydefred[yystate]) goto yyreduce;
         ~~~~^~~~~~~~~~~~~~~~~~~
codelite/CodeLite/cpp_expr_parser.cpp:598:27: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     yyerror("syntax error");
                           ^
codelite/CodeLite/cpp_expr_parser.cpp:971:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     yyerror("yacc stack overflow");
                                  ^
codelite/CodeLite/cpp_func_parser.cpp: In function 'int cl_func_parse()':
codelite/CodeLite/cpp_func_parser.cpp:648:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
     if (yyn = yydefred[yystate]) goto yyreduce;
         ~~~~^~~~~~~~~~~~~~~~~~~
codelite/CodeLite/cpp_func_parser.cpp:692:27: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     yyerror("syntax error");
                           ^
codelite/CodeLite/cpp_func_parser.cpp:1044:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     yyerror("yacc stack overflow");
                                  ^
codelite/CodeLite/var_parser.cpp: In function 'int cl_var_parse()':
codelite/CodeLite/var_parser.cpp:770:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
     if (yyn = yydefred[yystate]) goto yyreduce;
         ~~~~^~~~~~~~~~~~~~~~~~~
codelite/CodeLite/var_parser.cpp:814:27: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     yyerror("syntax error");
                           ^
codelite/CodeLite/var_parser.cpp:1418:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     yyerror("yacc stack overflow");
                                  ^
codelite/CodeLite/typedef_parser.cpp: In function 'int cl_typedef_parse()':
codelite/CodeLite/typedef_parser.cpp:552:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
     if (yyn = yydefred[yystate]) goto yyreduce;
         ~~~~^~~~~~~~~~~~~~~~~~~
codelite/CodeLite/typedef_parser.cpp:596:27: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     yyerror("syntax error");
                           ^
codelite/CodeLite/typedef_parser.cpp:933:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     yyerror("yacc stack overflow");
                                  ^
codelite/CodeLite/pp.cpp:329:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
     if (yyn = yydefred[yystate]) goto yyreduce;
         ~~~~^~~~~~~~~~~~~~~~~~~
codelite/Debugger/gdb_result_parser.cpp: In function 'int gdb_result_parse()':
codelite/Debugger/gdb_result_parser.cpp:513:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
     if (yyn = yydefred[yystate]) goto yyreduce;
         ~~~~^~~~~~~~~~~~~~~~~~~
codelite/LiteEditor/clang_result_parser.cpp:446:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
     if (yyn = yydefred[yystate]) goto yyreduce;
         ~~~~^~~~~~~~~~~~~~~~~~~
codelite/LiteEditor/clang_result_parser.cpp:490:27: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     yyerror("syntax error");
                           ^
codelite/LiteEditor/clang_result_parser.cpp:727:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     yyerror("yacc stack overflow");
                                  ^
zufuliu commented 6 years ago
other warnings count
dynamic exception specifications are deprecated in C++11 [-Wdeprecated] 743
type qualifiers ignored on function return type [-Wignored-qualifiers] 1478
should be explicitly initialized in the copy constructor [-Wextra] 111
this statement may fall through [-Wimplicit-fallthrough=] 12
suggest braces around empty body in an 'if' statement [-Wempty-body] 101
[-Wreorder] 30
will be initialized after [-Wreorder] 10
[-Wmissing-field-initializers] 16
comparison between signed and unsigned integer expressions [-Wsign-compare] 7
[-Wmisleading-indentation] 7
[-Wunused-parameter] 2071
zufuliu commented 6 years ago

These warning is produced by MinGW-w64 GCC with -Wall -Wextra flags. (I don't add -Wshadow, because GCC warns method parameter shadow object field, however local variable shadow exits in CodeLite.)

gcc -v:

Thread model: posix
gcc version 7.1.0 (x86_64-posix-seh-rev2, Built by MinGW-W64 project)

I had mentioned some warnings in issue #1710, however not full fixed.

PR #1728 fixed some warnings, especially dynamic exception specifications are deprecated in C++11 [-Wdeprecated].

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.