From patchwork Fri Oct 11 21:48:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1175589 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-510814-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="FwFD9S4w"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="ShPgO9zn"; 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 46qhRS0XKqz9sNx for ; Sat, 12 Oct 2019 08:48:50 +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:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=EEPHjzbDYC64mcKOQuVlT0r/gMWP7ca5FC+CuQ+C9LXT4c6x9b dcBK6Iigjoy+FQuGwjEyuc44FxRcFrkoUHgKXDXXAkZgguuFWTFVx0D2Ntk3j4ly WE7bNdBCp43y01Gx5J9cd9grU7UG9zL9vzSyUTv9zCHmbNKOAezGxFdzE= 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=t6hsr0RtGyCpXAvrWWNbpYSvUQc=; b=FwFD9S4wC85oAev350at 3qUaP5f4RGeUpDfKWlY1RdqM6L4ErhGO3zIBNq3XSkJJZCgoaObRFDokBXAcauiB jPUpQnIf6H8F5x7ds2DO0A7m9/TDGXPwSAZkBAxUdn1CH1ijkT7elaLi5YIaEsAC Gl0+7QaGH1ei+gDp11Q4biA= Received: (qmail 128084 invoked by alias); 11 Oct 2019 21:48:43 -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 128076 invoked by uid 89); 11 Oct 2019 21:48:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=sk:maybe_w, 1998 X-HELO: aserp2120.oracle.com Received: from aserp2120.oracle.com (HELO aserp2120.oracle.com) (141.146.126.78) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 11 Oct 2019 21:48:40 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9BLmcf0173781; Fri, 11 Oct 2019 21:48:38 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-2019-08-05; bh=bx6MmvPTw62GCg43vDeDfYixj1MGeZhYLZd7u4WdiXY=; b=ShPgO9zn3QlBlzXCLHZx6MqpD5AGnxCFijUoBAlp7Cs12pEOaFA5kBbrYcFw9bGI+RLC a1VfBup63mc9n3QfwGk/xQcBmA8fIifUZ9deZ6dZ50nS9Q2GHjWimQP8QAVd3MGHIfFx vG5fKEt4ZBrT1ghfgZ/z6krHweN912X8RAzFwJEHs/bdNtNr+TcL+ZO/4NVTYb5rCgtq TP5tEWgnk6rLCSwMOeR5bmEX4Ydca7pojYmrbNBQSHX1WTqu3mALKOJXiS5Gf/Tg0xE4 O+wE/9+uFG2ik+7lqePXChjBkF/VKWkaAhrwX2rGow8FOvPLwgkQ5G0TBEER8/mTrdHj Ag== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2vek4r467n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Oct 2019 21:48:38 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9BLmW5s054661; Fri, 11 Oct 2019 21:48:34 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2vjryd5bpk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Oct 2019 21:48:33 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x9BLmVa8024337; Fri, 11 Oct 2019 21:48:31 GMT Received: from [192.168.1.4] (/79.18.213.139) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 11 Oct 2019 14:48:30 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] Remove most uses of in_system_header_at Message-ID: <23d0f763-658b-31e5-6ca0-4411c6285610@oracle.com> Date: Fri, 11 Oct 2019 23:48:27 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi, as promised, this removes most uses of the predicate. I left alone the two occurrences in decl.c which guard permerrors, not warnings, and two more in parser.c which should be a (minor) optimization (particularly that in cp_parser_cast_expression). Tested x86_64-linux. Thanks, Paolo. /////////////////////// 2019-10-11 Paolo Carlini * decl.c (grokfndecl): Remove redundant use of in_system_header_at. (compute_array_index_type_loc): Likewise. (grokdeclarator): Likewise. * error.c (cp_printer): Likewise. * lambda.c (add_default_capture): Likewise. * parser.c (cp_parser_primary_expression): Likewise. (cp_parser_selection_statement): Likewise. (cp_parser_toplevel_declaration): Likewise. (cp_parser_enumerator_list): Likewise. (cp_parser_using_declaration): Likewise. (cp_parser_member_declaration): Likewise. (cp_parser_exception_specification_opt): Likewise. (cp_parser_std_attribute_spec): Likewise. * pt.c (do_decl_instantiation): Likewise. (do_type_instantiation): Likewise. * typeck.c (cp_build_unary_op): Likewise. Index: decl.c =================================================================== --- decl.c (revision 276903) +++ decl.c (working copy) @@ -9328,7 +9328,6 @@ grokfndecl (tree ctype, } /* 17.6.3.3.5 */ if (suffix[0] != '_' - && !in_system_header_at (location) && !current_function_decl && !(friendp && !funcdef_flag)) warning_at (location, OPT_Wliteral_suffix, "literal operator suffixes not preceded by %<_%>" @@ -10036,8 +10035,6 @@ compute_array_index_type_loc (location_t name_loc, indicated by the state of complain), so that another substitution can be found. */ return error_mark_node; - else if (in_system_header_at (input_location)) - /* Allow them in system headers because glibc uses them. */; else if (name) pedwarn (loc, OPT_Wpedantic, "ISO C++ forbids zero-size array %qD", name); @@ -11037,7 +11034,7 @@ grokdeclarator (const cp_declarator *declarator, } /* Don't pedwarn if the alternate "__intN__" form has been used instead of "__intN". */ - else if (!int_n_alt && pedantic && ! in_system_header_at (input_location)) + else if (!int_n_alt && pedantic) pedwarn (declspecs->locations[ds_type_spec], OPT_Wpedantic, "ISO C++ does not support %<__int%d%> for %qs", int_n_data[declspecs->int_n_idx].bitsize, name); @@ -12695,10 +12692,7 @@ grokdeclarator (const cp_declarator *declarator, else { /* Array is a flexible member. */ - if (in_system_header_at (input_location)) - /* Do not warn on flexible array members in system - headers because glibc uses them. */; - else if (name) + if (name) pedwarn (id_loc, OPT_Wpedantic, "ISO C++ forbids flexible array member %qs", name); else Index: error.c =================================================================== --- error.c (revision 276903) +++ error.c (working copy) @@ -4317,10 +4317,7 @@ cp_printer (pretty_printer *pp, text_info *text, c void maybe_warn_cpp0x (cpp0x_warn_str str) { - if ((cxx_dialect == cxx98) && !in_system_header_at (input_location)) - /* We really want to suppress this warning in system headers, - because libstdc++ uses variadic templates even when we aren't - in C++0x mode. */ + if (cxx_dialect == cxx98) switch (str) { case CPP0X_INITIALIZER_LISTS: Index: lambda.c =================================================================== --- lambda.c (revision 276903) +++ lambda.c (working copy) @@ -697,8 +697,7 @@ add_default_capture (tree lambda_stack, tree id, t /* Warn about deprecated implicit capture of this via [=]. */ if (cxx_dialect >= cxx2a && this_capture_p - && LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda) == CPLD_COPY - && !in_system_header_at (LAMBDA_EXPR_LOCATION (lambda))) + && LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda) == CPLD_COPY) { if (warning_at (LAMBDA_EXPR_LOCATION (lambda), OPT_Wdeprecated, "implicit capture of %qE via %<[=]%> is deprecated " Index: parser.c =================================================================== --- parser.c (revision 276903) +++ parser.c (working copy) @@ -5364,8 +5364,7 @@ cp_parser_primary_expression (cp_parser *parser, { expr = cp_parser_fold_expression (parser, expr); if (expr != error_mark_node - && cxx_dialect < cxx17 - && !in_system_header_at (input_location)) + && cxx_dialect < cxx17) pedwarn (input_location, 0, "fold-expressions only available " "with %<-std=c++17%> or %<-std=gnu++17%>"); } @@ -11817,7 +11816,7 @@ cp_parser_selection_statement (cp_parser* parser, { cx = true; cp_token *tok = cp_lexer_consume_token (parser->lexer); - if (cxx_dialect < cxx17 && !in_system_header_at (tok->location)) + if (cxx_dialect < cxx17) pedwarn (tok->location, 0, "% only available " "with %<-std=c++17%> or %<-std=gnu++17%>"); } @@ -13314,8 +13313,7 @@ cp_parser_toplevel_declaration (cp_parser* parser) /* A declaration consisting of a single semicolon is invalid. Allow it unless we're being pedantic. */ cp_lexer_consume_token (parser->lexer); - if (!in_system_header_at (input_location)) - pedwarn (input_location, OPT_Wpedantic, "extra %<;%>"); + pedwarn (input_location, OPT_Wpedantic, "extra %<;%>"); } else /* Parse the declaration itself. */ @@ -19193,7 +19191,7 @@ cp_parser_enumerator_list (cp_parser* parser, tree /* If the next token is a `}', there is a trailing comma. */ if (cp_lexer_next_token_is (parser->lexer, CPP_CLOSE_BRACE)) { - if (cxx_dialect < cxx11 && !in_system_header_at (input_location)) + if (cxx_dialect < cxx11) pedwarn (input_location, OPT_Wpedantic, "comma at end of enumerator list"); break; @@ -19655,8 +19653,7 @@ cp_parser_using_declaration (cp_parser* parser, else if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS)) { cp_token *ell = cp_lexer_consume_token (parser->lexer); - if (cxx_dialect < cxx17 - && !in_system_header_at (ell->location)) + if (cxx_dialect < cxx17) pedwarn (ell->location, 0, "pack expansion in using-declaration only available " "with %<-std=c++17%> or %<-std=gnu++17%>"); @@ -24835,7 +24832,6 @@ cp_parser_member_declaration (cp_parser* parser) location_t loc = cp_lexer_peek_token (parser->lexer)->location; if (cxx_dialect < cxx2a - && !in_system_header_at (loc) && identifier != NULL_TREE) pedwarn (loc, 0, "default member initializers for bit-fields " @@ -25692,7 +25688,7 @@ cp_parser_exception_specification_opt (cp_parser* "specifications"); type_id_list = NULL_TREE; } - else if (cxx_dialect >= cxx11 && !in_system_header_at (loc)) + else if (cxx_dialect >= cxx11) warning_at (loc, OPT_Wdeprecated, "dynamic exception specifications are deprecated in " "C++11"); @@ -26680,8 +26676,7 @@ cp_parser_std_attribute_spec (cp_parser *parser) if (attr_ns && cp_lexer_nth_token_is (parser->lexer, 3, CPP_COLON)) { - if (cxx_dialect < cxx17 - && !in_system_header_at (input_location)) + if (cxx_dialect < cxx17) pedwarn (input_location, 0, "attribute using prefix only available " "with %<-std=c++17%> or %<-std=gnu++17%>"); Index: pt.c =================================================================== --- pt.c (revision 276903) +++ pt.c (working copy) @@ -24257,7 +24257,7 @@ do_decl_instantiation (tree decl, tree storage) ; else if (storage == ridpointers[(int) RID_EXTERN]) { - if (!in_system_header_at (input_location) && (cxx_dialect == cxx98)) + if (cxx_dialect == cxx98) pedwarn (input_location, OPT_Wpedantic, "ISO C++ 1998 forbids the use of % on explicit " "instantiations"); @@ -24339,20 +24339,17 @@ do_type_instantiation (tree t, tree storage, tsubs if (storage != NULL_TREE) { - if (!in_system_header_at (input_location)) + if (storage == ridpointers[(int) RID_EXTERN]) { - if (storage == ridpointers[(int) RID_EXTERN]) - { - if (cxx_dialect == cxx98) - pedwarn (input_location, OPT_Wpedantic, - "ISO C++ 1998 forbids the use of % on " - "explicit instantiations"); - } - else + if (cxx_dialect == cxx98) pedwarn (input_location, OPT_Wpedantic, - "ISO C++ forbids the use of %qE" - " on explicit instantiations", storage); + "ISO C++ 1998 forbids the use of % on " + "explicit instantiations"); } + else + pedwarn (input_location, OPT_Wpedantic, + "ISO C++ forbids the use of %qE" + " on explicit instantiations", storage); if (storage == ridpointers[(int) RID_INLINE]) nomem_p = 1; Index: typeck.c =================================================================== --- typeck.c (revision 276903) +++ typeck.c (working copy) @@ -6533,7 +6533,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, return error_mark_node; } /* Otherwise, [depr.incr.bool] says this is deprecated. */ - else if (!in_system_header_at (input_location)) + else warning (OPT_Wdeprecated, "use of an operand of type %qT " "in % is deprecated", boolean_type_node);