diff --git a/regression/goto-gcc/multiple-sources/error.desc b/regression/goto-gcc/multiple-sources/error.desc new file mode 100644 index 00000000000..bd5dcef05e8 --- /dev/null +++ b/regression/goto-gcc/multiple-sources/error.desc @@ -0,0 +1,7 @@ +CORE + +-c main1.c main2.c -o outfile +^EXIT=1$ +^SIGNAL=0$ +^cannot specify -o with -c with multiple files$ +-- diff --git a/regression/goto-gcc/multiple-sources/main1.c b/regression/goto-gcc/multiple-sources/main1.c new file mode 100644 index 00000000000..859ed91d505 --- /dev/null +++ b/regression/goto-gcc/multiple-sources/main1.c @@ -0,0 +1 @@ +// blank diff --git a/regression/goto-gcc/multiple-sources/main2.c b/regression/goto-gcc/multiple-sources/main2.c new file mode 100644 index 00000000000..859ed91d505 --- /dev/null +++ b/regression/goto-gcc/multiple-sources/main2.c @@ -0,0 +1 @@ +// blank diff --git a/src/goto-cc/gcc_mode.cpp b/src/goto-cc/gcc_mode.cpp index 24d7369b99f..07ebb10768d 100644 --- a/src/goto-cc/gcc_mode.cpp +++ b/src/goto-cc/gcc_mode.cpp @@ -723,6 +723,14 @@ int gcc_modet::doit() } } + if( + cmdline.isset('o') && cmdline.isset('c') && + compiler.source_files.size() >= 2) + { + error() << "cannot specify -o with -c with multiple files" << eom; + return 1; // to match gcc's behaviour + } + // Revert to gcc in case there is no source to compile // and no binary to link.