From patchwork Fri Oct 3 21:29:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWFudWVsIEzDs3Blei1JYsOhw7Fleg==?= X-Patchwork-Id: 396453 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 813A01401B1 for ; Sat, 4 Oct 2014 07:30:24 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=USQU0phw0LoRX81j5WnPWcOCHuyIjGuLfdMgExrvh5Ad11 7NFOWUAlw2mG78gayjmkr8L4RYkzxSrYH5aIhAY6qGoEQ0oyXe8F6naqWqNDUW+z CXrcq08mjCJvqE/14yEwhS4R4O/yCH0rRQyYwQ6H4Av6lJTCP5dudeypZuvfc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=DTt4YQE58KP4fjTnCos9mmi3O2w=; b=FMfqkjKP5XV7h31emwF0 E/7G6j+Wx26z4/mzhoLdmUyNlurgf73DG1aZ0OWMKAYAHeLqsKYOdfxC17COGZl3 7x6h8nuzNnT74UUVQEuB6KVJVk3DLkf7hoyk64VziuTKv35eDskFkvcySokvnj8v tdexHvtCad2FAQFE8BxDbWU= Received: (qmail 20943 invoked by alias); 3 Oct 2014 21:30:11 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 20921 invoked by uid 89); 3 Oct 2014 21:30:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-wi0-f182.google.com Received: from mail-wi0-f182.google.com (HELO mail-wi0-f182.google.com) (209.85.212.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 03 Oct 2014 21:30:09 +0000 Received: by mail-wi0-f182.google.com with SMTP id n3so25502wiv.15 for ; Fri, 03 Oct 2014 14:30:05 -0700 (PDT) X-Received: by 10.194.83.67 with SMTP id o3mr10140566wjy.31.1412371805695; Fri, 03 Oct 2014 14:30:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.217.80.73 with HTTP; Fri, 3 Oct 2014 14:29:44 -0700 (PDT) From: =?ISO-8859-1?Q?Manuel_L=F3pez=2DIb=E1=F1ez?= Date: Fri, 3 Oct 2014 23:29:44 +0200 Message-ID: Subject: [PATCH Fortran] move more diagnostics to the common machinery To: Gcc Patch List , "fortran@gcc.gnu.org List" , Tobias Burnus The following patch adds two new functions. One of them is an overload of gfc_warning_cmdline() that takes an option. Thus now we get: f951: Warning: Nonexistent include directory 'C:\msys\1.0.10\home\FX\ibin\i586-pc-mingw32\libgfortran/../../../trunk/libgfortran/generated' [-Wmissing-include-dirs] plus colors! and of course, with -Werror=missing-include-dirs you get: f951: Error: Nonexistent include directory 'C:\msys\1.0.10\home\FX\ibin\i586-pc-mingw32\libgfortran/../../../trunk/libgfortran/generated' [-Werror=missing-include-dirs] f951: some warnings being treated as errors The other new function is for errors instead of warnings. Perhaps there are more places where these functions can be used. Bootstrapped and regression tested on x86_64-linux-gnu. OK? gcc/fortran/ChangeLog: 2014-10-03 Manuel López-Ibáñez * gfortran.h (gfc_warning_cmdline): Add overload variant taking an option. (gfc_error_cmdline): Declare. * error.c (gfc_warning_cmdline): New (gfc_error_cmdline): New. * scanner.c (add_path_to_list): Use them. (load_file): Likewise. Index: gcc/fortran/gfortran.h =================================================================== --- gcc/fortran/gfortran.h (revision 214251) +++ gcc/fortran/gfortran.h (working copy) @@ -2690,16 +2690,18 @@ void gfc_buffer_error (int); const char *gfc_print_wide_char (gfc_char_t); void gfc_warning (const char *, ...) ATTRIBUTE_GCC_GFC(1,2); void gfc_warning_now (const char *, ...) ATTRIBUTE_GCC_GFC(1,2); -void gfc_warning_cmdline (const char *gmsgid, ...) ATTRIBUTE_GCC_GFC(1,2); +bool gfc_warning_cmdline (const char *gmsgid, ...) ATTRIBUTE_GCC_GFC(1,2); +bool gfc_warning_cmdline (int opt, const char *gmsgid, ...) ATTRIBUTE_GCC_GFC(2,3); void gfc_clear_warning (void); void gfc_warning_check (void); void gfc_error (const char *, ...) ATTRIBUTE_GCC_GFC(1,2); +void gfc_error_cmdline (const char *gmsgid, ...) ATTRIBUTE_GCC_GFC(1,2); void gfc_error_now (const char *, ...) ATTRIBUTE_GCC_GFC(1,2); void gfc_fatal_error (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_GCC_GFC(1,2); void gfc_internal_error (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_GCC_GFC(1,2); void gfc_clear_error (void); int gfc_error_check (void); Index: gcc/fortran/error.c =================================================================== --- gcc/fortran/error.c (revision 214251) +++ gcc/fortran/error.c (working copy) @@ -1050,25 +1050,61 @@ gfc_diagnostic_finalizer (diagnostic_con { pp_destroy_prefix (context->printer); pp_newline_and_flush (context->printer); } /* Give a warning about the command-line. */ -void +bool +gfc_warning_cmdline (int opt, const char *gmsgid, ...) +{ + va_list argp; + diagnostic_info diagnostic; + bool ret; + + va_start (argp, gmsgid); + diagnostic_set_info (&diagnostic, gmsgid, &argp, UNKNOWN_LOCATION, + DK_WARNING); + diagnostic.option_index = opt; + ret = report_diagnostic (&diagnostic); + va_end (argp); + return ret; +} + + +/* Give a warning about the command-line. */ + +bool gfc_warning_cmdline (const char *gmsgid, ...) { va_list argp; diagnostic_info diagnostic; + bool ret; va_start (argp, gmsgid); diagnostic_set_info (&diagnostic, gmsgid, &argp, UNKNOWN_LOCATION, DK_WARNING); + ret = report_diagnostic (&diagnostic); + va_end (argp); + return ret; +} + + +/* Give an error about the command-line. */ + +void +gfc_error_cmdline (const char *gmsgid, ...) +{ + va_list argp; + diagnostic_info diagnostic; + + va_start (argp, gmsgid); + diagnostic_set_info (&diagnostic, gmsgid, &argp, UNKNOWN_LOCATION, DK_ERROR); report_diagnostic (&diagnostic); va_end (argp); } /* Clear the warning flag. */ void gfc_clear_warning (void) { Index: gcc/fortran/scanner.c =================================================================== --- gcc/fortran/scanner.c (revision 214251) +++ gcc/fortran/scanner.c (working copy) @@ -322,23 +322,20 @@ add_path_to_list (gfc_directorylist **li q[i--] = '\0'; if (stat (q, &st)) { if (errno != ENOENT) - gfc_warning_now ("Include directory \"%s\": %s", path, - xstrerror(errno)); - else - { - /* FIXME: Also support -Wmissing-include-dirs. */ - if (warn) - gfc_warning_now ("Nonexistent include directory \"%s\"", path); - } + gfc_warning_cmdline ("Include directory %qs: %s", path, + xstrerror(errno)); + else if (warn) + gfc_warning_cmdline (OPT_Wmissing_include_dirs, + "Nonexistent include directory %qs", path); return; } else if (!S_ISDIR (st.st_mode)) { - gfc_warning_now ("\"%s\" is not a directory", path); + gfc_warning_cmdline ("%qs is not a directory", path); return; } if (head || *list == NULL) { @@ -1923,11 +1920,11 @@ load_file (const char *realfilename, con } else input = gfc_open_file (realfilename); if (input == NULL) { - gfc_error_now ("Can't open file '%s'", filename); + gfc_error_cmdline ("Can't open file %qs", filename); return false; } } else {