From patchwork Sun Nov 23 09:27:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 413370 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 457CA140081 for ; Sun, 23 Nov 2014 20:27:33 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=oZaxos/gpszqzLuWE4fvDU/VONuDCCS3twzr2Gv2NOkx51 mrn4ZJvHvbqYYt9HqAlbPbW1M8neRQervUOpA8nr80Snm0FYOc9PzFE4rP1NbHx/ JkvgtuDKZlekUk5TxAuDR2+pXsf0570Xsk636uY1hX1BL13MxE47hjT2kbBWw= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=ZjE7grSbG7BkVKPkzsaHJbZjjwE=; b=CvmUf3BVfxE8W2ulXS8f /dHTfCVv72yrdOZOmAybzxprJS+OQKDpIfIGqM+3xv0TmFxUoIvhGob1o9hWdcPb NZpYXN+keLb+Ns5lZ7X6b7E7PvmnxsitA/M2oX5smYMEwWLysxOE92Va69vP918X cmInO/PuYm6543M+rGawJgM= Received: (qmail 30247 invoked by alias); 23 Nov 2014 09:27:25 -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 30225 invoked by uid 89); 23 Nov 2014 09:27:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx02.qsc.de Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Sun, 23 Nov 2014 09:27:21 +0000 Received: from tux.net-b.de (port-92-194-114-130.dynamic.qsc.de [92.194.114.130]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx02.qsc.de (Postfix) with ESMTPSA id 29C7D24D2C; Sun, 23 Nov 2014 10:27:15 +0100 (CET) Message-ID: <5471A873.40607@net-b.de> Date: Sun, 23 Nov 2014 10:27:15 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: gcc-patches , gfortran , =?UTF-8?B?TWFudWVsIEzDs3Blei1JYsOhw7Fleg==?= , gcc-patches Subject: [Patch, Fortran] -Wtabs cleanup This patch moves -Wtabs closer to the common diagnostics - and changed the odd reversed logic of flags = 0 meaning off. This brings nice common diagnostic features to fixed-form source code for the initial indentation [tab = 6 spaces] (which doesn't show a location), but not to free-form source code or in-line tabs (also in fixed-form) as that shows a location %C but gfc_current_location doesn't contain a valid localtion for the common diagnostics. For the fixed-form initial-tab diagnostic of -Wtabs, the colored output is not new, but it now also shows the "[-Wtabs]" or "[-Werror=tabs]" and handles the latter. Note: The Wpedantic (with alias -pedantic and --pedantic) had to be added as otherwise the LangEnabledBy for Wall (!) didn't work; as known, -(W)pedantic itself is not a new option. Note 2: As -pedantic enables -Wtabs, -pedantic-errors now also enabled -Werror=tabs. The testsuite seems to be run with -pedantic-errors, hence, I had to change a test case. Alternatively, one could either explicitly ("dg-options") or in the general test setup change "-pedantic-errors" to "-pedantic". Build and regtested on x86-64-gnu-linux. OK for the trunk? Tobias 2014-11-23 Tobias Burnus Manuel López-Ibáñez gcc/fortran/ * gfortran.h (gfc_option_t): Remove warn_tabs. * lang.opt (Wpedantic): Add. (Wtabs): Use Var and LangEnabledBy. * options.c (gfc_init_options, gfc_post_options, set_Wall): Remove -Wtabs handling. (gfc_handle_option): Update -std=, remove OPT_Wtabs. * scanner.c (gfc_gobble_whitespace): Update for flag-variable renaming. (load_line): Ditto. Pass warn flag to diagnostic. gcc/testsuite/ * gfortran.dg/tab_continuation.f: Update dg-*. diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index b0f15b4..1ee7dd4 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -2452,7 +2452,6 @@ typedef struct int warn_implicit_procedure; int warn_line_truncation; int warn_surprising; - int warn_tabs; int warn_underflow; int warn_intrinsic_shadow; int warn_intrinsics_std; diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt index d6fe603..5da0453 100644 --- a/gcc/fortran/lang.opt +++ b/gcc/fortran/lang.opt @@ -269,6 +269,10 @@ Wopenmp-simd Fortran ; Documented in C +Wpedantic +Fortran +; Documented in common.opt + Wreal-q-constant Fortran Warning Warn about real-literal-constants with 'q' exponent-letter @@ -294,9 +298,13 @@ Fortran Warning Warn about \"suspicious\" constructs Wtabs -Fortran Warning +Fortran Warning Var(warn_tabs) LangEnabledBy(Fortran,Wall) Permit nonconforming uses of the tab character +Wtabs +LangEnabledBy(Fortran,Wpedantic) +; + Wunderflow Fortran Warning Warn about underflow of numerical constant expressions diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c index bbbd6ab..dee1af4 100644 --- a/gcc/fortran/options.c +++ b/gcc/fortran/options.c @@ -104,7 +104,6 @@ gfc_init_options (unsigned int decoded_options_count, gfc_option.warn_implicit_interface = 0; gfc_option.warn_line_truncation = 0; gfc_option.warn_surprising = 0; - gfc_option.warn_tabs = 1; gfc_option.warn_underflow = 1; gfc_option.warn_intrinsic_shadow = 0; gfc_option.warn_intrinsics_std = 0; @@ -430,10 +429,7 @@ gfc_post_options (const char **pfilename) gfc_option.flag_max_stack_var_size = 0; if (pedantic) - { - gfc_option.warn_ampersand = 1; - gfc_option.warn_tabs = 0; - } + gfc_option.warn_ampersand = 1; /* Optimization implies front end optimization, unless the user specified it directly. */ @@ -461,7 +457,6 @@ set_Wall (int setting) gfc_option.gfc_warn_conversion = setting; gfc_option.warn_line_truncation = setting; gfc_option.warn_surprising = setting; - gfc_option.warn_tabs = !setting; gfc_option.warn_underflow = setting; gfc_option.warn_intrinsic_shadow = setting; gfc_option.warn_intrinsics_std = setting; @@ -720,10 +715,6 @@ gfc_handle_option (size_t scode, const char *arg, int value, gfc_option.warn_surprising = value; break; - case OPT_Wtabs: - gfc_option.warn_tabs = value; - break; - case OPT_Wtarget_lifetime: gfc_option.warn_target_lifetime = value; break; @@ -1038,7 +1029,7 @@ gfc_handle_option (size_t scode, const char *arg, int value, gfc_option.max_continue_free = 39; gfc_option.max_identifier_length = 31; gfc_option.warn_ampersand = 1; - gfc_option.warn_tabs = 0; + warn_tabs = 1; break; case OPT_std_f2003: @@ -1047,7 +1038,7 @@ gfc_handle_option (size_t scode, const char *arg, int value, gfc_option.warn_std = GFC_STD_F95_OBS; gfc_option.max_identifier_length = 63; gfc_option.warn_ampersand = 1; - gfc_option.warn_tabs = 0; + warn_tabs = 1; break; case OPT_std_f2008: @@ -1056,7 +1047,7 @@ gfc_handle_option (size_t scode, const char *arg, int value, gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS; gfc_option.max_identifier_length = 63; gfc_option.warn_ampersand = 1; - gfc_option.warn_tabs = 0; + warn_tabs = 1; break; case OPT_std_f2008ts: @@ -1066,7 +1057,7 @@ gfc_handle_option (size_t scode, const char *arg, int value, gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS; gfc_option.max_identifier_length = 63; gfc_option.warn_ampersand = 1; - gfc_option.warn_tabs = 0; + warn_tabs = 1; break; case OPT_std_gnu: diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index 2c0d4c3..e0b9a3b 100644 --- a/gcc/fortran/scanner.c +++ b/gcc/fortran/scanner.c @@ -1382,7 +1382,7 @@ gfc_gobble_whitespace (void) /* Issue a warning for nonconforming tabs. We keep track of the line number because the Fortran matchers will often back up and the same line will be scanned multiple times. */ - if (!gfc_option.warn_tabs && c == '\t') + if (warn_tabs && c == '\t') { int cur_linenum = LOCATION_LINE (gfc_current_locus.lb->location); if (cur_linenum != linenum) @@ -1534,12 +1534,12 @@ load_line (FILE *input, gfc_char_t **pbuf, int *pbuflen, const int *first_char) { found_tab = true; - if (!gfc_option.warn_tabs && seen_comment == 0 - && current_line != linenum) + if (warn_tabs && seen_comment == 0 && current_line != linenum) { linenum = current_line; - gfc_warning_now_2 ("Nonconforming tab character in column %d " - "of line %d", i+1, linenum); + gfc_warning_now_2 (OPT_Wtabs, + "Nonconforming tab character in column %d " + "of line %d", i+1, linenum); } while (i < 6) diff --git a/gcc/testsuite/gfortran.dg/tab_continuation.f b/gcc/testsuite/gfortran.dg/tab_continuation.f index 65cb7b4..85d2307 100644 --- a/gcc/testsuite/gfortran.dg/tab_continuation.f +++ b/gcc/testsuite/gfortran.dg/tab_continuation.f @@ -5,11 +5,16 @@ ! Allow 1 to 9 as continuation marker, which is a very common ! vendor extension. ! +! Note: The test suite is run with -pedantic-errors, which both enables +! the tab warning (-pedantic implies -Wtabs) and turns it into errors +! (-pedantic-errors hence implies -Werror=tabs). +! PARAMETER (LUMIN=11,LUMAX=20,MAPMAX=256,NPLANEMAX=999) INTEGER NAXIS(0:MAPMAX,LUMIN:LUMAX),NAXIS1(0:MAPMAX,LUMIN:LUMAX), 1NAXIS2(0:MAPMAX,LUMIN:LUMAX),NAXIS3(0:MAPMAX,LUMIN:LUMAX) end -! { dg-warning "Nonconforming tab character in column 1 of line 8" "Nonconforming tab" { target *-*-* } 0 } -! { dg-warning "Nonconforming tab character in column 1 of line 9" "Nonconforming tab" { target *-*-* } 0 } -! { dg-warning "Nonconforming tab character in column 1 of line 10" "Nonconforming tab" { target *-*-* } 0 } -! { dg-warning "Nonconforming tab character in column 1 of line 11" "Nonconforming tab" { target *-*-* } 0 } +! { dg-error "Nonconforming tab character in column 1 of line 12" "Nonconforming tab" { target *-*-* } 0 } +! { dg-error "Nonconforming tab character in column 1 of line 13" "Nonconforming tab" { target *-*-* } 0 } +! { dg-error "Nonconforming tab character in column 1 of line 14" "Nonconforming tab" { target *-*-* } 0 } +! { dg-error "Nonconforming tab character in column 1 of line 15" "Nonconforming tab" { target *-*-* } 0 } +! { dg-excess-errors "some warnings being treated as errors" }