From patchwork Wed Aug 29 16:09:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 963560 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-484712-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="rk5ISXM8"; 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 420rF42qffz9ryt for ; Thu, 30 Aug 2018 02:10:16 +1000 (AEST) Received: (qmail 89460 invoked by alias); 29 Aug 2018 16:10:10 -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 89439 invoked by uid 89); 29 Aug 2018 16:10:09 -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= X-HELO: mail-yw1-f44.google.com Received: from mail-yw1-f44.google.com (HELO mail-yw1-f44.google.com) (209.85.161.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 Aug 2018 16:10:02 +0000 Received: by mail-yw1-f44.google.com with SMTP id w202-v6so2214392yww.3 for ; Wed, 29 Aug 2018 09:10:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:cc:from:subject:message-id:date:user-agent:mime-version :content-language; bh=cS1tqM0yyl2WsQY7b91KNqP/z8RLFFZcm3Ie1wjHtJM=; b=rk5ISXM8dkPEYoP76/On8B5G1AoaORfC0EVap/7ET3x7SyfQ9SRVixgYsWb0wCiHKt X7rdzi0MaT//vtcafMo7omf+qmFzcGKYpuwFGBAsdezVmb9hm8OeEFbu+a/NY9At0c3c qXg7RbhYXXAqDsaSE1PXQkHvHjKzGOBAVc3J7PPKd8A/BbWCw29Zcky7sqWhYHfQenLr X7gQNt+w7i7afRycSueehypK84JhpWnc7uTdkXpO+GPcZSoTcTRfmZmJDttNjMgb++Vg iR5oejW7vvq+y+09HT6IflpBbGv+G3Q+MTIkCm+OdXkMzfd2ykgxGATMfehxPcat6r5n JBFg== Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::3:c6f]) by smtp.googlemail.com with ESMTPSA id z125-v6sm4946494ywg.57.2018.08.29.09.10.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Aug 2018 09:10:00 -0700 (PDT) Sender: Nathan Sidwell To: GCC Patches Cc: Jason Merrill , David Edelsohn From: Nathan Sidwell Subject: [C++ PATCH] Remove K&R declaration hack. Message-ID: <7e358ddd-707a-8e56-b6f1-2b8cefecec7f@acm.org> Date: Wed, 29 Aug 2018 12:09:59 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 When SYSTEM_IMPLICIT_EXTERN_C is in effect, we have a couple of hacks to allow unprototyped declarations. 1) in decls_match we look at the promoted return types 2) in decls_match and in the parser we allow '()' to mean '(...)'. This is of course horrible, #2 will fail badly on modern ABIs. #1 may well break sign extension behaviour of smaller-than-int return types. As it happens the only remaining SIEC target is AIX, and its system header files are sufficiently prototyped (including 'int open (const char *, int, ...)'). I've bootstrapped this patch on powerpc8-aix with no change in test results. (Thanks David on helping with that.) IMHO we don't need to warn about this going way first. If it did affect a target it'd be very noisy. I'll commit in a few days, unless there are objections. nathan 2018-08-29 Nathan Sidwell gcc/ * doc/extend.texi (Backwards Compatibility): Remove implicit extern C leeway of () being (...). gcc/cp/ * decl.c (decls_match): Remove SYSTEM_IMPLICIT_EXTERN_C matching of return types and parms. * parser.c (cp_parser_parameter_declaration_clause): Likewise, '()' always means '(void)'. Index: gcc/cp/decl.c =================================================================== --- gcc/cp/decl.c (revision 263897) +++ gcc/cp/decl.c (working copy) @@ -968,30 +968,12 @@ decls_match (tree newdecl, tree olddecl, if (same_type_p (TREE_TYPE (f1), r2)) { if (!prototype_p (f2) && DECL_EXTERN_C_P (olddecl) - && (fndecl_built_in_p (olddecl) -#ifdef SYSTEM_IMPLICIT_EXTERN_C - || (DECL_IN_SYSTEM_HEADER (newdecl) && !DECL_CLASS_SCOPE_P (newdecl)) - || (DECL_IN_SYSTEM_HEADER (olddecl) && !DECL_CLASS_SCOPE_P (olddecl)) -#endif - )) + && fndecl_built_in_p (olddecl)) { types_match = self_promoting_args_p (p1); if (p1 == void_list_node) TREE_TYPE (newdecl) = TREE_TYPE (olddecl); } -#ifdef SYSTEM_IMPLICIT_EXTERN_C - else if (!prototype_p (f1) - && (DECL_EXTERN_C_P (olddecl) - && DECL_IN_SYSTEM_HEADER (olddecl) - && !DECL_CLASS_SCOPE_P (olddecl)) - && (DECL_EXTERN_C_P (newdecl) - && DECL_IN_SYSTEM_HEADER (newdecl) - && !DECL_CLASS_SCOPE_P (newdecl))) - { - types_match = self_promoting_args_p (p2); - TREE_TYPE (newdecl) = TREE_TYPE (olddecl); - } -#endif else types_match = compparms (p1, p2) Index: gcc/cp/parser.c =================================================================== --- gcc/cp/parser.c (revision 263897) +++ gcc/cp/parser.c (working copy) @@ -21372,16 +21372,7 @@ cp_parser_parameter_declaration_clause ( } else if (token->type == CPP_CLOSE_PAREN) /* There are no parameters. */ - { -#ifdef SYSTEM_IMPLICIT_EXTERN_C - if (in_system_header_at (input_location) - && current_class_type == NULL - && current_lang_name == lang_name_c) - return NULL_TREE; - else -#endif - return void_list_node; - } + return void_list_node; /* Check for `(void)', too, which is a special case. */ else if (token->keyword == RID_VOID && (cp_lexer_peek_nth_token (parser->lexer, 2)->type Index: gcc/doc/extend.texi =================================================================== --- gcc/doc/extend.texi (revision 263897) +++ gcc/doc/extend.texi (working copy) @@ -23685,9 +23685,9 @@ deprecated. @xref{Deprecated Features} @item Implicit C language Old C system header files did not contain an @code{extern "C" @{@dots{}@}} scope to set the language. On such systems, all system header files are -implicitly scoped inside a C language scope. Also, an empty prototype -@code{()} is treated as an unspecified number of arguments, rather -than no arguments, as C++ demands. +implicitly scoped inside a C language scope. Such headers must +correctly prototype function argument types, there is no leeway for +@code{()} to indicate an unspecified set of arguments. @end table