From 317639a81c1c666ab67014d458da7cb57a554a92 Mon Sep 17 00:00:00 2001 From: Branko Cibej Date: Tue, 26 Sep 2000 00:54:04 +0200 Subject: flags.h: Declare warning flag warn_system_headers. 2000-09-25 Branko Cibej * flags.h: Declare warning flag warn_system_headers. * toplev.c: Define it. (W_options): Add option -Wsystem-headers. * diagnostic.c (count_error): Test warn_system_headers. * invoke.texi: Add description for -Wsystem-headers. * cpplib.h (cpp_options): New member warn_system_headers. * cpphash.h (CPP_PEDANTIC, CPP_WTRADITIONAL): Don't test CPP_IN_SYSTEM_HEADER. * cpplib.c (do_import, do_pragma_once): Likewise. * cpperror.c (_cpp_begin_message): Test warn_system_headers and CPP_IN_SYSTEM_HEADER. * cppinit.c (handle_option): Recognize -Wsystem_headers. (print_help): Describe -Wsystem_headers. * cpplex.c (lex_line): Reorganize condition so that warnings about C++ comments in system headers can be enabled. Remove label do_line_comment. From-SVN: r36636 --- gcc/cpplex.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'gcc/cpplex.c') diff --git a/gcc/cpplex.c b/gcc/cpplex.c index 0c31560..47dcdbc 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -1209,10 +1209,24 @@ lex_token (pfile, result) irrespective of conformance mode, because lots of broken systems do that and trying to clean it up in fixincludes is a nightmare. */ - if (!CPP_IN_SYSTEM_HEADER (pfile) - && CPP_OPTION (pfile, c89) && CPP_PEDANTIC (pfile) - && !buffer->warned_cplusplus_comments) + if (CPP_OPTION (pfile, cplusplus_comments) + || CPP_IN_SYSTEM_HEADER (pfile)) { + if (CPP_OPTION (pfile, c89) && CPP_PEDANTIC (pfile) + && ! buffer->warned_cplusplus_comments) + { + cpp_pedwarn (pfile, + "C++ style comments are not allowed in ISO C89"); + cpp_pedwarn (pfile, + "(this will be reported only once per input file)"); + buffer->warned_cplusplus_comments = 1; + } + comment_start = buffer->cur; + + /* Skip_line_comment updates buffer->read_ahead. */ + if (skip_line_comment (pfile)) + cpp_warning_with_line (pfile, result->line, result->col, + "multi-line comment"); cpp_pedwarn (pfile, "C++ style comments are not allowed in ISO C89"); cpp_pedwarn (pfile, -- cgit v1.1