From patchwork Mon Aug 25 17:10:30 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: 382816 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 518AC1400B7 for ; Tue, 26 Aug 2014 03:11:05 +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=MloVEbqYGIe8RLqzrCbd9XezqpgOxGW8NNIrjBMeS4W09H cqOUqljYQAW9jsKdEr87blNbjV7vJr3zvRFOqZgSd1Ib7UkhlNCfZlfRn6oSK3Uh 0oTwsm+uTAQQjYvjcgVPddhpfU/MDxXCtipl+ZbgQ+jBIRjfFzD8VEaQwVahc= 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=9FdxeFDL3JdPKCIUqo0ycS/kVXk=; b=N5/GnvuRGoBDJm4b/5Ka QUZq/MHia5vbF5HwlaqpN+1EWZz5eJQVXIU17TU548gwRk8ks4mngw2/yaOrUhGM GWYiM5TBHmVhtEyjI7X3tddr0A7b6EWRWtbkaVFiK0SwO6ePNBeR7Iivzhz4zwkE 2T7f+dd/hYXYzPXGrrDHJYk= Received: (qmail 25982 invoked by alias); 25 Aug 2014 17:10:57 -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 25964 invoked by uid 89); 25 Aug 2014 17:10:56 -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-HELO: mail-wg0-f43.google.com Received: from mail-wg0-f43.google.com (HELO mail-wg0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 25 Aug 2014 17:10:54 +0000 Received: by mail-wg0-f43.google.com with SMTP id l18so13424949wgh.14 for ; Mon, 25 Aug 2014 10:10:51 -0700 (PDT) X-Received: by 10.180.77.83 with SMTP id q19mr6779241wiw.83.1408986651206; Mon, 25 Aug 2014 10:10:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.217.80.73 with HTTP; Mon, 25 Aug 2014 10:10:30 -0700 (PDT) From: =?ISO-8859-1?Q?Manuel_L=F3pez=2DIb=E1=F1ez?= Date: Mon, 25 Aug 2014 19:10:30 +0200 Message-ID: Subject: [PATCH libcpp] Use CPP() for Wendif-labels and other flags To: Gcc Patch List , "Joseph S. Myers" X-IsSubscribed: yes This patch is on top of https://gcc.gnu.org/ml/gcc-patches/2014-08/msg02244.html The main issue here is Wendif-labels, since we were not using the correct CPP_W_* flag. The rest are straight-forward. libcpp/ChangeLog: 2014-08-25 Manuel López-Ibáñez * directives.c (check_eol_1): New. (check_eol_endif_labels): New. (check_eol): Call check_eol_1. (do_else,do_endif): Call check_eol_endif_labels. gcc/c-family/ChangeLog: 2014-08-25 Manuel López-Ibáñez * c.opt (Wbuiltin-macro-redefined,Wdeprecated,Wendif-labels, Winvalid-pch,Wliteral-suffix,Wmissing-include-dirs,Wtrigraphs, Wundef): Use CPP, Var and Init. * c-opts.c (c_common_handle_option): Do not handle the above flags here. diff -u gcc/c-family/c.opt gcc/c-family/c.opt --- gcc/c-family/c.opt (working copy) +++ gcc/c-family/c.opt (working copy) @@ -292,7 +292,7 @@ Warn about boolean expression compared with an integer value different from true/false Wbuiltin-macro-redefined -C ObjC C++ ObjC++ CPP(warn_builtin_macro_redefined) Var(cpp_warn_builtin_macro_redefined) Warning +C ObjC C++ ObjC++ CPP(warn_builtin_macro_redefined) Var(cpp_warn_builtin_macro_redefined) Init(1) Warning Warn when a built-in preprocessor macro is undefined or redefined Wc90-c99-compat @@ -368,7 +368,7 @@ ; Wdeprecated -C C++ ObjC ObjC++ Var(warn_deprecated) Init(1) Warning +C C++ ObjC ObjC++ CPP(cpp_warn_deprecated) Var(warn_deprecated) Init(1) Warning Warn if a deprecated compiler feature, class, method, or field is used Wdesignated-init @@ -392,7 +392,7 @@ Warn about an empty body in an if or else statement Wendif-labels -C ObjC C++ ObjC++ Warning +C ObjC C++ ObjC++ CPP(warn_endif_labels) Var(cpp_warn_endif_labels) Init(1) Warning Warn about stray tokens after #elif and #endif Wenum-compare @@ -503,7 +503,7 @@ Warn about invalid uses of the \"offsetof\" macro Winvalid-pch -C ObjC C++ ObjC++ Warning +C ObjC C++ ObjC++ CPP(warn_invalid_pch) Var(cpp_warn_invalid_pch) Warning Warn about PCH files that are found but not used Wjump-misses-init @@ -511,7 +511,7 @@ Warn when a jump misses a variable initialization Wliteral-suffix -C++ ObjC++ Warning +C++ ObjC++ CPP(warn_literal_suffix) Var(cpp_warn_literal_suffix) Init(1) Warning Warn when a string or character literal is followed by a ud-suffix which does not begin with an underscore. Wlogical-op @@ -583,7 +583,7 @@ ; Wmissing-include-dirs -C ObjC C++ ObjC++ Warning +C ObjC C++ ObjC++ CPP(warn_missing_include_dirs) Var(cpp_warn_missing_include_dirs) Warning Warn about user-specified include directories that do not exist Wmissing-parameter-type @@ -794,7 +794,7 @@ Warn of prototypes causing type conversions different from what would happen in the absence of prototype Wtrigraphs -C ObjC C++ ObjC++ Warning +C ObjC C++ ObjC++ CPP(warn_trigraphs) Var(cpp_warn_trigraphs) Init(2) Warning Warn if trigraphs are encountered that might affect the meaning of the program Wundeclared-selector @@ -802,7 +802,7 @@ Warn about @selector()s without previously declared methods Wundef -C ObjC C++ ObjC++ Warning +C ObjC C++ ObjC++ CPP(warn_undef) Var(cpp_warn_undef) Warning Warn if an undefined macro is used in an #if directive Wuninitialized diff -u gcc/c-family/c-opts.c gcc/c-family/c-opts.c --- gcc/c-family/c-opts.c (working copy) +++ gcc/c-family/c-opts.c (working copy) @@ -389,29 +389,10 @@ cpp_opts->warn_cxx_operator_names = value; break; - case OPT_Wdeprecated: - cpp_opts->cpp_warn_deprecated = value; - break; - - case OPT_Wendif_labels: - cpp_opts->warn_endif_labels = value; - break; - - case OPT_Winvalid_pch: - cpp_opts->warn_invalid_pch = value; - break; - - case OPT_Wliteral_suffix: - cpp_opts->warn_literal_suffix = value; - break; - case OPT_Wlong_long: cpp_opts->cpp_warn_long_long = value; break; - case OPT_Wmissing_include_dirs: - cpp_opts->warn_missing_include_dirs = value; - break; case OPT_Wnormalized_: /* FIXME: Move all this to c.opt. */ if (kind == DK_ERROR) @@ -439,14 +420,6 @@ cpp_opts->cpp_warn_traditional = value; break; - case OPT_Wtrigraphs: - cpp_opts->warn_trigraphs = value; - break; - - case OPT_Wundef: - cpp_opts->warn_undef = value; - break; - case OPT_Wunknown_pragmas: /* Set to greater than 1, so that even unknown pragmas in system headers will be warned about. */ diff -u libcpp/directives.c libcpp/directives.c --- libcpp/directives.c (working copy) +++ libcpp/directives.c (working copy) @@ -213,16 +213,33 @@ ; } -/* Ensure there are no stray tokens at the end of a directive. If - EXPAND is true, tokens macro-expanding to nothing are allowed. */ +/* Helper function for check_oel. */ + static void -check_eol (cpp_reader *pfile, bool expand) +check_eol_1 (cpp_reader *pfile, bool expand, int reason) { if (! SEEN_EOL () && (expand ? cpp_get_token (pfile) : _cpp_lex_token (pfile))->type != CPP_EOF) - cpp_error (pfile, CPP_DL_PEDWARN, "extra tokens at end of #%s directive", - pfile->directive->name); + cpp_pedwarning (pfile, reason, "extra tokens at end of #%s directive", + pfile->directive->name); +} + +/* Variant of check_eol used for Wendif-labels warnings. */ + +static void +check_eol_endif_labels (cpp_reader *pfile) +{ + check_eol_1 (pfile, false, CPP_W_ENDIF_LABELS); +} + +/* Ensure there are no stray tokens at the end of a directive. If + EXPAND is true, tokens macro-expanding to nothing are allowed. */ + +static void +check_eol (cpp_reader *pfile, bool expand) +{ + check_eol_1 (pfile, expand, CPP_W_NONE); } /* Ensure there are no stray tokens other than comments at the end of @@ -1990,7 +2007,7 @@ /* Only check EOL if was not originally skipping. */ if (!ifs->was_skipping && CPP_OPTION (pfile, warn_endif_labels)) - check_eol (pfile, false); + check_eol_endif_labels (pfile); } } @@ -2051,7 +2068,7 @@ { /* Only check EOL if was not originally skipping. */ if (!ifs->was_skipping && CPP_OPTION (pfile, warn_endif_labels)) - check_eol (pfile, false); + check_eol_endif_labels (pfile); /* If potential control macro, we go back outside again. */ if (ifs->next == 0 && ifs->mi_cmacro)