From patchwork Mon Aug 20 15:27:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 959816 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-483989-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PJfr234E"; dkim-atps=neutral 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 41vHk75tNQz9s0n for ; Tue, 21 Aug 2018 01:27:42 +1000 (AEST) Received: (qmail 60238 invoked by alias); 20 Aug 2018 15:27:36 -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 60227 invoked by uid 89); 20 Aug 2018 15:27:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=annoying, Plus X-HELO: mail-yw1-f48.google.com Received: from mail-yw1-f48.google.com (HELO mail-yw1-f48.google.com) (209.85.161.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 20 Aug 2018 15:27:33 +0000 Received: by mail-yw1-f48.google.com with SMTP id x67-v6so1884471ywg.0 for ; Mon, 20 Aug 2018 08:27:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=742E+ETi6q4TzHozKoThHa1H320CgVUFG1buJizBm50=; b=PJfr234EoTSHBeLn3+7IGNKc71BF2+b/+ONKD5q39SOoZALBkzjWgtaRwB5qcGEoH6 tH+axNfPIZnq5fLSTWMoS2jvC511/CQN3Lk/FPvaoKRYxjN5Md8MVuJUFosrpdnDOuwv eOW/dQlN0kBT+IBxe+JRNUmUU6OPiAY77J7ygVu9Nhvsl25mgLsJSoLb6vyP9u6semch 4dyQMFw3YaQAxGGAiIo659ewKUhUQEPEWRA9pwzXgjE3rjGPUMVlydbpPHhA6al9R3/k lxwes1hxxeKIYMHDK2fdJv9OmNCCfYuG/XdcZg+b4mABNWKfcBsoh+C374QErlK0G4RP glGw== Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::5c29]) by smtp.googlemail.com with ESMTPSA id a79-v6sm4513225ywa.52.2018.08.20.08.27.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 08:27:31 -0700 (PDT) Sender: Nathan Sidwell To: GCC Patches , Bernhard Reutner-Fischer From: Nathan Sidwell Subject: [CPP PATCH] Fix warning & other cleanups. Message-ID: <8132c4c3-55ab-c497-ebc1-f6586293b2f7@acm.org> Date: Mon, 20 Aug 2018 11:27:29 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 I noticed I'd inadvertently allowed a trailing comma to creep in, leading to annoying warnings. I'd also missed a few uses of the cpp_macro_p function and friends. Plus Bernhard had suggested there's a name for 255 when it's encoding unsigned char range. Fixed thusly. nathan Index: directives.c =================================================================== --- directives.c (revision 263658) +++ directives.c (working copy) @@ -665,12 +665,12 @@ do_undef (cpp_reader *pfile) /* 6.10.3.5 paragraph 2: [#undef] is ignored if the specified identifier is not currently defined as a macro name. */ - if (node->type == NT_MACRO) + if (cpp_macro_p (node)) { if (node->flags & NODE_WARN) cpp_error (pfile, CPP_DL_WARNING, "undefining \"%s\"", NODE_NAME (node)); - else if ((node->flags & NODE_BUILTIN) + else if (cpp_builtin_macro_p (node) && CPP_OPTION (pfile, warn_builtin_macro_redefined)) cpp_warning_with_line (pfile, CPP_W_BUILTIN_MACRO_REDEFINED, pfile->directive_line, 0, Index: include/cpplib.h =================================================================== --- include/cpplib.h (revision 263658) +++ include/cpplib.h (working copy) @@ -674,7 +674,7 @@ struct cpp_dir enum cpp_macro_kind { cmk_macro, /* An ISO macro (token expansion). */ cmk_assert, /* An assertion. */ - cmk_traditional, /* A traditional macro (text expansion). */ + cmk_traditional /* A traditional macro (text expansion). */ }; /* Each macro definition is recorded in a cpp_macro structure. @@ -972,7 +972,10 @@ inline bool cpp_macro_p (const cpp_hashn return node->type == NT_MACRO; } /* Returns true if NODE is a function-like user macro. */ -extern bool cpp_fun_like_macro_p (cpp_hashnode *node); +inline bool cpp_fun_like_macro_p (cpp_hashnode *node) +{ + return cpp_user_macro_p (node) && node->value.macro->fun_like; +} extern const unsigned char *cpp_macro_definition (cpp_reader *, cpp_hashnode *); Index: macro.c =================================================================== --- macro.c (revision 263658) +++ macro.c (working copy) @@ -3551,7 +3551,7 @@ cpp_define_lazily (cpp_reader *pfile, cp { cpp_macro *macro = node->value.macro; - gcc_checking_assert (pfile->cb.user_lazy_macro && macro && num < 255); + gcc_checking_assert (pfile->cb.user_lazy_macro && macro && num < UCHAR_MAX); macro->lazy = num + 1; } @@ -3632,15 +3632,6 @@ check_trad_stringification (cpp_reader * } } -/* Returns true of NODE is a function-like macro. */ -bool -cpp_fun_like_macro_p (cpp_hashnode *node) -{ - return (node->type == NT_MACRO - && (node->flags & (NODE_BUILTIN | NODE_MACRO_ARG)) == 0 - && node->value.macro->fun_like); -} - /* Returns the name, arguments and expansion of a macro, in a format suitable to be read back in again, and therefore also for DWARF 2 debugging info. e.g. "PASTE(X, Y) X ## Y", or "MACNAME EXPANSION".