From patchwork Tue Aug 21 10:20:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 960188 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-484072-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ZpqhqH+H"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="Zzdb0cG8"; 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 41vmsD5qYbz9s4Z for ; Tue, 21 Aug 2018 20:20:31 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=UQ5FUckHEV5cU6r+yA0RHtLGA3uuYT+ode9rXc9w7vmkOSoosZ +66sVI8yl+B+l2fs6AmN10ln+Og+X35HByCKkY/CRsjRrrYl8GMxXSJ5nbcBTJ/U lR20ak7ouH11nzg/3zyySorgXPFHmNxfpd+9EwJoEm2be9Y0fk/UrcpIg= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=AER/jccVVuY1UHnwvOLsZAeKya0=; b=ZpqhqH+Hs/RFWsXjR8xy qbjkoy2uOO5Tj308jNM5M1KGPMNs+wFO4VW3sK84AbMg6/OG0n5T6x+r3kllYhN/ j5wfEOo76VJXac97IsWRsEYAH+kAjZCGQuspusIx13+hZ0+qDapuO9smWrV3tS8G JQKYagYLlA//8OGs1Ws3yj4= Received: (qmail 101022 invoked by alias); 21 Aug 2018 10:20:24 -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 100994 invoked by uid 89); 21 Aug 2018 10:20:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=san, San, H*RU:192.168.1.4, H*r:ip*192.168.1.4 X-HELO: userp2130.oracle.com Received: from userp2130.oracle.com (HELO userp2130.oracle.com) (156.151.31.86) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 Aug 2018 10:20:21 +0000 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7LAJ8Um036433; Tue, 21 Aug 2018 10:20:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : cc : from : subject : message-id : date : mime-version : content-type; s=corp-2018-07-02; bh=pb5OL2VhdXzS13eia01GIMqNDnicZJFV/bo66Z5NS4Y=; b=Zzdb0cG8AFcxUJ7API+Ssu70DCDTc33vUYWyeIOA+8Wm9X55x/vyi8Rzsczk2soN9E9d BSiDCjXMAKsRImz6/lkOftrNtR8gceZQTVtBC5SUJVidheYAB6/2uK33twUi6N42vbeu tQeQ1WrKO/fBEvz7Jh5ifqXN1DAVqRkD+sKvoAvoyDbnYGgztL1ZOR3S+VC6FcSYPBn1 fFIxJDQcteBP6Q4BLp3ZkKV4oYCHwSKU2Z/IeCF3h1SP2op7Qgqj12B9WUmesWtEkJju m+PulbzKnV4nl8WGgBs+CdSKeczORj8Xvqnc21LDDCbMA2q3wgWQDkU4YJe1kLacMpLY /g== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2kxavtkjn1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Aug 2018 10:20:17 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w7LAKG6q028611 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Aug 2018 10:20:16 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w7LAKFRd027134; Tue, 21 Aug 2018 10:20:15 GMT Received: from [192.168.1.4] (/79.41.56.79) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 21 Aug 2018 03:20:14 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill , Nathan Sidwell From: Paolo Carlini Subject: [C++ Patch, obvious?] Change check_static_variable_definition return type to void Message-ID: Date: Tue, 21 Aug 2018 12:20:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi, over the last couple of weeks I started auditing the front-end about problematic uses of permerror (say, the user passes -fpermissive and after the warning we immediately return error_mark_node anyway: the assembly most likely will not make sense) and noticed that we don't use anywhere the return value of check_static_variable_definition (luckily, because we are returning 1 both for error and permerror), thus the below, which just changes the return type to void and consistently adjusts the body. I mean to commit it as obvious after testing finishes... Thanks, Paolo. //////////////////////////// 2018-08-21 Paolo Carlini * decl.c (check_static_variable_definition): Change to return void. Index: decl.c =================================================================== --- decl.c (revision 263695) +++ decl.c (working copy) @@ -70,7 +70,7 @@ static void push_local_name (tree); static tree grok_reference_init (tree, tree, tree, int); static tree grokvardecl (tree, tree, tree, const cp_decl_specifier_seq *, int, int, int, bool, int, tree); -static int check_static_variable_definition (tree, tree); +static void check_static_variable_definition (tree, tree); static void record_unknown_type (tree, const char *); static tree builtin_function_1 (tree, tree, bool); static int member_function_or_else (tree, tree, enum overload_flags); @@ -9531,25 +9531,24 @@ build_ptrmem_type (tree class_type, tree member_ty /* DECL is a VAR_DECL defined in-class, whose TYPE is also given. Check to see that the definition is valid. Issue appropriate error - messages. Return 1 if the definition is particularly bad, or 0 - otherwise. */ + messages. */ -static int +static void check_static_variable_definition (tree decl, tree type) { /* Avoid redundant diagnostics on out-of-class definitions. */ if (!current_class_type || !TYPE_BEING_DEFINED (current_class_type)) - return 0; + ; /* Can't check yet if we don't know the type. */ - if (dependent_type_p (type)) - return 0; + else if (dependent_type_p (type)) + ; /* If DECL is declared constexpr, we'll do the appropriate checks in check_initializer. Similarly for inline static data members. */ - if (DECL_P (decl) + else if (DECL_P (decl) && (DECL_DECLARED_CONSTEXPR_P (decl) || undeduced_auto_decl (decl) || DECL_VAR_DECLARED_INLINE_P (decl))) - return 0; + ; else if (cxx_dialect >= cxx11 && !INTEGRAL_OR_ENUMERATION_TYPE_P (type)) { if (!COMPLETE_TYPE_P (type)) @@ -9564,9 +9563,7 @@ check_static_variable_definition (tree decl, tree error_at (DECL_SOURCE_LOCATION (decl), "in-class initialization of static data member %q#D of " "non-literal type", decl); - return 1; } - /* Motion 10 at San Diego: If a static const integral data member is initialized with an integral constant expression, the initializer may appear either in the declaration (within the class), or in @@ -9573,14 +9570,11 @@ check_static_variable_definition (tree decl, tree the definition, but not both. If it appears in the class, the member is a member constant. The file-scope definition is always required. */ - if (!ARITHMETIC_TYPE_P (type) && TREE_CODE (type) != ENUMERAL_TYPE) - { - error_at (DECL_SOURCE_LOCATION (decl), - "invalid in-class initialization of static data member " - "of non-integral type %qT", - type); - return 1; - } + else if (!ARITHMETIC_TYPE_P (type) && TREE_CODE (type) != ENUMERAL_TYPE) + error_at (DECL_SOURCE_LOCATION (decl), + "invalid in-class initialization of static data member " + "of non-integral type %qT", + type); else if (!CP_TYPE_CONST_P (type)) error_at (DECL_SOURCE_LOCATION (decl), "ISO C++ forbids in-class initialization of non-const " @@ -9590,8 +9584,6 @@ check_static_variable_definition (tree decl, tree pedwarn (DECL_SOURCE_LOCATION (decl), OPT_Wpedantic, "ISO C++ forbids initialization of member constant " "%qD of non-integral type %qT", decl, type); - - return 0; } /* *expr_p is part of the TYPE_SIZE of a variably-sized array. If any