Skip to content

added test for undeclared functions #4212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions regression/ansi-c/undeclared_function/fileA.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// There is no #include <stdlib.h> here, deliberately,
// to trigger automatic generation of a signature below.

int main(void)
{
malloc(4);
}
6 changes: 6 additions & 0 deletions regression/ansi-c/undeclared_function/fileB.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdlib.h>

int f()
{
malloc(4);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
KNOWNBUG
fileA.c
fileB.c --validate-goto-model
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
^CONVERSION ERROR$
3 changes: 3 additions & 0 deletions src/goto-cc/armcc_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ int armcc_modet::doit()

debug() << "ARM mode" << eom;

// model validation
compiler.validate_goto_model = cmdline.isset("validate-goto-model");

// get configuration
config.set(cmdline);

Expand Down
6 changes: 6 additions & 0 deletions src/goto-cc/compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,12 @@ bool compilet::write_bin_object_file(
const std::string &file_name,
const goto_modelt &src_goto_model)
{
if(validate_goto_model)
{
status() << "Validating goto model" << eom;
src_goto_model.validate(validation_modet::INVARIANT);
}

statistics() << "Writing binary format object `"
<< file_name << "'" << eom;

Expand Down
1 change: 1 addition & 0 deletions src/goto-cc/compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class compilet : public messaget
bool echo_file_name;
std::string working_directory;
std::string override_language;
bool validate_goto_model = false;

enum { PREPROCESS_ONLY, // gcc -E
COMPILE_ONLY, // gcc -c
Expand Down
3 changes: 3 additions & 0 deletions src/goto-cc/cw_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ int cw_modet::doit()

debug() << "CodeWarrior mode" << eom;

// model validation
compiler.validate_goto_model = cmdline.isset("validate-goto-model");

// get configuration
config.set(cmdline);

Expand Down
1 change: 1 addition & 0 deletions src/goto-cc/gcc_cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const char *goto_cc_options_without_argument[]=
"--big-endian",
"--no-arch",
"--partial-inlining",
"--validate-goto-model",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add that to all modes, not just the GCC mode.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

"-?",
nullptr
};
Expand Down
3 changes: 3 additions & 0 deletions src/goto-cc/gcc_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ int gcc_modet::doit()
debug() << "GCC mode" << eom;
}

// model validation
compiler.validate_goto_model = cmdline.isset("validate-goto-model");

// determine actions to be undertaken
if(cmdline.isset('S'))
compiler.mode=compilet::ASSEMBLE_ONLY;
Expand Down
1 change: 1 addition & 0 deletions src/goto-cc/ld_cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const char *goto_ld_options_with_argument[]=
"--verbosity",
"--native-compiler",
"--native-linker",
"--validate-goto-model",
nullptr
};

Expand Down
3 changes: 3 additions & 0 deletions src/goto-cc/ld_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ int ld_modet::doit()
// determine actions to be undertaken
compiler.mode = compilet::LINK_LIBRARY;

// model validation
compiler.validate_goto_model = cmdline.isset("validate-goto-model");

// get configuration
config.set(cmdline);

Expand Down
3 changes: 3 additions & 0 deletions src/goto-cc/ms_cl_cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Author: Daniel Kroening
/// parses the command line options into a cmdlinet
/// \par parameters: argument count, argument strings
/// \return none
// clang-format off
const char *non_ms_cl_options[]=
{
"--show-symbol-table",
Expand All @@ -44,8 +45,10 @@ const char *non_ms_cl_options[]=
"--partial-inlining",
"--verbosity",
"--function",
"--validate-goto-model",
nullptr
};
// clang-format on

bool ms_cl_cmdlinet::parse(const std::vector<std::string> &arguments)
{
Expand Down
3 changes: 3 additions & 0 deletions src/goto-cc/ms_cl_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ int ms_cl_modet::doit()

debug() << "Visual Studio mode " << ms_cl_version << eom;

// model validation
compiler.validate_goto_model = cmdline.isset("validate-goto-model");

// get configuration
config.set(cmdline);

Expand Down