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

are present.
This commit is contained in:
Alexandre Julliard 2000-11-13 04:46:34 +00:00
parent f3a15607ad
commit 3570bfd41f
4 changed files with 29 additions and 8 deletions

View File

@ -153,7 +153,7 @@ extern int output_res16_directory( unsigned char *buffer );
extern void BuildGlue( FILE *outfile, FILE *infile );
extern void BuildRelays( 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 );
/* global variables */

View File

@ -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 */
void read_undef_symbols( const char *name )
{
@ -249,7 +268,7 @@ int resolve_imports( FILE *outfile )
else undef_symbols[j - off] = undef_symbols[j];
}
nb_undef_symbols -= off;
if (!off) warning( "%s imported but no symbols used\n", imp->dll );
if (!off) warn_unused( imp->dll );
}
return 1;
}

View File

@ -203,7 +203,7 @@ int main(int argc, char **argv)
BuildSpec16File( output_file );
break;
case SPEC_WIN32:
BuildSpec32File( output_file, !resolve_imports( output_file ) );
BuildSpec32File( output_file );
break;
default: assert(0);
}

View File

@ -358,12 +358,12 @@ static void output_stub_funcs( FILE *outfile )
*
* Build a Win32 C file from a spec file.
*/
void BuildSpec32File( FILE *outfile, int output_main )
void BuildSpec32File( FILE *outfile )
{
ORDDEF *odp;
int i, fwd_size = 0, have_regs = FALSE;
int nr_exports, nr_imports, nr_resources, nr_debug;
int characteristics, subsystem;
int characteristics, subsystem, has_imports;
const char *init_func;
DWORD page_size;
@ -380,6 +380,8 @@ void BuildSpec32File( FILE *outfile, int output_main )
AssignOrdinals();
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",
input_file_name );
@ -498,7 +500,7 @@ void BuildSpec32File( FILE *outfile, int output_main )
" _ARGC = __wine_get_main_args( &_ARGV );\n"
" ExitProcess( %s( GetModuleHandleA(0), 0, cmdline, info.wShowWindow ) );\n"
"}\n\n", init_func, init_func );
if (output_main)
if (!has_imports)
fprintf( outfile,
"int main( int argc, char *argv[] )\n"
"{\n"
@ -510,7 +512,7 @@ void BuildSpec32File( FILE *outfile, int output_main )
subsystem = IMAGE_SUBSYSTEM_WINDOWS_GUI;
break;
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,
"\n#include <winbase.h>\n"
"int _ARGC;\n"
@ -522,7 +524,7 @@ void BuildSpec32File( FILE *outfile, int output_main )
" _ARGC = __wine_get_main_args( &_ARGV );\n"
" ExitProcess( %s( _ARGC, _ARGV ) );\n"
"}\n\n", init_func, init_func );
if (output_main)
if (!has_imports)
fprintf( outfile,
"int main( int argc, char *argv[] )\n"
"{\n"