From 74dc6a119089515f330035d60c35f56756c8c862 Mon Sep 17 00:00:00 2001 From: Chris Demetriou Date: Fri, 18 Sep 2009 23:15:21 -0700 Subject: [PATCH] re PR preprocessor/28435 (-MMD vs not found system header (included from a system header)) [libcpp/ChangeLog] 2009-09-18 Chris Demetriou PR preprocessor/28435: * include/cpplib.h (struct cpp_options): Add new member deps.need_preprocessor_output. * files.c (open_file_failed): If preprocessor output is needed always report an error. [gcc/ChangeLog] 2009-09-19 Chris Demetriou PR preprocessor/28435: * c-opts.c (c_common_handle_option): For -MD and -MMD, indicate to cpplib that the preprocessor output is needed. [gcc/testsuite/ChangeLog] 2009-09-19 Chris Demetriou PR preprocessor/28435: * gcc.dg/cpp/missing-header-MD.c: New test. * gcc.dg/cpp/missing-header-MMD.c: New test. * gcc.dg/cpp/missing-sysheader-MD.c: New test. * gcc.dg/cpp/missing-sysheader-MMD.c: New test. From-SVN: r151879 --- gcc/ChangeLog | 6 +++++ gcc/c-opts.c | 1 + gcc/testsuite/ChangeLog | 8 ++++++ gcc/testsuite/gcc.dg/cpp/missing-header-MD.c | 6 +++++ gcc/testsuite/gcc.dg/cpp/missing-header-MMD.c | 6 +++++ .../gcc.dg/cpp/missing-sysheader-MD.c | 6 +++++ .../gcc.dg/cpp/missing-sysheader-MMD.c | 6 +++++ libcpp/ChangeLog | 8 ++++++ libcpp/files.c | 25 ++++++++++++++----- libcpp/include/cpplib.h | 4 +++ 10 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/cpp/missing-header-MD.c create mode 100644 gcc/testsuite/gcc.dg/cpp/missing-header-MMD.c create mode 100644 gcc/testsuite/gcc.dg/cpp/missing-sysheader-MD.c create mode 100644 gcc/testsuite/gcc.dg/cpp/missing-sysheader-MMD.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2d7182e46dc..27f877faf64 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2009-09-19 Chris Demetriou + + PR preprocessor/28435: + * c-opts.c (c_common_handle_option): For -MD and -MMD, indicate + to cpplib that the preprocessor output is needed. + 2009-09-19 Jakub Jelinek * config/rs6000/rs6000.md (*save_gpregs_, *save_fpregs_, diff --git a/gcc/c-opts.c b/gcc/c-opts.c index 3b9b34bdc3f..d9165aa6061 100644 --- a/gcc/c-opts.c +++ b/gcc/c-opts.c @@ -343,6 +343,7 @@ c_common_handle_option (size_t scode, const char *arg, int value) case OPT_MD: case OPT_MMD: cpp_opts->deps.style = (code == OPT_MD ? DEPS_SYSTEM: DEPS_USER); + cpp_opts->deps.need_preprocessor_output = true; deps_file = arg; break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ed2939911a6..301dfbbe4d6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2009-09-19 Chris Demetriou + + PR preprocessor/28435: + * gcc.dg/cpp/missing-header-MD.c: New test. + * gcc.dg/cpp/missing-header-MMD.c: New test. + * gcc.dg/cpp/missing-sysheader-MD.c: New test. + * gcc.dg/cpp/missing-sysheader-MMD.c: New test. + 2009-09-18 Jerry DeLisle PR libgfortran/41328 diff --git a/gcc/testsuite/gcc.dg/cpp/missing-header-MD.c b/gcc/testsuite/gcc.dg/cpp/missing-header-MD.c new file mode 100644 index 00000000000..198352537ee --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/missing-header-MD.c @@ -0,0 +1,6 @@ +/* Test that missing user headers are fatal errors with -MD. */ +/* { dg-do compile } */ +/* { dg-options "-MD" } */ + +#include "nonexistent.h" /* { dg-error "nonexistent.h" } */ +/* { dg-message "terminated" "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.dg/cpp/missing-header-MMD.c b/gcc/testsuite/gcc.dg/cpp/missing-header-MMD.c new file mode 100644 index 00000000000..aff8d395596 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/missing-header-MMD.c @@ -0,0 +1,6 @@ +/* Test that missing user headers are fatal errors with -MMD. */ +/* { dg-do compile } */ +/* { dg-options "-MMD" } */ + +#include "nonexistent.h" /* { dg-error "nonexistent.h" } */ +/* { dg-message "terminated" "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.dg/cpp/missing-sysheader-MD.c b/gcc/testsuite/gcc.dg/cpp/missing-sysheader-MD.c new file mode 100644 index 00000000000..bf255a4994d --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/missing-sysheader-MD.c @@ -0,0 +1,6 @@ +/* Test that missing system headers are fatal errors with -MD. */ +/* { dg-do compile } */ +/* { dg-options "-MD" } */ + +#include /* { dg-error "nonexistent.h" } */ +/* { dg-message "terminated" "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.dg/cpp/missing-sysheader-MMD.c b/gcc/testsuite/gcc.dg/cpp/missing-sysheader-MMD.c new file mode 100644 index 00000000000..10cd870ad54 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/missing-sysheader-MMD.c @@ -0,0 +1,6 @@ +/* Test that missing system headers are fatal errors with -MMD. */ +/* { dg-do compile } */ +/* { dg-options "-MMD" } */ + +#include /* { dg-error "nonexistent.h" } */ +/* { dg-message "terminated" "" { target *-*-* } 0 } */ diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 5d278223113..6b257d211cb 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,11 @@ +2009-09-18 Chris Demetriou + + PR preprocessor/28435: + * include/cpplib.h (struct cpp_options): Add new member + deps.need_preprocessor_output. + * files.c (open_file_failed): If preprocessor output is needed + always report an error. + 2009-09-13 Kai Tietz * configure.ac: Set for i?86-w64-mingw* diff --git a/libcpp/files.c b/libcpp/files.c index 69aa7895361..96ba7e80afc 100644 --- a/libcpp/files.c +++ b/libcpp/files.c @@ -935,15 +935,28 @@ open_file_failed (cpp_reader *pfile, _cpp_file *file, int angle_brackets) errno = file->err_no; if (print_dep && CPP_OPTION (pfile, deps.missing_files) && errno == ENOENT) - deps_add_dep (pfile->deps, file->name); + { + deps_add_dep (pfile->deps, file->name); + /* If the preprocessor output (other than dependency information) is + being used, we must also flag an error. */ + if (CPP_OPTION (pfile, deps.need_preprocessor_output)) + cpp_errno (pfile, CPP_DL_FATAL, file->path); + } else { - /* If we are outputting dependencies but not for this file then - don't error because we can still produce correct output. */ - if (CPP_OPTION (pfile, deps.style) && ! print_dep) - cpp_errno (pfile, CPP_DL_WARNING, file->path); - else + /* If we are not outputting dependencies, or if we are and dependencies + were requested for this file, or if preprocessor output is needed + in addition to dependency information, this is an error. + + Otherwise (outputting dependencies but not for this file, and not + using the preprocessor output), we can still produce correct output + so it's only a warning. */ + if (CPP_OPTION (pfile, deps.style) == DEPS_NONE + || print_dep + || CPP_OPTION (pfile, deps.need_preprocessor_output)) cpp_errno (pfile, CPP_DL_FATAL, file->path); + else + cpp_errno (pfile, CPP_DL_WARNING, file->path); } } diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index e873ccfeea5..df04668dda0 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -433,6 +433,10 @@ struct cpp_options /* If true, no dependency is generated on the main file. */ bool ignore_main_file; + + /* If true, intend to use the preprocessor output (e.g., for compilation) + in addition to the dependency info. */ + bool need_preprocessor_output; } deps; /* Target-specific features set by the front end or client. */