This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C] Patch: fix PR 22231
>>>>> "Joseph" == Joseph S Myers <joseph@codesourcery.com> writes:
>> PR preprocessor/22231:
>> * c-opts.c (sanitize_cpp_opts): Disallow -MG if compilation is
>> proceeding.
Joseph> OK if you add a testcase for this error.
Oops, my apologies. I've appended the patch I am checking in.
Tom
ChangeLog:
2008-05-09 Tom Tromey <tromey@redhat.com>
PR preprocessor/22231:
* c-opts.c (sanitize_cpp_opts): Disallow -MG if compilation is
proceeding.
testsuite/ChangeLog:
2008-05-09 Tom Tromey <tromey@redhat.com>
PR preprocessor/22231:
* gcc.dg/pr22231.c: New file.
Index: testsuite/gcc.dg/pr22231.c
===================================================================
--- testsuite/gcc.dg/pr22231.c (revision 0)
+++ testsuite/gcc.dg/pr22231.c (revision 0)
@@ -0,0 +1,7 @@
+/* Test case for PR 22231. -c and -MG are invalid together. */
+
+/* { dg-do compile } */
+/* { dg-options "-MG -MD -c" } */
+/* { dg-error "may only be used with -M" "" 0 */
+
+int anything;
Index: c-opts.c
===================================================================
--- c-opts.c (revision 134988)
+++ c-opts.c (working copy)
@@ -1427,6 +1427,8 @@
flag_dump_includes = 0;
flag_no_line_commands = 1;
}
+ else if (cpp_opts->deps.missing_files)
+ error ("-MG may only be used with -M or -MM");
cpp_opts->unsigned_char = !flag_signed_char;
cpp_opts->stdc_0_in_system_headers = STDC_0_IN_SYSTEM_HEADERS;