Commit 3570bfd4 authored by Alexandre Julliard's avatar Alexandre Julliard

Do not warn for unused imported dlls when forwards to the same dlls

are present.
parent f3a15607
...@@ -153,7 +153,7 @@ extern int output_res16_directory( unsigned char *buffer ); ...@@ -153,7 +153,7 @@ extern int output_res16_directory( unsigned char *buffer );
extern void BuildGlue( FILE *outfile, FILE *infile ); extern void BuildGlue( FILE *outfile, FILE *infile );
extern void BuildRelays( FILE *outfile ); extern void BuildRelays( FILE *outfile );
extern void BuildSpec16File( FILE *outfile ); extern void BuildSpec16File( FILE *outfile );
extern void BuildSpec32File( FILE *outfile, int output_main ); extern void BuildSpec32File( FILE *outfile );
extern SPEC_TYPE ParseTopLevel( FILE *file ); extern SPEC_TYPE ParseTopLevel( FILE *file );
/* global variables */ /* global variables */
......
...@@ -195,6 +195,25 @@ static void add_extra_undef_symbols(void) ...@@ -195,6 +195,25 @@ static void add_extra_undef_symbols(void)
} }
} }
/* warn if a given dll is not used, but check forwards first */
static void warn_unused( const char *dllname )
{
int i;
size_t len = strlen(dllname);
const char *p = strchr( dllname, '.' );
if (p && !strcasecmp( p, ".dll" )) len = p - dllname;
for (i = Base; i <= Limit; i++)
{
ORDDEF *odp = Ordinals[i];
if (!odp || odp->type != TYPE_FORWARD) continue;
if (!strncasecmp( odp->u.fwd.link_name, dllname, len ) &&
odp->u.fwd.link_name[len] == '.')
return; /* found an import, do not warn */
}
warning( "%s imported but no symbols used\n", dllname );
}
/* read in the list of undefined symbols */ /* read in the list of undefined symbols */
void read_undef_symbols( const char *name ) void read_undef_symbols( const char *name )
{ {
...@@ -249,7 +268,7 @@ int resolve_imports( FILE *outfile ) ...@@ -249,7 +268,7 @@ int resolve_imports( FILE *outfile )
else undef_symbols[j - off] = undef_symbols[j]; else undef_symbols[j - off] = undef_symbols[j];
} }
nb_undef_symbols -= off; nb_undef_symbols -= off;
if (!off) warning( "%s imported but no symbols used\n", imp->dll ); if (!off) warn_unused( imp->dll );
} }
return 1; return 1;
} }
......
...@@ -203,7 +203,7 @@ int main(int argc, char **argv) ...@@ -203,7 +203,7 @@ int main(int argc, char **argv)
BuildSpec16File( output_file ); BuildSpec16File( output_file );
break; break;
case SPEC_WIN32: case SPEC_WIN32:
BuildSpec32File( output_file, !resolve_imports( output_file ) ); BuildSpec32File( output_file );
break; break;
default: assert(0); default: assert(0);
} }
......
...@@ -358,12 +358,12 @@ static void output_stub_funcs( FILE *outfile ) ...@@ -358,12 +358,12 @@ static void output_stub_funcs( FILE *outfile )
* *
* Build a Win32 C file from a spec file. * Build a Win32 C file from a spec file.
*/ */
void BuildSpec32File( FILE *outfile, int output_main ) void BuildSpec32File( FILE *outfile )
{ {
ORDDEF *odp; ORDDEF *odp;
int i, fwd_size = 0, have_regs = FALSE; int i, fwd_size = 0, have_regs = FALSE;
int nr_exports, nr_imports, nr_resources, nr_debug; int nr_exports, nr_imports, nr_resources, nr_debug;
int characteristics, subsystem; int characteristics, subsystem, has_imports;
const char *init_func; const char *init_func;
DWORD page_size; DWORD page_size;
...@@ -380,6 +380,8 @@ void BuildSpec32File( FILE *outfile, int output_main ) ...@@ -380,6 +380,8 @@ void BuildSpec32File( FILE *outfile, int output_main )
AssignOrdinals(); AssignOrdinals();
nr_exports = Base <= Limit ? Limit - Base + 1 : 0; nr_exports = Base <= Limit ? Limit - Base + 1 : 0;
has_imports = resolve_imports( outfile );
fprintf( outfile, "/* File generated automatically from %s; do not edit! */\n\n", fprintf( outfile, "/* File generated automatically from %s; do not edit! */\n\n",
input_file_name ); input_file_name );
...@@ -498,7 +500,7 @@ void BuildSpec32File( FILE *outfile, int output_main ) ...@@ -498,7 +500,7 @@ void BuildSpec32File( FILE *outfile, int output_main )
" _ARGC = __wine_get_main_args( &_ARGV );\n" " _ARGC = __wine_get_main_args( &_ARGV );\n"
" ExitProcess( %s( GetModuleHandleA(0), 0, cmdline, info.wShowWindow ) );\n" " ExitProcess( %s( GetModuleHandleA(0), 0, cmdline, info.wShowWindow ) );\n"
"}\n\n", init_func, init_func ); "}\n\n", init_func, init_func );
if (output_main) if (!has_imports)
fprintf( outfile, fprintf( outfile,
"int main( int argc, char *argv[] )\n" "int main( int argc, char *argv[] )\n"
"{\n" "{\n"
...@@ -510,7 +512,7 @@ void BuildSpec32File( FILE *outfile, int output_main ) ...@@ -510,7 +512,7 @@ void BuildSpec32File( FILE *outfile, int output_main )
subsystem = IMAGE_SUBSYSTEM_WINDOWS_GUI; subsystem = IMAGE_SUBSYSTEM_WINDOWS_GUI;
break; break;
case SPEC_MODE_CUIEXE: case SPEC_MODE_CUIEXE:
if (!init_func) init_func = output_main ? "wine_main" : "main"; if (!init_func) init_func = has_imports ? "main" : "wine_main";
fprintf( outfile, fprintf( outfile,
"\n#include <winbase.h>\n" "\n#include <winbase.h>\n"
"int _ARGC;\n" "int _ARGC;\n"
...@@ -522,7 +524,7 @@ void BuildSpec32File( FILE *outfile, int output_main ) ...@@ -522,7 +524,7 @@ void BuildSpec32File( FILE *outfile, int output_main )
" _ARGC = __wine_get_main_args( &_ARGV );\n" " _ARGC = __wine_get_main_args( &_ARGV );\n"
" ExitProcess( %s( _ARGC, _ARGV ) );\n" " ExitProcess( %s( _ARGC, _ARGV ) );\n"
"}\n\n", init_func, init_func ); "}\n\n", init_func, init_func );
if (output_main) if (!has_imports)
fprintf( outfile, fprintf( outfile,
"int main( int argc, char *argv[] )\n" "int main( int argc, char *argv[] )\n"
"{\n" "{\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment