From patchwork Mon Nov 20 09:55:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 167015 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp2089798vqn; Mon, 20 Nov 2023 01:56:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IEh4uEw8esiwVhFgfgCLn86uueIWt4VjgTEwhio/d7Z+KDZXKyBb1psvwm6C036O5E47YDW X-Received: by 2002:a05:6102:15a3:b0:460:621c:d14b with SMTP id g35-20020a05610215a300b00460621cd14bmr7078645vsv.20.1700474197108; Mon, 20 Nov 2023 01:56:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700474197; cv=pass; d=google.com; s=arc-20160816; b=JPRJyA60WZSkDl9Fk923vXe/GhU1K2S5aJE5xpEk5Lk6KxZ3RNYRjMZ6E1kullKuB6 c0KuA4OsDel3Y1gDL558jlxztLPyL7v3bZM6M8DGbbRPlMGQnoq/icbNzFGgjcp66Hqc nWB/P+A+cg8VEWKt0DzNZeop9SCbKgh6ymnsGoLs1v9m6jpCHFXi+ucADqi6DgBvHRWx ht89+VAG1ubCBdm2YfZqmN3xGGd7/w87vaXgkhDBIpdhTCd5j/D6e2NdBVbOfJhbhCxZ 46MpR8gZQyI/KMQdn0vrBDeChAVMfPfaP0dh+DiTjXy76jtZZhVRtIyWdecnGg89x0qW fTbQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent:date :references:message-id:in-reply-to:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=2B22qaPIT+Hgh50VaypES9aT7OWFYFqmMbHT/SSJ5S0=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=WSRl3su8l4CAJoP93ZIPe3pLFm2BGKDOzo2biuqrjVqZIdjfIC1qEHciPkUOarmtkM UDC30+Yi8AG1ITv0GN56vCEqHC6oGUVHbfd/7iw8/8u7GGV7xhhwTaEzKHxz/fo0cYDP 6E1z+ZZH1Be7FS/AU7F5FXN/GdcN7k0DhLcdWXn8277nsbMXh8riqM9T7Rv+gHqoFAXW C2B0DPVCFhT3p1INNgKOTMS5mbQRnSWLRr/V0Sp87R+gAyUjd7lvRFpuV4nM//WIOO2M 1PSDQKjQ199QGTZLQy/qggM8QFPBKAEUfBPrwzYxvqHtlrK2YUIe5Xf2WUPBIOj6x5fk B89Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="WxN/dWDn"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ay11-20020a05620a178b00b0076d990f8864si7587633qkb.259.2023.11.20.01.56.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 01:56:37 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="WxN/dWDn"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8A05A3882ACE for ; Mon, 20 Nov 2023 09:56:20 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id EDEA5384F488 for ; Mon, 20 Nov 2023 09:55:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EDEA5384F488 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EDEA5384F488 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700474157; cv=none; b=HHSwJ6QDasqdCDHlz0rRFga3yCL5DlAmXWt0/BT5QTDanNCLG9rzVNtp3rzmofQYicXqjgxoubLQl5ZBMgtdpDWZkWfz8G5dGpiNlzSLSAyS0/2ciU+Obc1jiZ6yyvirFbe/N2YAtOnXxZvCmA6fB2ypQTLFOBsnDfbnkGoucz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700474157; c=relaxed/simple; bh=ZR7d5eywfT76J8nH7Gm4hoduI/tsraIpS2jQgErqb4k=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=i1bu5wuLc3uEnONZB8H7MSLV3XJEytxr1YKSS7wdZZg1diO6R7Ui/ulk2Tuqoqd2yqmRqpvbqVCqhAQNS1yYSHZSmYUf9ec1ZKbI+7axumb7pNF+lj2zg0eBVZh93wjs7Zsp7dBDgpFeNdjkspb2faTplcQmFZfHpG/HkleRvBE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700474154; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2B22qaPIT+Hgh50VaypES9aT7OWFYFqmMbHT/SSJ5S0=; b=WxN/dWDn3J/RHUyo/i95OSMQFpfgUgYY/LAOUQJH9V4lmJD/OyA4UdpcbLuE2MopZkyqzi c+77M4VcJFuENcH/sqzzFzEczDv1UDFS3ruEGOMMA8N0x1kTwrneLkPOJmWwOPQI5gj47W 5Yj9nydeNE35LC5QWQvRyiDGQ3j71zw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-362-ZE9lcXhtNpqjPNpsKFAIyw-1; Mon, 20 Nov 2023 04:55:52 -0500 X-MC-Unique: ZE9lcXhtNpqjPNpsKFAIyw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0A394830E64 for ; Mon, 20 Nov 2023 09:55:52 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B9005036 for ; Mon, 20 Nov 2023 09:55:51 +0000 (UTC) From: Florian Weimer To: gcc-patches@gcc.gnu.org Subject: [PATCH v3 01/11] aarch64: Avoid -Wincompatible-pointer-types warning in Linux unwinder In-Reply-To: Message-ID: <6a18b92d17c1b465ebf6b4d6f94ee9050c49feac.1700473918.git.fweimer@redhat.com> References: X-From-Line: 6a18b92d17c1b465ebf6b4d6f94ee9050c49feac Mon Sep 17 00:00:00 2001 Date: Mon, 20 Nov 2023 10:55:49 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783076431769017177 X-GMAIL-MSGID: 1783076431769017177 * config/aarch64/linux-unwind.h (aarch64_fallback_frame_state): Add cast to the expected type in sc assignment. --- libgcc/config/aarch64/linux-unwind.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libgcc/config/aarch64/linux-unwind.h b/libgcc/config/aarch64/linux-unwind.h index 00eba866049..18b3df71e7b 100644 --- a/libgcc/config/aarch64/linux-unwind.h +++ b/libgcc/config/aarch64/linux-unwind.h @@ -77,7 +77,10 @@ aarch64_fallback_frame_state (struct _Unwind_Context *context, } rt_ = context->cfa; - sc = &rt_->uc.uc_mcontext; + /* Historically, the uc_mcontext member was of type struct sigcontext, but + glibc uses a different type now with member names in the implementation + namespace. */ + sc = (struct sigcontext *) &rt_->uc.uc_mcontext; /* This define duplicates the definition in aarch64.md */ #define SP_REGNUM 31 From patchwork Mon Nov 20 09:55:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 167016 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp2089830vqn; Mon, 20 Nov 2023 01:56:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGFVqbzOC3ljQf/DbPVGl+zHUiZW5JKrWjFLUkayzzttuivW+3RGVnyq9wFuK1qvHUAXoPK X-Received: by 2002:a05:620a:8405:b0:778:8b39:166e with SMTP id pc5-20020a05620a840500b007788b39166emr6798598qkn.20.1700474204256; Mon, 20 Nov 2023 01:56:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700474204; cv=pass; d=google.com; s=arc-20160816; b=qO6Am5JWyqv3cpTDYaRe+7JSTwovi/5AMgcPiWzykR5gQJT3QjPeCKc4qGXItQ2X53 MMkeDuIdXGYQP8X1Nn3fHedych5irAtSzUxnMG95loL6JcrroPsKHAvD9w0wutm832LB KlgamchZgXfFAu42x3Y2NYaxlgSHB/fynI7xkZ5wyQa5xUbZBMm/DfoBzwsfWKpQA851 B5dOBCriLbJ9Y3IPCG9OkMww1kXn2w/q335WHeyTzHhV6ct3KHucysyts/i1I2W/gptC REkao/3SlNxpYaTGQeP8m5LpGPNvw0QAggQittOWh9xg4i+H5qPdb5ifQKRwY9B609EP NxZA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent:date :references:message-id:in-reply-to:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=DiydS9XBDJBtBvJQmV3klQcBxRIaRlCrSpmsDoCfjdc=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=DKAkfavdWQ0o/i5MJ22jC23OODyXTmxPziaUrmwQe1TbSQgNToWIKL1E5dEtHMB8P5 o9IqI+zN+tAzybl1WNK3dLYSsF660tGKTUquY52Ux2xjHpVE+Qv64EctXFaNj5+ar/CM nOJn2sctGf2fD0j4AR+DoiOJLuAvyLAG0d4fz6kK+FJZMLQMeOOSt0yuFWKPZ5ufFigV LqrPPAd4IydtX/XtMfWPvwVqljwwT43cLdB1GD4XIguDLbCZTDN/R9r21wc783p76Fo2 PmcvIymlcucG8ObOwOU/wOvkMSbMdT7FEkhKpbBchQltb0kXr+ThhTA4VeCieOFW6knj uYEQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OJ+OzrZH; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id qs8-20020a05620a394800b00779d59077d4si7436652qkn.667.2023.11.20.01.56.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 01:56:44 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OJ+OzrZH; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 97A02388458E for ; Mon, 20 Nov 2023 09:56:25 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 23197382F90C for ; Mon, 20 Nov 2023 09:56:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 23197382F90C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 23197382F90C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700474161; cv=none; b=Cpppndkcm2vbL9Y0kv/fs9MzR3uJTu8PsCPbbi22PJgIJoomD9pJ4Go/vrXiqAunVg8hm+sF7c4u+sUOToJ6epnky0i9XYe3OHXBeVZFNWGHrprNdRlXj6ADwbRYQPErD0K0r6KezLo+jhYfYbPhXy6iYxDTKmV1NrndsQ9Ec4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700474161; c=relaxed/simple; bh=GmYT2MuB1DOGvU55wzHs64ahBeYyx8F4ddQxthgZaSI=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=WfXhfvCOPe/eaf39C/0oQrzJ1WoBeddFT1n06jgBktuW4xsHNpgmv7xqQMwLDxsySZrrw+2P+QOg39tZ5cQC2p8qO9B1WPzkzy7DBL7oAg5qJIRIr6s0jI0OWQyi0r9AbyqmYYDa543xIEMb0Bgk23fqkoH1D68BNpeObzqqHss= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700474159; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=DiydS9XBDJBtBvJQmV3klQcBxRIaRlCrSpmsDoCfjdc=; b=OJ+OzrZHgTFeCgwlrO5RVQCvRRcmT1MmXqucVAmczGTQzWCkwtaAFvKFGG7ZCW+4uWOfuK B6Muw4jSVxQebEyoKBeMXPftMv5htDpZ5GRs+CO6EGG68AY/tFSxgfc8ob5Ch0iXAHo+bm 46z3QbuRvxKid8uidWTNz7ZiViPXkGo= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-541-jSo1LLNYOEKbJPgRRLmYjg-1; Mon, 20 Nov 2023 04:55:57 -0500 X-MC-Unique: jSo1LLNYOEKbJPgRRLmYjg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A17651C06E33 for ; Mon, 20 Nov 2023 09:55:57 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 06E93C1596F for ; Mon, 20 Nov 2023 09:55:56 +0000 (UTC) From: Florian Weimer To: gcc-patches@gcc.gnu.org Subject: [PATCH v3 02/11] aarch64: Call named function in gcc.target/aarch64/aapcs64/ice_1.c In-Reply-To: Message-ID: References: X-From-Line: dcab4866c14b323b00d92348ddb975d79f713ef9 Mon Sep 17 00:00:00 2001 Date: Mon, 20 Nov 2023 10:55:54 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783076439624046430 X-GMAIL-MSGID: 1783076439624046430 This test looks like it intends to pass a small struct argument through both a non-variadic and variadic argument, but due to the typo, it does not achieve that. gcc/testsuite/ * gcc.target/aarch64/aapcs64/ice_1.c (foo): Call named. --- gcc/testsuite/gcc.target/aarch64/aapcs64/ice_1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.target/aarch64/aapcs64/ice_1.c b/gcc/testsuite/gcc.target/aarch64/aapcs64/ice_1.c index 906ccebf616..edc35db2f6e 100644 --- a/gcc/testsuite/gcc.target/aarch64/aapcs64/ice_1.c +++ b/gcc/testsuite/gcc.target/aarch64/aapcs64/ice_1.c @@ -16,6 +16,6 @@ void unnamed (int, ...); void foo () { - name (0, aaaa); + named (0, aaaa); unnamed (0, aaaa); } From patchwork Mon Nov 20 09:55:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 167019 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp2090080vqn; Mon, 20 Nov 2023 01:57:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/0ZMEiBq2HzZkAvFzR4Bu8/GIeERPKAhaq3y1HlhtxdT+ZypU3bluxFEzmXfOuEK3visr X-Received: by 2002:a05:6359:2104:b0:16d:be35:2e9d with SMTP id lp4-20020a056359210400b0016dbe352e9dmr5671797rwb.24.1700474243141; Mon, 20 Nov 2023 01:57:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700474243; cv=pass; d=google.com; s=arc-20160816; b=kxeM6yjiFP68oI3qGnrlBN/bQvz1lDABQJIwvwmyDinmUELguQZHbCeoAhwHF/mF40 IJK7koRvnfsgdo3+8Kz3P72Ma17hdy7MfBaB0/yQDBhYqlmIVwoS5VZct8rpdHVWRYM6 XCwi7mLpAoNTZNYSY8/2Xt0sMwvqFIg+NvAa3dpqWR3O18uSUT6DgrqV1gJN/cmxt2iv LX7qIdZE59kCFNqzHazVNcPTGbgDFy3x5IW4ITMhz9ajVuwaHRQpoDYyhv29zSIWjkp5 h7en8wqewj//JoUzz+gUc2D8+4bxNvv2EGoBCp1KIFAWZgd+eu/iELygNhKOLO0erVwd t/0w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent:date :references:message-id:in-reply-to:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=DfFMJOQwNBXvjRXcH41kPFYMlAz7kJXe6NerAGncXws=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=Dv+7bhXCiPwqH9RCMKrzEnXvw/7mROo1uT91ch1V2n/hi3lapNar4cNZ6LRVe567Tw eP9NMTjViToHTFTGxaOIZXhssO+Pd4dtazTJsVjGR6muEy+1hOh9lR4HxHfHl9p67vms vRPYFLHcXMjDLkicorgOUMLbNXYkCQuMm9Cuszp/7ziSjdYj9NSvMIyMsHn/OV56c/+z 0H9wx9ex7RfKSqBg+KkBJkG3/KqwhvdSCjHDQ9K9t3O8QPIBq9BMuwXKmfXdWGjrWYwx zLaXtMr2WZby5CjTHlgN5mGJmgYFENrNAcM0nyd6Owq5uEqHMtbz5tjmVzq5oWz/g2WZ T8Ww== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aZAYWAie; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id r8-20020ac85c88000000b004198ff97550si7251687qta.28.2023.11.20.01.57.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 01:57:23 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aZAYWAie; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2AE59388267A for ; Mon, 20 Nov 2023 09:57:09 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 2F0D9385841E for ; Mon, 20 Nov 2023 09:56:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2F0D9385841E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2F0D9385841E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700474165; cv=none; b=dKwF57/HVjSYJE8n/TXWT/0NsX+E8BL8hm13KoMa39t+dL4fxGCup3Lu/yF8TrCfVHCUwyDgApjHr3dx43fR8CYQAiIVZu434hzWQJA+nrJLJ450e5LqPrVN0s0d6aJ7jlWXTgSxIZJrQ+3WWF0FC6oSiVRhHGRiiM1K/Cjtxew= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700474165; c=relaxed/simple; bh=oqUx28IR1MQji3b3gaCUNErVFwertlqTY/jrgTXOn/M=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=LB3zUD1mP6iqdT1gmWxNrMQqzTTdkce7utS9NO+BaB94T2ZUlg7jMZeD8mrobuLQTGBM4i+h8GVm1jJKBGAYD+unzmnMLPEXt26eckN4MgA2V0ikrDp8Wi0HxzLLbJZ8IT3ITnzOgJzeDtfxHzzqetaXj04ul2cVn3kw03pP0c8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700474163; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=DfFMJOQwNBXvjRXcH41kPFYMlAz7kJXe6NerAGncXws=; b=aZAYWAie69IY/7QklUORs1DtduNWiWmNWvOFEwIL5FIwfchxTf0vHWvzll6lJHuHEBoToy bqssXEbGP5US7Dh1J6snwaBf+gxwOOlRpGmLwy1BNHd6PUEtZTOHYTKdyiaIEbiaKE2sOq XTN8Y+y73PvXJoq437MbL4E/VeX+hiY= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-554-XTgKoVR3MXGyiedihAZY1g-1; Mon, 20 Nov 2023 04:56:02 -0500 X-MC-Unique: XTgKoVR3MXGyiedihAZY1g-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 335071C06E2F for ; Mon, 20 Nov 2023 09:56:02 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B5ACE1C060B0 for ; Mon, 20 Nov 2023 09:56:01 +0000 (UTC) From: Florian Weimer To: gcc-patches@gcc.gnu.org Subject: [PATCH v3 03/11] gm2: Add missing declaration of m2pim_M2RTS_Terminate to test In-Reply-To: Message-ID: References: X-From-Line: d2be3b364f48b17c37fe882e45c0569cd73c481e Mon Sep 17 00:00:00 2001 Date: Mon, 20 Nov 2023 10:55:59 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783076479932077227 X-GMAIL-MSGID: 1783076479932077227 gcc/testsuite/ * gm2/link/externalscaffold/pass/scaffold.c (m2pim_M2RTS_Terminate): Declare. --- gcc/testsuite/gm2/link/externalscaffold/pass/scaffold.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/testsuite/gm2/link/externalscaffold/pass/scaffold.c b/gcc/testsuite/gm2/link/externalscaffold/pass/scaffold.c index 2bd3587f6c7..2df0368b983 100644 --- a/gcc/testsuite/gm2/link/externalscaffold/pass/scaffold.c +++ b/gcc/testsuite/gm2/link/externalscaffold/pass/scaffold.c @@ -6,6 +6,7 @@ extern void m2pim_M2_M2RTS_init (int argc, char *argv[]); extern void m2pim_M2_M2RTS_fini (void); extern void m2pim_M2_RTExceptions_init (int argc, char *argv[]); extern void m2pim_M2_RTExceptions_fini (void); +extern void m2pim_M2RTS_Terminate (void); extern void _M2_hello_init (int argc, char *argv[]); extern void _M2_hello_fini (void); From patchwork Mon Nov 20 09:56:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 167021 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp2090097vqn; Mon, 20 Nov 2023 01:57:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHrF8jPxmzroupJNauvszo7zv9zVk4sTovb+HkBHMoCgHB/7waoMeNgq3FKjh1lPG9G5M7E X-Received: by 2002:a05:6214:23c8:b0:679:d325:f32f with SMTP id hr8-20020a05621423c800b00679d325f32fmr4107523qvb.63.1700474246950; Mon, 20 Nov 2023 01:57:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700474246; cv=pass; d=google.com; s=arc-20160816; b=P4rSw9cwGtUp213HTZxqaMLW0Bh/yZ2C80v3VvIQSStey6pdcoSkbnvXGTIBaaNqPd ea1ZnTvF5pXuqkGI5ZlmNd32AtlsutIoKszHsCx6mul1zX/tWFefgbQa0BUfwDLsWgVc 7piSIqrdD686cZJUXH0vDmAOQMIcRu/iSBXOjUyccM9mzPl/Y9r2cw5c+JBVLZ//suSM G5Jqa8sFkI3JBM0ku1/9mqJVVERbuv+/zzoiygxV0s+ZbxPTJTYJE7foIsjJOSRiyxft TFsV98fIo2ZFxEY1bwBm6Rt4jTlPbu8uGFsnCf5mqdKGx0rk5GNVtyhwXt43V9YF21JK yaYQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent:date :references:message-id:in-reply-to:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=OOuC1B7oCL6juhJ5Ke+Jz+orynYnpQrZu5dkyqwz4+4=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=bR3UD30AypPM4IuqmLA/SBd0s2B3SRE2gBjLdMkLZBsyBEHWrWvxVUgFlDt4AmvbYw T+FHd27tRx+CMAVOYRR0OE8LjvpDx91idgrhGJ3uPEmV3ekZqKQ+lzK5jBKH/DwRIEUx UDivgAabKme35tp/2PhLdXhlb2ferZfx/B+XqolqqEbv9K5PcphkWUxbJxX9LlDIuytj ojdk0VNz3qeTO5NhC2bBXqZkD5xg0qww92exjj2dQdkOCe6d1wQ3DL++55EViGK1Cve2 PEYt6cbjF1+2u3WPlRRnZkzFcSxs+nH4ASVxx/B5z4L67TSbqeuvKbwQd6ryNl8wJWT0 GKNw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fZFzhXnU; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f7-20020a056214164700b00671022d48e4si7245938qvw.427.2023.11.20.01.57.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 01:57:26 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fZFzhXnU; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A8E813884569 for ; Mon, 20 Nov 2023 09:57:12 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 9B730388265A for ; Mon, 20 Nov 2023 09:56:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9B730388265A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9B730388265A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700474178; cv=none; b=Js5i3HbaB7XI9UMoszNaVL/p3N01Fk7cpkZ9M9Cwde8W/a5Tc7FqIcyHEg9rm6My5C9hw4brFepqsWDxbpZtiwgdx6tI0lhHO9Yp/fWNr97Zwyj5XkoNm8ntVp9czP3xXJFlci9GVjpQxOZz8LCN+xo6NbnRE5JkOa2y8nLb8kE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700474178; c=relaxed/simple; bh=52/FH1tym9tm4KvknEfGIbAHzLxRGfgK02oCuFwqNNc=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=PpFA4lO1lj0ioFt5AibwXQq/vZSFYZD+ZeVq1ZsXQFQivg+CFoRapo4cnEuaqBSuxS9ncaj191J7Wyp59DhB0pPsJ3tDPZupW8EDRNdbGzfjwML2+rXmc0vHZxOSmcAZW1ikkwuTird34qrNwL7umP+mTF8wWkld1/dtlEKxvec= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700474173; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OOuC1B7oCL6juhJ5Ke+Jz+orynYnpQrZu5dkyqwz4+4=; b=fZFzhXnUi1vtae7v+7b8GZfYiQdv8QPxqTZLVZW3hQjsbVG7/piFUy+XK8jHnCRmWI0rnk g/QNZAvFXzg27S7V1wGo5SL1J92HlCOlgjgtNUtBikU7/nClck7uzqw4Ibe+zWfA9qQq8B 85SZLtOrA2Hj4G+2eNqA+UBCXnxvlvk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-39t8midQPfiwgbg-3NWyUQ-1; Mon, 20 Nov 2023 04:56:07 -0500 X-MC-Unique: 39t8midQPfiwgbg-3NWyUQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2DB90828AC3 for ; Mon, 20 Nov 2023 09:56:07 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E5CDB2026D4C for ; Mon, 20 Nov 2023 09:56:05 +0000 (UTC) From: Florian Weimer To: gcc-patches@gcc.gnu.org Subject: [PATCH v3 04/11] Add tests for validating future C permerrors In-Reply-To: Message-ID: <39c669e5eb8d904ce59ad18f3cd0368959ec067b.1700473918.git.fweimer@redhat.com> References: X-From-Line: 39c669e5eb8d904ce59ad18f3cd0368959ec067b Mon Sep 17 00:00:00 2001 Date: Mon, 20 Nov 2023 10:56:03 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783076484058304357 X-GMAIL-MSGID: 1783076484058304357 The dg-error directives for gcc.dg/permerror-system.c can be generated using (for the most part at least): perl -ne 'print if s,.*(/\* \{ dg-error .*) } \*/$,$1 "" { target *-*-* } $. } */,' \ < gcc/testsuite/gcc.dg/permerror-default.c gcc/testsuite/ * gcc.dg/permerror-default.c: New test. * gcc.dg/permerror-fpermissive.c: Likewise. * gcc.dg/permerror-fpermissive-nowarning.c: Likewise. * gcc.dg/permerror-gnu89-nopermissive.c: Likewise. No permerrors yet, so this matches gcc.dg/permerror-gnu89.c for now. * gcc.dg/permerror-gnu89-pedantic.c: New test. * gcc.dg/permerror-gnu89.c: Likewise. * gcc.dg/permerror-noerror.c: Likewise. * gcc.dg/permerror-nowarning.c: Likewise. * gcc.dg/permerror-pedantic.c: Likewise. * gcc.dg/permerror-system.c: Likewise. --- gcc/testsuite/gcc.dg/permerror-default.c | 85 +++++++++++++++++++ .../gcc.dg/permerror-fpermissive-nowarning.c | 11 +++ gcc/testsuite/gcc.dg/permerror-fpermissive.c | 85 +++++++++++++++++++ .../gcc.dg/permerror-gnu89-nopermissive.c | 85 +++++++++++++++++++ .../gcc.dg/permerror-gnu89-pedantic.c | 85 +++++++++++++++++++ gcc/testsuite/gcc.dg/permerror-gnu89.c | 85 +++++++++++++++++++ gcc/testsuite/gcc.dg/permerror-noerror.c | 85 +++++++++++++++++++ gcc/testsuite/gcc.dg/permerror-nowarning.c | 10 +++ gcc/testsuite/gcc.dg/permerror-pedantic.c | 85 +++++++++++++++++++ gcc/testsuite/gcc.dg/permerror-system.c | 9 ++ 10 files changed, 625 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/permerror-default.c create mode 100644 gcc/testsuite/gcc.dg/permerror-fpermissive-nowarning.c create mode 100644 gcc/testsuite/gcc.dg/permerror-fpermissive.c create mode 100644 gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c create mode 100644 gcc/testsuite/gcc.dg/permerror-gnu89-pedantic.c create mode 100644 gcc/testsuite/gcc.dg/permerror-gnu89.c create mode 100644 gcc/testsuite/gcc.dg/permerror-noerror.c create mode 100644 gcc/testsuite/gcc.dg/permerror-nowarning.c create mode 100644 gcc/testsuite/gcc.dg/permerror-pedantic.c create mode 100644 gcc/testsuite/gcc.dg/permerror-system.c diff --git a/gcc/testsuite/gcc.dg/permerror-default.c b/gcc/testsuite/gcc.dg/permerror-default.c new file mode 100644 index 00000000000..ea0be1dc89f --- /dev/null +++ b/gcc/testsuite/gcc.dg/permerror-default.c @@ -0,0 +1,85 @@ +/* { dg-options "" } */ + +/* Overview test for C permerrors. This test should be kept in sync with the + other permerror-* tests. If new permerrors are added, test cases should be + added to this and the other files. */ + +void +implicit_function_declaration (void) +{ + f1 (); /* { dg-warning "'f1' \\\[-Wimplicit-function-declaration\\\]" } */ +} + +extern implicit_int_1; /* { dg-warning "'implicit_int_1' \\\[-Wimplicit-int\\\]" } */ +typedef implicit_int_2; /* { dg-warning "'implicit_int_2' \\\[-Wimplicit-int\\\]" } */ +extern implicit_int_3 (void); /* { dg-warning "'implicit_int_3' \\\[-Wimplicit-int\\]" } */ +implicit_int_4 (i) /* { dg-warning "return type defaults to 'int' \\\[-Wimplicit-int\\\]" } */ +/* { dg-warning "type of 'i' defaults to 'int' \\\[-Wimplicit-int\\\]" "" { target *-*-*} .-1 } */ +{ + (const) 0; /* { dg-warning "type defaults to 'int' in type name \\\[-Wimplicit-int\\\]" } */ +} + +extern int missing_parameter_type (i); /* { dg-warning "parameter names \\\(without types\\\) in function declaration\n" } */ + + +int * +int_conversion_1 (int flag) +{ + void f2 (int *); + flag ? "1" : 1; /* { dg-warning "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ + flag ? 1 : "1"; /* { dg-warning "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ + f2 (flag); /* { dg-warning "passing argument 1 of 'f2' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + { + int i1 = &flag; /* { dg-warning "initialization of 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + i1 = &flag; /* { dg-warning "assignment to 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + } + return flag; /* { dg-warning "returning 'int' from a function with return type 'int \\\*' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ +} + +int +int_conversion_2 (int flag) +{ + void f3 (int); + f3 (&flag); /* { dg-warning "passing argument 1 of 'f3' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + { + int *i1 = flag; /* { dg-warning "initialization of 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + i1 = flag; /* { dg-warning "assignment to 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + } + return &flag; /* { dg-warning "returning 'int \\\*' from a function with return type 'int' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ +} + +int * +incompatible_pointer_types (int flag) +{ + void f4 (int *); + flag ? __builtin_abs : __builtin_labs; /* { dg-warning "pointer type mismatch in conditional expression \\\[-Wincompatible-pointer-types\\\]" } */ + { + int *p1 = __builtin_abs; /* { dg-warning "initialization of 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + p1 = __builtin_abs; /* { dg-warning "assignment to 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + } + { + int *p2 = incompatible_pointer_types; /* { dg-warning "initialization of 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + p2 = incompatible_pointer_types; /* { dg-warning "assignment to 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + { + int *p3 = &p2; /* { dg-warning "initialization of 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + p3 = &p2; /* { dg-warning "assignment to 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + } + f4 (&p2); /* { dg-warning "passing argument 1 of 'f4' from incompatible pointer type \\\[-Wincompatible-pointer-types\\\]" } */ + } + if (flag) + return __builtin_abs; /* { dg-warning "returning pointer to '__builtin_abs' of type 'int \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + else + return incompatible_pointer_types; /* { dg-warning "returning 'int \\\* \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible return type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ +} + +void +return_mismatch_1 (void) +{ + return 0; /* { dg-warning "'return' with a value, in function returning void \\\[-Wreturn-mismatch\\\]" } */ +} + +int +return_mismatch_2 (void) +{ + return; /* { dg-warning "return' with no value, in function returning non-void \\\[-Wreturn-mismatch\\\]" } */ +} diff --git a/gcc/testsuite/gcc.dg/permerror-fpermissive-nowarning.c b/gcc/testsuite/gcc.dg/permerror-fpermissive-nowarning.c new file mode 100644 index 00000000000..f15b21ef43d --- /dev/null +++ b/gcc/testsuite/gcc.dg/permerror-fpermissive-nowarning.c @@ -0,0 +1,11 @@ +/* { dg-options "-fpermissive -Wno-implicit-function-declaration -Wno-implicit-int -Wno-int-conversion -Wno-incompatible-pointer-types -Wno-return-mismatch" } */ + +/* This test checks that permerrors can be disabled using -Wno-* options even + if -fpermissive is used. */ + +#include "permerror-default.c" + +/* Ideally, we do not want to see any warnings here, but this warning is not + yet controlled by its own option. */ + +/* { dg-warning "parameter names \\\(without types\\\) in function declaration\n" "" { target *-*-* } 22 } */ diff --git a/gcc/testsuite/gcc.dg/permerror-fpermissive.c b/gcc/testsuite/gcc.dg/permerror-fpermissive.c new file mode 100644 index 00000000000..139f35ad1c0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/permerror-fpermissive.c @@ -0,0 +1,85 @@ +/* { dg-options "-fpermissive" } */ + +/* Overview test for C permerrors. This test should be kept in sync with the + other permerror-* tests. If new permerrors are added, test cases should be + added to this and the other files. */ + +void +implicit_function_declaration (void) +{ + f1 (); /* { dg-warning "'f1' \\\[-Wimplicit-function-declaration\\\]" } */ +} + +extern implicit_int_1; /* { dg-warning "'implicit_int_1' \\\[-Wimplicit-int\\\]" } */ +typedef implicit_int_2; /* { dg-warning "'implicit_int_2' \\\[-Wimplicit-int\\\]" } */ +extern implicit_int_3 (void); /* { dg-warning "'implicit_int_3' \\\[-Wimplicit-int\\]" } */ +implicit_int_4 (i) /* { dg-warning "return type defaults to 'int' \\\[-Wimplicit-int\\\]" } */ +/* { dg-warning "type of 'i' defaults to 'int' \\\[-Wimplicit-int\\\]" "" { target *-*-*} .-1 } */ +{ + (const) 0; /* { dg-warning "type defaults to 'int' in type name \\\[-Wimplicit-int\\\]" } */ +} + +extern int missing_parameter_type (i); /* { dg-warning "parameter names \\\(without types\\\) in function declaration\n" } */ + + +int * +int_conversion_1 (int flag) +{ + void f2 (int *); + flag ? "1" : 1; /* { dg-warning "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ + flag ? 1 : "1"; /* { dg-warning "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ + f2 (flag); /* { dg-warning "passing argument 1 of 'f2' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + { + int i1 = &flag; /* { dg-warning "initialization of 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + i1 = &flag; /* { dg-warning "assignment to 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + } + return flag; /* { dg-warning "returning 'int' from a function with return type 'int \\\*' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ +} + +int +int_conversion_2 (int flag) +{ + void f3 (int); + f3 (&flag); /* { dg-warning "passing argument 1 of 'f3' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + { + int *i1 = flag; /* { dg-warning "initialization of 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + i1 = flag; /* { dg-warning "assignment to 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + } + return &flag; /* { dg-warning "returning 'int \\\*' from a function with return type 'int' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ +} + +int * +incompatible_pointer_types (int flag) +{ + void f4 (int *); + flag ? __builtin_abs : __builtin_labs; /* { dg-warning "pointer type mismatch in conditional expression \\\[-Wincompatible-pointer-types\\\]" } */ + { + int *p1 = __builtin_abs; /* { dg-warning "initialization of 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + p1 = __builtin_abs; /* { dg-warning "assignment to 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + } + { + int *p2 = incompatible_pointer_types; /* { dg-warning "initialization of 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + p2 = incompatible_pointer_types; /* { dg-warning "assignment to 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + { + int *p3 = &p2; /* { dg-warning "initialization of 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + p3 = &p2; /* { dg-warning "assignment to 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + } + f4 (&p2); /* { dg-warning "passing argument 1 of 'f4' from incompatible pointer type \\\[-Wincompatible-pointer-types\\\]" } */ + } + if (flag) + return __builtin_abs; /* { dg-warning "returning pointer to '__builtin_abs' of type 'int \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + else + return incompatible_pointer_types; /* { dg-warning "returning 'int \\\* \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible return type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ +} + +void +return_mismatch_1 (void) +{ + return 0; /* { dg-warning "'return' with a value, in function returning void \\\[-Wreturn-mismatch\\\]" } */ +} + +int +return_mismatch_2 (void) +{ + return; /* { dg-warning "return' with no value, in function returning non-void \\\[-Wreturn-mismatch\\\]" } */ +} diff --git a/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c b/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c new file mode 100644 index 00000000000..6d42bc61d5c --- /dev/null +++ b/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c @@ -0,0 +1,85 @@ +/* { dg-options "-std=gnu89 -fno-permissive" } */ + +/* Test for C89 dialect mode, with new permerrors enabled. In most + cases where the compiler warnings in C89 mode, it should issue a + permerror with -fno-permissive. */ + +void +implicit_function_declaration (void) +{ + f1 (); /* { dg-bogus "-Wimplicit-function-declaration" } */ +} + +extern implicit_int_1; /* { dg-bogus "-Wimplicit-int" } */ +typedef implicit_int_2; /* { dg-bogus "-Wimplicit-int" } */ +extern implicit_int_3 (void); /* { dg-bogus "-Wimplicit-int" } */ +implicit_int_4 (i) /* { dg-bogus "-Wimplicit-int" } */ +/* Directive here in the other files. */ +{ + (const) 0; /* { dg-bogus "-Wimplicit-int" } */ +} + +extern int missing_parameter_type (i); /* { dg-warning "parameter names \\\(without types\\\) in function declaration\n" } */ + + +int * +int_conversion_1 (int flag) +{ + void f2 (int *); + flag ? "1" : 1; /* { dg-warning "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ + flag ? 1 : "1"; /* { dg-warning "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ + f2 (flag); /* { dg-warning "passing argument 1 of 'f2' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + { + int i1 = &flag; /* { dg-warning "initialization of 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + i1 = &flag; /* { dg-warning "assignment to 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + } + return flag; /* { dg-warning "returning 'int' from a function with return type 'int \\\*' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ +} + +int +int_conversion_2 (int flag) +{ + void f3 (int); + f3 (&flag); /* { dg-warning "passing argument 1 of 'f3' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + { + int *i1 = flag; /* { dg-warning "initialization of 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + i1 = flag; /* { dg-warning "assignment to 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + } + return &flag; /* { dg-warning "returning 'int \\\*' from a function with return type 'int' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ +} + +int * +incompatible_pointer_types (int flag) +{ + void f4 (int *); + flag ? __builtin_abs : __builtin_labs; /* { dg-warning "pointer type mismatch in conditional expression \\\[-Wincompatible-pointer-types\\\]" } */ + { + int *p1 = __builtin_abs; /* { dg-warning "initialization of 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + p1 = __builtin_abs; /* { dg-warning "assignment to 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + } + { + int *p2 = incompatible_pointer_types; /* { dg-warning "initialization of 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + p2 = incompatible_pointer_types; /* { dg-warning "assignment to 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + { + int *p3 = &p2; /* { dg-warning "initialization of 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + p3 = &p2; /* { dg-warning "assignment to 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + } + f4 (&p2); /* { dg-warning "passing argument 1 of 'f4' from incompatible pointer type \\\[-Wincompatible-pointer-types\\\]" } */ + } + if (flag) + return __builtin_abs; /* { dg-warning "returning pointer to '__builtin_abs' of type 'int \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + else + return incompatible_pointer_types; /* { dg-warning "returning 'int \\\* \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible return type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ +} + +void +return_mismatch_1 (void) +{ + return 0; /* { dg-warning "'return' with a value, in function returning void \\\[-Wreturn-mismatch\\\]" } */ +} + +int +return_mismatch_2 (void) +{ + return; /* { dg-bogus "-Wreturn-mismatch" } */ +} diff --git a/gcc/testsuite/gcc.dg/permerror-gnu89-pedantic.c b/gcc/testsuite/gcc.dg/permerror-gnu89-pedantic.c new file mode 100644 index 00000000000..465a16f5f9a --- /dev/null +++ b/gcc/testsuite/gcc.dg/permerror-gnu89-pedantic.c @@ -0,0 +1,85 @@ +/* { dg-options "-std=gnu89 -pedantic-errors" } */ + +/* Overview test for C permerrors. This test should be kept in sync with the + other permerror-* tests. If new permerrors are added, test cases should be + added to this and the other files. */ + +void +implicit_function_declaration (void) +{ + f1 (); /* { dg-bogus "-Wimplicit-function-declaration" } */ +} + +extern implicit_int_1; /* { dg-bogus "-Wimplicit-int" } */ +typedef implicit_int_2; /* { dg-bogus "-Wimplicit-int" } */ +extern implicit_int_3 (void); /* { dg-bogus "-Wimplicit-int" } */ +implicit_int_4 (i) /* { dg-bogus "-Wimplicit-int" } */ +/* Directive here in the other files. */ +{ + (const) 0; /* { dg-bogus "-Wimplicit-int" } */ +} + +extern int missing_parameter_type (i); /* { dg-error "parameter names \\\(without types\\\) in function declaration\n" } */ + + +int * +int_conversion_1 (int flag) +{ + void f2 (int *); + flag ? "1" : 1; /* { dg-error "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ + flag ? 1 : "1"; /* { dg-error "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ + f2 (flag); /* { dg-error "passing argument 1 of 'f2' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + { + int i1 = &flag; /* { dg-error "initialization of 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + i1 = &flag; /* { dg-error "assignment to 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + } + return flag; /* { dg-error "returning 'int' from a function with return type 'int \\\*' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ +} + +int +int_conversion_2 (int flag) +{ + void f3 (int); + f3 (&flag); /* { dg-error "passing argument 1 of 'f3' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + { + int *i1 = flag; /* { dg-error "initialization of 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + i1 = flag; /* { dg-error "assignment to 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + } + return &flag; /* { dg-error "returning 'int \\\*' from a function with return type 'int' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ +} + +int * +incompatible_pointer_types (int flag) +{ + void f4 (int *); + flag ? __builtin_abs : __builtin_labs; /* { dg-warning "pointer type mismatch in conditional expression \\\[-Wincompatible-pointer-types\\\]" } */ + { + int *p1 = __builtin_abs; /* { dg-error "initialization of 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + p1 = __builtin_abs; /* { dg-error "assignment to 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + } + { + int *p2 = incompatible_pointer_types; /* { dg-error "initialization of 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + p2 = incompatible_pointer_types; /* { dg-error "assignment to 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + { + int *p3 = &p2; /* { dg-error "initialization of 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + p3 = &p2; /* { dg-error "assignment to 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + } + f4 (&p2); /* { dg-error "passing argument 1 of 'f4' from incompatible pointer type \\\[-Wincompatible-pointer-types\\\]" } */ + } + if (flag) + return __builtin_abs; /* { dg-error "returning pointer to '__builtin_abs' of type 'int \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + else + return incompatible_pointer_types; /* { dg-error "returning 'int \\\* \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible return type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ +} + +void +return_mismatch_1 (void) +{ + return 0; /* { dg-error "'return' with a value, in function returning void \\\[-Wreturn-mismatch\\\]" } */ +} + +int +return_mismatch_2 (void) +{ + return; /* { dg-bogus "-Wreturn-mismatch" } */ +} diff --git a/gcc/testsuite/gcc.dg/permerror-gnu89.c b/gcc/testsuite/gcc.dg/permerror-gnu89.c new file mode 100644 index 00000000000..66f7789269f --- /dev/null +++ b/gcc/testsuite/gcc.dg/permerror-gnu89.c @@ -0,0 +1,85 @@ +/* { dg-options "-std=gnu89" } */ + +/* Overview test for C permerrors. This test should be kept in sync with the + other permerror-* tests. If new permerrors are added, test cases should be + added to this and the other files. */ + +void +implicit_function_declaration (void) +{ + f1 (); /* { dg-bogus "-Wimplicit-function-declaration" } */ +} + +extern implicit_int_1; /* { dg-bogus "-Wimplicit-int" } */ +typedef implicit_int_2; /* { dg-bogus "-Wimplicit-int" } */ +extern implicit_int_3 (void); /* { dg-bogus "-Wimplicit-int" } */ +implicit_int_4 (i) /* { dg-bogus "-Wimplicit-int" } */ +/* Directive here in the other files. */ +{ + (const) 0; /* { dg-bogus "-Wimplicit-int" } */ +} + +extern int missing_parameter_type (i); /* { dg-warning "parameter names \\\(without types\\\) in function declaration\n" } */ + + +int * +int_conversion_1 (int flag) +{ + void f2 (int *); + flag ? "1" : 1; /* { dg-warning "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ + flag ? 1 : "1"; /* { dg-warning "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ + f2 (flag); /* { dg-warning "passing argument 1 of 'f2' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + { + int i1 = &flag; /* { dg-warning "initialization of 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + i1 = &flag; /* { dg-warning "assignment to 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + } + return flag; /* { dg-warning "returning 'int' from a function with return type 'int \\\*' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ +} + +int +int_conversion_2 (int flag) +{ + void f3 (int); + f3 (&flag); /* { dg-warning "passing argument 1 of 'f3' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + { + int *i1 = flag; /* { dg-warning "initialization of 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + i1 = flag; /* { dg-warning "assignment to 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + } + return &flag; /* { dg-warning "returning 'int \\\*' from a function with return type 'int' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ +} + +int * +incompatible_pointer_types (int flag) +{ + void f4 (int *); + flag ? __builtin_abs : __builtin_labs; /* { dg-warning "pointer type mismatch in conditional expression \\\[-Wincompatible-pointer-types\\\]" } */ + { + int *p1 = __builtin_abs; /* { dg-warning "initialization of 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + p1 = __builtin_abs; /* { dg-warning "assignment to 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + } + { + int *p2 = incompatible_pointer_types; /* { dg-warning "initialization of 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + p2 = incompatible_pointer_types; /* { dg-warning "assignment to 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + { + int *p3 = &p2; /* { dg-warning "initialization of 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + p3 = &p2; /* { dg-warning "assignment to 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + } + f4 (&p2); /* { dg-warning "passing argument 1 of 'f4' from incompatible pointer type \\\[-Wincompatible-pointer-types\\\]" } */ + } + if (flag) + return __builtin_abs; /* { dg-warning "returning pointer to '__builtin_abs' of type 'int \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + else + return incompatible_pointer_types; /* { dg-warning "returning 'int \\\* \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible return type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ +} + +void +return_mismatch_1 (void) +{ + return 0; /* { dg-warning "'return' with a value, in function returning void \\\[-Wreturn-mismatch\\\]" } */ +} + +int +return_mismatch_2 (void) +{ + return; /* { dg-bogus "-Wreturn-mismatch" } */ +} diff --git a/gcc/testsuite/gcc.dg/permerror-noerror.c b/gcc/testsuite/gcc.dg/permerror-noerror.c new file mode 100644 index 00000000000..cd1c2013cb5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/permerror-noerror.c @@ -0,0 +1,85 @@ +/* { dg-options "-Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=int-conversion -Wno-error=incompatible-pointer-types -Wno-error=return-mismatch" } */ + +/* This test should emulate the effect of -fpermissive by adding all the + -Wno-error= options that are implied by -fpermissive. It needs to be + kept in sync with the other permerror-* tests. */ + +void +implicit_function_declaration (void) +{ + f1 (); /* { dg-warning "'f1' \\\[-Wimplicit-function-declaration\\\]" } */ +} + +extern implicit_int_1; /* { dg-warning "'implicit_int_1' \\\[-Wimplicit-int\\\]" } */ +typedef implicit_int_2; /* { dg-warning "'implicit_int_2' \\\[-Wimplicit-int\\\]" } */ +extern implicit_int_3 (void); /* { dg-warning "'implicit_int_3' \\\[-Wimplicit-int\\]" } */ +implicit_int_4 (i) /* { dg-warning "return type defaults to 'int' \\\[-Wimplicit-int\\\]" } */ +/* { dg-warning "type of 'i' defaults to 'int' \\\[-Wimplicit-int\\\]" "" { target *-*-*} .-1 } */ +{ + (const) 0; /* { dg-warning "type defaults to 'int' in type name \\\[-Wimplicit-int\\\]" } */ +} + +extern int missing_parameter_type (i); /* { dg-warning "parameter names \\\(without types\\\) in function declaration\n" } */ + + +int * +int_conversion_1 (int flag) +{ + void f2 (int *); + flag ? "1" : 1; /* { dg-warning "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ + flag ? 1 : "1"; /* { dg-warning "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ + f2 (flag); /* { dg-warning "passing argument 1 of 'f2' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + { + int i1 = &flag; /* { dg-warning "initialization of 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + i1 = &flag; /* { dg-warning "assignment to 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + } + return flag; /* { dg-warning "returning 'int' from a function with return type 'int \\\*' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ +} + +int +int_conversion_2 (int flag) +{ + void f3 (int); + f3 (&flag); /* { dg-warning "passing argument 1 of 'f3' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + { + int *i1 = flag; /* { dg-warning "initialization of 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + i1 = flag; /* { dg-warning "assignment to 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + } + return &flag; /* { dg-warning "returning 'int \\\*' from a function with return type 'int' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ +} + +int * +incompatible_pointer_types (int flag) +{ + void f4 (int *); + flag ? __builtin_abs : __builtin_labs; /* { dg-warning "pointer type mismatch in conditional expression \\\[-Wincompatible-pointer-types\\\]" } */ + { + int *p1 = __builtin_abs; /* { dg-warning "initialization of 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + p1 = __builtin_abs; /* { dg-warning "assignment to 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + } + { + int *p2 = incompatible_pointer_types; /* { dg-warning "initialization of 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + p2 = incompatible_pointer_types; /* { dg-warning "assignment to 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + { + int *p3 = &p2; /* { dg-warning "initialization of 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + p3 = &p2; /* { dg-warning "assignment to 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + } + f4 (&p2); /* { dg-warning "passing argument 1 of 'f4' from incompatible pointer type \\\[-Wincompatible-pointer-types\\\]" } */ + } + if (flag) + return __builtin_abs; /* { dg-warning "returning pointer to '__builtin_abs' of type 'int \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + else + return incompatible_pointer_types; /* { dg-warning "returning 'int \\\* \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible return type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ +} + +void +return_mismatch_1 (void) +{ + return 0; /* { dg-warning "'return' with a value, in function returning void \\\[-Wreturn-mismatch\\\]" } */ +} + +int +return_mismatch_2 (void) +{ + return; /* { dg-warning "return' with no value, in function returning non-void \\\[-Wreturn-mismatch\\\]" } */ +} diff --git a/gcc/testsuite/gcc.dg/permerror-nowarning.c b/gcc/testsuite/gcc.dg/permerror-nowarning.c new file mode 100644 index 00000000000..da6bd08245d --- /dev/null +++ b/gcc/testsuite/gcc.dg/permerror-nowarning.c @@ -0,0 +1,10 @@ +/* { dg-options "-Wno-implicit-function-declaration -Wno-implicit-int -Wno-int-conversion -Wno-incompatible-pointer-types -Wno-return-mismatch" } */ + +/* This test checks that permerrors can be disabled using -Wno-* options. */ + +#include "permerror-default.c" + +/* Ideally, we do not want to see any warnings here, but this warning is not + yet controlled by its own option. */ + +/* { dg-warning "parameter names \\\(without types\\\) in function declaration\n" "" { target *-*-* } 22 } */ diff --git a/gcc/testsuite/gcc.dg/permerror-pedantic.c b/gcc/testsuite/gcc.dg/permerror-pedantic.c new file mode 100644 index 00000000000..852e7daa38d --- /dev/null +++ b/gcc/testsuite/gcc.dg/permerror-pedantic.c @@ -0,0 +1,85 @@ +/* { dg-options "-pedantic-errors" } */ + +/* Overview test for C permerrors. This test should be kept in sync with the + other permerror-* tests. If new permerrors are added, test cases should be + added to this and the other files. */ + +void +implicit_function_declaration (void) +{ + f1 (); /* { dg-error "'f1' \\\[-Wimplicit-function-declaration\\\]" } */ +} + +extern implicit_int_1; /* { dg-error "'implicit_int_1' \\\[-Wimplicit-int\\\]" } */ +typedef implicit_int_2; /* { dg-error "'implicit_int_2' \\\[-Wimplicit-int\\\]" } */ +extern implicit_int_3 (void); /* { dg-error "'implicit_int_3' \\\[-Wimplicit-int\\]" } */ +implicit_int_4 (i) /* { dg-error "return type defaults to 'int' \\\[-Wimplicit-int\\\]" } */ +/* { dg-error "type of 'i' defaults to 'int' \\\[-Wimplicit-int\\\]" "" { target *-*-*} .-1 } */ +{ + (const) 0; /* { dg-error "type defaults to 'int' in type name \\\[-Wimplicit-int\\\]" } */ +} + +extern int missing_parameter_type (i); /* { dg-error "parameter names \\\(without types\\\) in function declaration\n" } */ + + +int * +int_conversion_1 (int flag) +{ + void f2 (int *); + flag ? "1" : 1; /* { dg-error "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ + flag ? 1 : "1"; /* { dg-error "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ + f2 (flag); /* { dg-error "passing argument 1 of 'f2' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + { + int i1 = &flag; /* { dg-error "initialization of 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + i1 = &flag; /* { dg-error "assignment to 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + } + return flag; /* { dg-error "returning 'int' from a function with return type 'int \\\*' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ +} + +int +int_conversion_2 (int flag) +{ + void f3 (int); + f3 (&flag); /* { dg-error "passing argument 1 of 'f3' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + { + int *i1 = flag; /* { dg-error "initialization of 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + i1 = flag; /* { dg-error "assignment to 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + } + return &flag; /* { dg-error "returning 'int \\\*' from a function with return type 'int' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ +} + +int * +incompatible_pointer_types (int flag) +{ + void f4 (int *); + flag ? __builtin_abs : __builtin_labs; /* { dg-warning "pointer type mismatch in conditional expression \\\[-Wincompatible-pointer-types\\\]" } */ + { + int *p1 = __builtin_abs; /* { dg-error "initialization of 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + p1 = __builtin_abs; /* { dg-error "assignment to 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + } + { + int *p2 = incompatible_pointer_types; /* { dg-error "initialization of 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + p2 = incompatible_pointer_types; /* { dg-error "assignment to 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + { + int *p3 = &p2; /* { dg-error "initialization of 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + p3 = &p2; /* { dg-error "assignment to 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + } + f4 (&p2); /* { dg-error "passing argument 1 of 'f4' from incompatible pointer type \\\[-Wincompatible-pointer-types\\\]" } */ + } + if (flag) + return __builtin_abs; /* { dg-error "returning pointer to '__builtin_abs' of type 'int \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + else + return incompatible_pointer_types; /* { dg-error "returning 'int \\\* \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible return type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ +} + +void +return_mismatch_1 (void) +{ + return 0; /* { dg-error "'return' with a value, in function returning void \\\[-Wreturn-mismatch\\\]" } */ +} + +int +return_mismatch_2 (void) +{ + return; /* { dg-error "return' with no value, in function returning non-void \\\[-Wreturn-mismatch\\\]" } */ +} diff --git a/gcc/testsuite/gcc.dg/permerror-system.c b/gcc/testsuite/gcc.dg/permerror-system.c new file mode 100644 index 00000000000..e6a978e494d --- /dev/null +++ b/gcc/testsuite/gcc.dg/permerror-system.c @@ -0,0 +1,9 @@ +/* { dg-options "-isystem ${srcdir}" } */ + +/* Test that permerrors appear in system headers. */ + +/* The dg-* directives in the header file are ignored. No warnings are + expected. */ +#include + +/* These errors come from permerror-default.c. No errors yet. */ From patchwork Mon Nov 20 09:56:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 167022 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp2090292vqn; Mon, 20 Nov 2023 01:58:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IEcF9XbepOw8sWFZO5qkg4Np+dOar/fDfkyAEM2DNmAf2nqIMiPuw7ddIZdvcbtIvmziL/h X-Received: by 2002:ac8:5c03:0:b0:421:ac6d:c091 with SMTP id i3-20020ac85c03000000b00421ac6dc091mr9953131qti.9.1700474283728; Mon, 20 Nov 2023 01:58:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700474283; cv=pass; d=google.com; s=arc-20160816; b=UX0nxuwShE1iWR0WjClB7S2suw5hJchhWq2eY03HhLJWppYH7T3RM4U1NRZFyLgVn0 a1h5Ls/DcZCqq0IUsRtONTLvOukODqJnR9QzUkVYLbQvg+e0Wpl35QjJCWZ7c32J6rrK tW7WJ4T72hI1QRnEWusHZudw9I4qm1BQeA0QgQMhhzTLJcAQH2CNcQoTpAF0hAe8K+fb 3Z/aQHabk2UF2EcFVMFX18PpLhp/IJoBNhIb5j/e3aQzdA+k8Sy+BpcPUHUxLVsEp2Z3 i6ElFsjMwBmXNN831Ksyx5fJsJByC4KimBmRCYncdV+b4dT22zv/OW0Ly/P2400LoQbQ TVow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent:date :references:message-id:in-reply-to:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=TY9ElsyHKPutM6SW6UmLf3F007xzTEB7bcwcPlO7ua0=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=klh2mRLyDcyV0mDiWyy2kaJ43UYb9uAeCyc2q5fvTGntNAAUpoz712PH+OKAR0+KCg W7H0wmOC484zGtmqWVx2nMYVUQSYexMHny11aMhyJZfj9ZFR2dtLZoJNP8czifUCbFQ7 2s4GDdBg5SyeQDnW+JQy3F+prlGeDpTo7NDmpwCusSMYghdnbOfU9mv0AwAPW0cx5KRF UllAmp/qRA7qEx0fOcOZVehxNgtP54NbVi98fxLnn8AABG6XruL0jiIL8AJ1C2UARdYB 5xQmstxCBx8wH2PbWvAPVJ/q0MH4NYCqZ9R06k8y6wgLcVa3TYbdH8udQurkQiRCACLM jGqQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Y0GZcFui; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id f14-20020ac87f0e000000b004179a79ef98si7018353qtk.220.2023.11.20.01.58.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 01:58:03 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Y0GZcFui; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8CD223882175 for ; Mon, 20 Nov 2023 09:57:56 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 5D7683870922 for ; Mon, 20 Nov 2023 09:56:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5D7683870922 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5D7683870922 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700474180; cv=none; b=RSpqFLavuLrclI08pimNvywzJQ6zzPGKYQtzuas7OSlqelwz4oNF84dBkGM7AmR5/k2Ch4tzv+eaP+Ba5zk7YIvrChNupCeyVxvio4DEZl2gRWSLO36D1RD6w4PiaIhLfkz5XVq7EIEG/A6VBMRvCq3Ca0aMsT5V5AB4pmfBTfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700474180; c=relaxed/simple; bh=N4ddezorhurTGUTtqVLkOp2anf0cQrG1wiTkFVzpjbc=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=eM90t8HK6CHAc6F9Q8sol9lqZBup7JlYnZUZaUPnZXcsr08TlVKS2k6FvCNXpDo2PW2MdO+GrQpboXyEkzYuI2gse0Liy/PecwDuN2G9dkbdM8LaccwCGaVSb7LvGlpncV9U206LBL7T+dJsFF+ShH1zLtO43vNbAEgar4VzmsM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700474174; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=TY9ElsyHKPutM6SW6UmLf3F007xzTEB7bcwcPlO7ua0=; b=Y0GZcFui4yIHunyj/S3JR3Z3+h9/xZ8zSHurAiCEHlpv3qvYv+Tjf6PH1HrtBo9yXJQ8GO n0vAKqij/EdPE7E8QRWwANIvEzpYFa5BYVaSxV/FtQF+IiDBFkb7VJph1pq4AyuUlqFPWa 9FrXokmOW02rM2raAhj7iGxrmQq+tYg= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-631-G2M36WOXPgC6NWuSqlOVTQ-1; Mon, 20 Nov 2023 04:56:12 -0500 X-MC-Unique: G2M36WOXPgC6NWuSqlOVTQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 558D93804073 for ; Mon, 20 Nov 2023 09:56:12 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 589EA2026D4C for ; Mon, 20 Nov 2023 09:56:11 +0000 (UTC) From: Florian Weimer To: gcc-patches@gcc.gnu.org Subject: [PATCH v3 05/11] c: Turn int-conversion warnings into permerrors In-Reply-To: Message-ID: <145518b7d8fc4d04b8d00b69375e27860c5c1000.1700473918.git.fweimer@redhat.com> References: X-From-Line: 145518b7d8fc4d04b8d00b69375e27860c5c1000 Mon Sep 17 00:00:00 2001 Date: Mon, 20 Nov 2023 10:56:09 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783076522716361028 X-GMAIL-MSGID: 1783076522716361028 gcc/ * doc/invoke.texi (Warning Options): Document changes. gcc/c/ PR c/96284 PR c/106416 * c-typeck.cc (build_conditional_expr): Use permerror_opt for pointer/integer type mismatches, based on -Wint-conversion. (pedwarn_permerror_init, permerror_init): New function. (pedwarn_init): Call pedwarn_permerror_init. (convert_for_assignment): Use permerror_opt and permerror_init for -Wint-conversion warnings. gcc/testsuite/ * gcc.dg/permerror-default.c (int_conversion_1) (int_conversion_2): Expect the new permerrors. * gcc.dg/permerror-gnu89-nopermissive.c (int_conversion_1) (int_conversion_2): Likewise. * gcc.dg/permerror-system.c: Likewise. * c-c++-common/pr77624-1.c (foo, bar): Expect error instead of warning. * gcc.dg/Wint-conversion-2.c: Compile with -fpermissive due to expected int-conversion warning. * gcc.dg/Wint-conversion-3.c: Likewise. * gcc.dg/Wint-conversion-4.c: New test. Based on gcc.dg/Wint-conversion-3.c. Expect int-conversion errors. * gcc.dg/assign-warn-1.c: Compile with -fpermissive. * gcc.dg/assign-warn-4.c: New file. Extracted from assign-warn1.c. Expect int-cnversion errors. * gcc.dg/diagnostic-types-1.c: compile with -fpermissive. * gcc.dg/diagnostic-types-2.c: New file. Extracted from gcc.dg/diagnostic-types-1.c. Expect some errors instead of warnings. * gcc.dg/gomp/pr35738.c: Compile with -fpermissive due to expected int-conversion error. * gcc.dg/gomp/pr35738-2.c: New test. Based on gcc.dg/gomp/pr35738.c. Expect int-converison errors. * gcc.dg/init-excess-3.c: Expect int-converison errors. * gcc.dg/overflow-warn-1.c: Likewise. * gcc.dg/overflow-warn-3.c: Likewise. * gcc.dg/param-type-mismatch.c: Compile with -fpermissive. * gcc.dg/param-type-mismatch-2.c: New test. Copied from gcc.dg/param-type-mismatch.c. Expect errors. * gcc.dg/pr61162-2.c: Compile with -fpermissive. * gcc.dg/pr61162-3.c: New test. Extracted from gcc.dg/pr61162-2.c. Expect int-conversion errors. * gcc.dg/spec-barrier-3.c: Use -fpermissive due to expected int-conversion error. * gcc.dg/spec-barrier-3a.c: New test. Based on gcc.dg/spec-barrier-3.c. Expect int-conversion errors. * gcc.target/aarch64/acle/memtag_2.c: Use -fpermissive due to expected int-conversion error. * gcc.target/aarch64/acle/memtag_2a.c: New test. Copied from gcc.target/aarch64/acle/memtag_2.c. Expect error. * gcc.target/aarch64/sve/acle/general-c/load_3.c (f1): Expect error. * gcc.target/aarch64/sve/acle/general-c/store_2.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/store_scatter_index_1.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/store_scatter_index_restricted_1.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_2.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_restricted_1.c (f1): Likewise. --- gcc/c/c-typeck.cc | 97 +++++---- gcc/doc/invoke.texi | 6 + gcc/testsuite/c-c++-common/pr77624-1.c | 4 +- gcc/testsuite/gcc.dg/Wint-conversion-2.c | 2 +- gcc/testsuite/gcc.dg/Wint-conversion-3.c | 2 +- gcc/testsuite/gcc.dg/Wint-conversion-4.c | 14 ++ gcc/testsuite/gcc.dg/assign-warn-1.c | 2 +- gcc/testsuite/gcc.dg/assign-warn-4.c | 21 ++ gcc/testsuite/gcc.dg/diagnostic-types-1.c | 2 +- gcc/testsuite/gcc.dg/diagnostic-types-2.c | 24 +++ gcc/testsuite/gcc.dg/gomp/pr35738-2.c | 18 ++ gcc/testsuite/gcc.dg/gomp/pr35738.c | 2 +- gcc/testsuite/gcc.dg/init-excess-3.c | 4 +- gcc/testsuite/gcc.dg/overflow-warn-1.c | 4 +- gcc/testsuite/gcc.dg/overflow-warn-3.c | 4 +- gcc/testsuite/gcc.dg/param-type-mismatch-2.c | 187 ++++++++++++++++++ gcc/testsuite/gcc.dg/param-type-mismatch.c | 2 +- gcc/testsuite/gcc.dg/permerror-default.c | 20 +- .../gcc.dg/permerror-gnu89-nopermissive.c | 20 +- gcc/testsuite/gcc.dg/permerror-system.c | 13 +- gcc/testsuite/gcc.dg/pr61162-2.c | 2 +- gcc/testsuite/gcc.dg/pr61162-3.c | 13 ++ gcc/testsuite/gcc.dg/spec-barrier-3.c | 2 +- gcc/testsuite/gcc.dg/spec-barrier-3a.c | 13 ++ .../gcc.target/aarch64/acle/memtag_2.c | 4 +- .../gcc.target/aarch64/acle/memtag_2a.c | 71 +++++++ .../aarch64/sve/acle/general-c/load_3.c | 2 +- .../aarch64/sve/acle/general-c/store_2.c | 2 +- .../acle/general-c/store_scatter_index_1.c | 2 +- .../store_scatter_index_restricted_1.c | 2 +- .../acle/general-c/store_scatter_offset_2.c | 2 +- .../store_scatter_offset_restricted_1.c | 2 +- 32 files changed, 483 insertions(+), 82 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/Wint-conversion-4.c create mode 100644 gcc/testsuite/gcc.dg/assign-warn-4.c create mode 100644 gcc/testsuite/gcc.dg/diagnostic-types-2.c create mode 100644 gcc/testsuite/gcc.dg/gomp/pr35738-2.c create mode 100644 gcc/testsuite/gcc.dg/param-type-mismatch-2.c create mode 100644 gcc/testsuite/gcc.dg/pr61162-3.c create mode 100644 gcc/testsuite/gcc.dg/spec-barrier-3a.c create mode 100644 gcc/testsuite/gcc.target/aarch64/acle/memtag_2a.c diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 1dbb4471a88..c7b35a27e3f 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -5450,8 +5450,9 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp, && (code2 == INTEGER_TYPE || code2 == BITINT_TYPE)) { if (!null_pointer_constant_p (orig_op2)) - pedwarn (colon_loc, OPT_Wint_conversion, - "pointer/integer type mismatch in conditional expression"); + permerror_opt (colon_loc, OPT_Wint_conversion, + "pointer/integer type mismatch " + "in conditional expression"); else { op2 = null_pointer_node; @@ -5462,8 +5463,9 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp, && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE)) { if (!null_pointer_constant_p (orig_op1)) - pedwarn (colon_loc, OPT_Wint_conversion, - "pointer/integer type mismatch in conditional expression"); + permerror_opt (colon_loc, OPT_Wint_conversion, + "pointer/integer type mismatch " + "in conditional expression"); else { op1 = null_pointer_node; @@ -6559,28 +6561,48 @@ error_init (location_t loc, const char *gmsgid, ...) inform (loc, "(near initialization for %qs)", ofwhat); } -/* Issue a pedantic warning for a bad initializer component. OPT is - the option OPT_* (from options.h) controlling this warning or 0 if - it is unconditionally given. GMSGID identifies the message. The - component name is taken from the spelling stack. */ +/* Used to implement pedwarn_init and permerror_init. */ static void ATTRIBUTE_GCC_DIAG (3,0) -pedwarn_init (location_t loc, int opt, const char *gmsgid, ...) +pedwarn_permerror_init (location_t loc, int opt, const char *gmsgid, + va_list *ap, diagnostic_t kind) { /* Use the location where a macro was expanded rather than where it was defined to make sure macros defined in system headers but used incorrectly elsewhere are diagnosed. */ location_t exploc = expansion_point_location_if_in_system_header (loc); auto_diagnostic_group d; - va_list ap; - va_start (ap, gmsgid); - bool warned = emit_diagnostic_valist (DK_PEDWARN, exploc, opt, gmsgid, &ap); - va_end (ap); + bool warned = emit_diagnostic_valist (kind, exploc, opt, gmsgid, ap); char *ofwhat = print_spelling ((char *) alloca (spelling_length () + 1)); if (*ofwhat && warned) inform (exploc, "(near initialization for %qs)", ofwhat); } +/* Issue a pedantic warning for a bad initializer component. OPT is + the option OPT_* (from options.h) controlling this warning or 0 if + it is unconditionally given. GMSGID identifies the message. The + component name is taken from the spelling stack. */ + +static void ATTRIBUTE_GCC_DIAG (3,0) +pedwarn_init (location_t loc, int opt, const char *gmsgid, ...) +{ + va_list ap; + va_start (ap, gmsgid); + pedwarn_permerror_init (loc, opt, gmsgid, &ap, DK_PEDWARN); + va_end (ap); +} + +/* Like pedwarn_init, but issue a permerror. */ + +static void ATTRIBUTE_GCC_DIAG (3,0) +permerror_init (location_t loc, int opt, const char *gmsgid, ...) +{ + va_list ap; + va_start (ap, gmsgid); + pedwarn_permerror_init (loc, opt, gmsgid, &ap, DK_PERMERROR); + va_end (ap); +} + /* Issue a warning for a bad initializer component. OPT is the OPT_W* value corresponding to the warning option that @@ -7630,27 +7652,28 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, auto_diagnostic_group d; range_label_for_type_mismatch rhs_label (rhstype, type); gcc_rich_location richloc (expr_loc, &rhs_label); - if (pedwarn (&richloc, OPT_Wint_conversion, - "passing argument %d of %qE makes pointer from " - "integer without a cast", parmnum, rname)) + if (permerror_opt (&richloc, OPT_Wint_conversion, + "passing argument %d of %qE makes pointer " + "from integer without a cast", parmnum, rname)) inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); } break; case ic_assign: - pedwarn (location, OPT_Wint_conversion, - "assignment to %qT from %qT makes pointer from integer " - "without a cast", type, rhstype); + permerror_opt (location, OPT_Wint_conversion, + "assignment to %qT from %qT makes pointer from " + "integer without a cast", type, rhstype); break; case ic_init: case ic_init_const: - pedwarn_init (location, OPT_Wint_conversion, - "initialization of %qT from %qT makes pointer from " - "integer without a cast", type, rhstype); + permerror_init (location, OPT_Wint_conversion, + "initialization of %qT from %qT makes pointer " + "from integer without a cast", type, rhstype); break; case ic_return: - pedwarn (location, OPT_Wint_conversion, "returning %qT from a " - "function with return type %qT makes pointer from " - "integer without a cast", rhstype, type); + permerror_init (location, OPT_Wint_conversion, + "returning %qT from a function with return type " + "%qT makes pointer from integer without a cast", + rhstype, type); break; default: gcc_unreachable (); @@ -7668,27 +7691,27 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, auto_diagnostic_group d; range_label_for_type_mismatch rhs_label (rhstype, type); gcc_rich_location richloc (expr_loc, &rhs_label); - if (pedwarn (&richloc, OPT_Wint_conversion, - "passing argument %d of %qE makes integer from " - "pointer without a cast", parmnum, rname)) + if (permerror_opt (&richloc, OPT_Wint_conversion, + "passing argument %d of %qE makes integer from " + "pointer without a cast", parmnum, rname)) inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); } break; case ic_assign: - pedwarn (location, OPT_Wint_conversion, - "assignment to %qT from %qT makes integer from pointer " - "without a cast", type, rhstype); + permerror_opt (location, OPT_Wint_conversion, + "assignment to %qT from %qT makes integer from " + "pointer without a cast", type, rhstype); break; case ic_init: case ic_init_const: - pedwarn_init (location, OPT_Wint_conversion, - "initialization of %qT from %qT makes integer from " - "pointer without a cast", type, rhstype); + permerror_init (location, OPT_Wint_conversion, + "initialization of %qT from %qT makes integer " + "from pointer without a cast", type, rhstype); break; case ic_return: - pedwarn (location, OPT_Wint_conversion, "returning %qT from a " - "function with return type %qT makes integer from " - "pointer without a cast", rhstype, type); + permerror_opt (location, OPT_Wint_conversion, "returning %qT from a " + "function with return type %qT makes integer from " + "pointer without a cast", rhstype, type); break; default: gcc_unreachable (); diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index c0b571327fb..753bc62f1d4 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -6181,6 +6181,7 @@ only by this flag, but it also downgrades some C and C++ diagnostics that have their own flag: @gccoptlist{ +-Wint-conversion @r{(C)} -Wnarrowing @r{(C++)} } @@ -8547,6 +8548,11 @@ conversions. This warning is about implicit conversions; for explicit conversions the warnings @option{-Wno-int-to-pointer-cast} and @option{-Wno-pointer-to-int-cast} may be used. +By default, in C99 and later dialects of C, GCC treats this issue as an +error. The error can be downgraded to a warning using +@option{-fpermissive} (along with certain other errors), or for this +error alone, with @option{-Wno-error=int-conversion}. + This warning is upgraded to an error by @option{-pedantic-errors}. @opindex Wzero-length-bounds diff --git a/gcc/testsuite/c-c++-common/pr77624-1.c b/gcc/testsuite/c-c++-common/pr77624-1.c index 3567e9b866f..e25469ee2c1 100644 --- a/gcc/testsuite/c-c++-common/pr77624-1.c +++ b/gcc/testsuite/c-c++-common/pr77624-1.c @@ -4,11 +4,11 @@ int foo (int a) { - return __atomic_is_lock_free (2, a); /* { dg-warning "pointer from integer" "" { target c } } */ + return __atomic_is_lock_free (2, a); /* { dg-error "pointer from integer" "" { target c } } */ } /* { dg-error "invalid conversion" "" { target c++ } .-1 } */ int bar (int a) { - return __atomic_always_lock_free (2, a); /* { dg-warning "pointer from integer" "" { target c } } */ + return __atomic_always_lock_free (2, a); /* { dg-error "pointer from integer" "" { target c } } */ } /* { dg-error "invalid conversion" "" { target c++ } .-1 } */ diff --git a/gcc/testsuite/gcc.dg/Wint-conversion-2.c b/gcc/testsuite/gcc.dg/Wint-conversion-2.c index bf590a7bcd7..101e792e5b6 100644 --- a/gcc/testsuite/gcc.dg/Wint-conversion-2.c +++ b/gcc/testsuite/gcc.dg/Wint-conversion-2.c @@ -1,7 +1,7 @@ /* PR middle-end/86202 - ICE in get_range_info calling an invalid memcpy() declaration */ /* { dg-do compile } */ -/* { dg-options "-Wint-conversion" } */ +/* { dg-options "-fpermissive -Wint-conversion" } */ void *memcpy (void *, void *, __SIZE_TYPE__ *); /* { dg-warning "conflicting types for built-in function .memcpy." } */ void *a, *b; diff --git a/gcc/testsuite/gcc.dg/Wint-conversion-3.c b/gcc/testsuite/gcc.dg/Wint-conversion-3.c index 4e514769c01..4614c015db4 100644 --- a/gcc/testsuite/gcc.dg/Wint-conversion-3.c +++ b/gcc/testsuite/gcc.dg/Wint-conversion-3.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "" } */ +/* { dg-options "-fpermissive" } */ const char * f1 (int flag) diff --git a/gcc/testsuite/gcc.dg/Wint-conversion-4.c b/gcc/testsuite/gcc.dg/Wint-conversion-4.c new file mode 100644 index 00000000000..6ded61aed9c --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wint-conversion-4.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +const char * +f1 (int flag) +{ + return flag ? "" : 1; /* { dg-error "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ +} + +const char * +f2 (int flag) +{ + return flag ? 1 : ""; /* { dg-error "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ +} diff --git a/gcc/testsuite/gcc.dg/assign-warn-1.c b/gcc/testsuite/gcc.dg/assign-warn-1.c index 365025724c4..c483276a913 100644 --- a/gcc/testsuite/gcc.dg/assign-warn-1.c +++ b/gcc/testsuite/gcc.dg/assign-warn-1.c @@ -1,7 +1,7 @@ /* Test diagnostics for bad implicit type conversions. */ /* Origin: Joseph Myers */ /* { dg-do compile } */ -/* { dg-options "-pedantic -ftrack-macro-expansion=0" } */ +/* { dg-options "-pedantic -fpermissive -ftrack-macro-expansion=0" } */ #define TESTARG(ID, TL, TR) void ID##F(TL); void ID##F2(TR x) { ID##F(x); } extern int dummy #define TESTARP(ID, TL, TR) struct { void (*x)(TL); } ID##Fp; void ID##F2(TR x) { ID##Fp.x(x); } extern int dummy diff --git a/gcc/testsuite/gcc.dg/assign-warn-4.c b/gcc/testsuite/gcc.dg/assign-warn-4.c new file mode 100644 index 00000000000..da834f7d29d --- /dev/null +++ b/gcc/testsuite/gcc.dg/assign-warn-4.c @@ -0,0 +1,21 @@ +/* Test diagnostics for bad implicit type conversions. Error variant. */ +/* { dg-do compile } */ +/* { dg-options "-ftrack-macro-expansion=0" } */ + +#define TESTARG(ID, TL, TR) void ID##F(TL); void ID##F2(TR x) { ID##F(x); } extern int dummy +#define TESTARP(ID, TL, TR) struct { void (*x)(TL); } ID##Fp; void ID##F2(TR x) { ID##Fp.x(x); } extern int dummy +#define TESTASS(ID, TL, TR) void ID##F(TR x) { TL y; y = x; } extern int dummy +#define TESTINI(ID, TL, TR) void ID##F(TR x) { TL y = x; } extern int dummy +#define TESTRET(ID, TL, TR) TR ID##V; TL ID##F(void) { return ID##V; } extern int dummy + +TESTARG(ciia, char *, int); /* { dg-error "passing argument 1 of 'ciiaF' makes pointer from integer without a cast" } */ +TESTARP(ciib, char *, int); /* { dg-error "passing argument 1 of 'ciibFp.x' makes pointer from integer without a cast" } */ +TESTASS(ciic, char *, int); /* { dg-error "assignment to 'char \\*' from 'int' makes pointer from integer without a cast" } */ +TESTINI(ciid, char *, int); /* { dg-error "initialization of 'char \\*' from 'int' makes pointer from integer without a cast" } */ +TESTRET(ciie, char *, int); /* { dg-error "returning 'int' from a function with return type 'char \\*' makes pointer from integer without a cast" } */ + +TESTARG(iica, int, char *); /* { dg-error "passing argument 1 of 'iicaF' makes integer from pointer without a cast" } */ +TESTARP(iicb, int, char *); /* { dg-error "passing argument 1 of 'iicbFp.x' makes integer from pointer without a cast" } */ +TESTASS(iicc, int, char *); /* { dg-error "assignment to 'int' from 'char \\*' makes integer from pointer without a cast" } */ +TESTINI(iicd, int, char *); /* { dg-error "initialization of 'int' from 'char \\*' makes integer from pointer without a cast" } */ +TESTRET(iice, int, char *); /* { dg-error "returning 'char \\*' from a function with return type 'int' makes integer from pointer without a cast" } */ diff --git a/gcc/testsuite/gcc.dg/diagnostic-types-1.c b/gcc/testsuite/gcc.dg/diagnostic-types-1.c index fc4b104df05..94b67c6ae8d 100644 --- a/gcc/testsuite/gcc.dg/diagnostic-types-1.c +++ b/gcc/testsuite/gcc.dg/diagnostic-types-1.c @@ -1,6 +1,6 @@ /* PR c/81233 */ /* { dg-do compile } */ -/* { dg-options "-Wc++-compat -Wpedantic" } */ +/* { dg-options "-fpermissive -Wc++-compat -Wpedantic" } */ /* Test we're printing the types, like the good compiler we are. */ enum E1 { A } e; diff --git a/gcc/testsuite/gcc.dg/diagnostic-types-2.c b/gcc/testsuite/gcc.dg/diagnostic-types-2.c new file mode 100644 index 00000000000..e6d284d2c5f --- /dev/null +++ b/gcc/testsuite/gcc.dg/diagnostic-types-2.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-Wpedantic" } */ +/* Test we're printing the types, like the good compiler we are. */ + +extern void foo2 (int *); /* { dg-message "expected 'int \\*' but argument is of type 'int'" } */ +extern void foo3 (int); /* { dg-message "expected 'int' but argument is of type 'int \\*'" } */ + +int * +fn1 (int *p) +{ + p = 1; /* { dg-error "assignment to 'int \\*' from 'int' makes pointer from integer without a cast" } */ + int *q = 1; /* { dg-error "initialization of 'int \\*' from 'int' makes pointer from integer without a cast" } */ + foo2 (1); /* { dg-error "passing argument 1 of 'foo2' makes pointer from integer without a cast" } */ + return 1; /* { dg-error "returning 'int' from a function with return type 'int \\*' makes pointer from integer without a cast" } */ +} + +int +fn2 (int i, int *p) +{ + i = p; /* { dg-error "assignment to 'int' from 'int \\*' makes integer from pointer without a cast" } */ + int j = p; /* { dg-error "initialization of 'int' from 'int \\*' makes integer from pointer without a cast" } */ + foo3 (p); /* { dg-error "passing argument 1 of 'foo3' makes integer from pointer without a cast" } */ + return p; /* { dg-error "returning 'int \\*' from a function with return type 'int' makes integer from pointer without a cast" } */ +} diff --git a/gcc/testsuite/gcc.dg/gomp/pr35738-2.c b/gcc/testsuite/gcc.dg/gomp/pr35738-2.c new file mode 100644 index 00000000000..846afe7e778 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/pr35738-2.c @@ -0,0 +1,18 @@ +/* PR c/35738 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp" } */ + +void foo (void); + +void +bar (void *p) +{ + int i = 0; + char q[10]; +#pragma omp atomic + i += q; /* { dg-error "makes integer from pointer without a cast" } */ +#pragma omp atomic + i += foo; /* { dg-error "makes integer from pointer without a cast" } */ +#pragma omp atomic + i += p; /* { dg-error "makes integer from pointer without a cast" } */ +} diff --git a/gcc/testsuite/gcc.dg/gomp/pr35738.c b/gcc/testsuite/gcc.dg/gomp/pr35738.c index 0b3866eae3b..954cfa43ece 100644 --- a/gcc/testsuite/gcc.dg/gomp/pr35738.c +++ b/gcc/testsuite/gcc.dg/gomp/pr35738.c @@ -1,6 +1,6 @@ /* PR c/35738 */ /* { dg-do compile } */ -/* { dg-options "-fopenmp" } */ +/* { dg-options "-fpermissive -fopenmp" } */ void foo (void); diff --git a/gcc/testsuite/gcc.dg/init-excess-3.c b/gcc/testsuite/gcc.dg/init-excess-3.c index c03a98487b4..6ea7858a1c9 100644 --- a/gcc/testsuite/gcc.dg/init-excess-3.c +++ b/gcc/testsuite/gcc.dg/init-excess-3.c @@ -7,9 +7,9 @@ char s0[] = {"abc",1}; /* { dg-error "'char..' initializer|near init" } */ char s1[] = {"abc","a"}; /* { dg-error "'char..' initializer|near init" } */ char s2[] = {1,"abc"}; /* { dg-error "'char..' initializer|near init|computable at load time" } */ -/* { dg-warning "integer from pointer without a cast" "" { target *-*-* } .-1 } */ +/* { dg-error "integer from pointer without a cast" "" { target *-*-* } .-1 } */ char s3[5] = {"abc",1}; /* { dg-error "'char.5.' initializer|near init" } */ char s4[5] = {"abc","a"}; /* { dg-error "'char.5.' initializer|near init" } */ char s5[5] = {1,"abc"}; /* { dg-error "'char.5.' initializer|near init|computable at load time" } */ -/* { dg-warning "integer from pointer without a cast" "" { target *-*-* } .-1 } */ +/* { dg-error "integer from pointer without a cast" "" { target *-*-* } .-1 } */ diff --git a/gcc/testsuite/gcc.dg/overflow-warn-1.c b/gcc/testsuite/gcc.dg/overflow-warn-1.c index a9d9fbae148..90eb43b35e2 100644 --- a/gcc/testsuite/gcc.dg/overflow-warn-1.c +++ b/gcc/testsuite/gcc.dg/overflow-warn-1.c @@ -47,10 +47,10 @@ static int sc = INT_MAX + 1; /* { dg-warning "25:integer overflow in expression" constants. The third has the overflow in an unevaluated subexpression, so is a null pointer constant. */ void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ -/* { dg-warning "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-1 } */ +/* { dg-error "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-1 } */ void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */ /* { dg-error "initializer element is not constant" "constant" { target *-*-* } .-1 } */ -/* { dg-warning "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */ +/* { dg-error "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */ void *r = (1 ? 0 : INT_MAX+1); void diff --git a/gcc/testsuite/gcc.dg/overflow-warn-3.c b/gcc/testsuite/gcc.dg/overflow-warn-3.c index f64047795c7..a2ead836964 100644 --- a/gcc/testsuite/gcc.dg/overflow-warn-3.c +++ b/gcc/testsuite/gcc.dg/overflow-warn-3.c @@ -53,10 +53,10 @@ static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } subexpression, so is a null pointer constant. */ void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ /* { dg-warning "overflow in constant expression" "constant" { target *-*-* } .-1 } */ -/* { dg-warning "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */ +/* { dg-error "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */ void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */ /* { dg-error "initializer element is not constant" "constant" { target *-*-* } .-1 } */ -/* { dg-warning "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */ +/* { dg-error "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */ void *r = (1 ? 0 : INT_MAX+1); void diff --git a/gcc/testsuite/gcc.dg/param-type-mismatch-2.c b/gcc/testsuite/gcc.dg/param-type-mismatch-2.c new file mode 100644 index 00000000000..91d998437d1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/param-type-mismatch-2.c @@ -0,0 +1,187 @@ +/* { dg-options "-fdiagnostics-show-caret -Wpointer-sign" } */ + +/* A collection of calls where argument 2 is of the wrong type. + Like param-type-mismatch.c, but expecting errors. */ + +/* decl, with argname. */ + +extern int callee_1 (int one, const char *two, float three); /* { dg-line callee_1 } */ + +int test_1 (int first, int second, float third) +{ + return callee_1 (first, second, third); /* { dg-error "passing argument 2 of 'callee_1' makes pointer from integer without a cast" } */ + /* { dg-begin-multiline-output "" } + return callee_1 (first, second, third); + ^~~~~~ + | + int + { dg-end-multiline-output "" } */ + /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_1 } */ + /* { dg-begin-multiline-output "" } + extern int callee_1 (int one, const char *two, float three); + ~~~~~~~~~~~~^~~ + { dg-end-multiline-output "" } */ +} + +/* decl, without argname. */ + +extern int callee_2 (int, const char *, float); /* { dg-line callee_2 } */ + +int test_2 (int first, int second, float third) +{ + return callee_2 (first, second, third); /* { dg-error "passing argument 2 of 'callee_2' makes pointer from integer without a cast" } */ + /* { dg-begin-multiline-output "" } + return callee_2 (first, second, third); + ^~~~~~ + | + int + { dg-end-multiline-output "" } */ + /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_2 } */ + /* { dg-begin-multiline-output "" } + extern int callee_2 (int, const char *, float); + ^~~~~~~~~~~~ + { dg-end-multiline-output "" } */ +} + +/* defn, with argname. */ + +static int callee_3 (int one, const char *two, float three) /* { dg-line callee_3 } */ +{ + return callee_2 (one, two, three); +} + +int test_3 (int first, int second, float third) +{ + return callee_3 (first, second, third); // { dg-error "passing argument 2 of 'callee_3' makes pointer from integer without a cast" } + /* { dg-begin-multiline-output "" } + return callee_3 (first, second, third); + ^~~~~~ + | + int + { dg-end-multiline-output "" } */ + /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_3 } */ + /* { dg-begin-multiline-output "" } + static int callee_3 (int one, const char *two, float three) + ~~~~~~~~~~~~^~~ + { dg-end-multiline-output "" } */ +} + +/* Trivial decl, with argname. */ + +extern int callee_4 (int one, float two, float three); /* { dg-line callee_4 } */ + +int test_4 (int first, const char *second, float third) +{ + return callee_4 (first, second, third); /* { dg-error "incompatible type for argument 2 of 'callee_4'" } */ + /* { dg-begin-multiline-output "" } + return callee_4 (first, second, third); + ^~~~~~ + | + const char * + { dg-end-multiline-output "" } */ + /* { dg-message "expected 'float' but argument is of type 'const char \\*'" "" { target *-*-* } callee_4 } */ + /* { dg-begin-multiline-output "" } + extern int callee_4 (int one, float two, float three); + ~~~~~~^~~ + { dg-end-multiline-output "" } */ +} + +/* Trivial decl, without argname. */ + +extern int callee_5 (int, float, float); /* { dg-line callee_5 } */ + +int test_5 (int first, const char *second, float third) +{ + return callee_5 (first, second, third); /* { dg-error "incompatible type for argument 2 of 'callee_5'" } */ + /* { dg-begin-multiline-output "" } + return callee_5 (first, second, third); + ^~~~~~ + | + const char * + { dg-end-multiline-output "" } */ + /* { dg-message "expected 'float' but argument is of type 'const char \\*'" "" { target *-*-* } callee_5 } */ + /* { dg-begin-multiline-output "" } + extern int callee_5 (int, float, float); + ^~~~~ + { dg-end-multiline-output "" } */ +} + +/* Callback with name. */ + +extern int callee_6 (int one, int (*two)(int, int), float three); /* { dg-line callee_6 } */ + +int test_6 (int first, int second, float third) +{ + return callee_6 (first, second, third); /* { dg-error "passing argument 2 of 'callee_6' makes pointer from integer without a cast" } */ + /* { dg-begin-multiline-output "" } + return callee_6 (first, second, third); + ^~~~~~ + | + int + { dg-end-multiline-output "" } */ + /* { dg-message " expected 'int \\(\\*\\)\\(int, int\\)' but argument is of type 'int'" "" { target *-*-* } callee_6 } */ + /* { dg-begin-multiline-output "" } + extern int callee_6 (int one, int (*two)(int, int), float three); + ~~~~~~^~~~~~~~~~~~~~ + { dg-end-multiline-output "" } */ +} + +/* Callback without name. */ + +extern int callee_7 (int one, int (*)(int, int), float three); /* { dg-line callee_7 } */ + +int test_7 (int first, int second, float third) +{ + return callee_7 (first, second, third); /* { dg-error "passing argument 2 of 'callee_7' makes pointer from integer without a cast" } */ + /* { dg-begin-multiline-output "" } + return callee_7 (first, second, third); + ^~~~~~ + | + int + { dg-end-multiline-output "" } */ + /* { dg-message " expected 'int \\(\\*\\)\\(int, int\\)' but argument is of type 'int'" "" { target *-*-* } callee_7 } */ + /* { dg-begin-multiline-output "" } + extern int callee_7 (int one, int (*)(int, int), float three); + ^~~~~~~~~~~~~~~~~ + { dg-end-multiline-output "" } */ +} + +/* -Wincompatible-pointer-types for a parameter. */ + +extern int callee_8 (int one, float *two, float (three)); /* { dg-line callee_8 } */ + +int test_8 (int first, int *second, float third) +{ + return callee_8 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_8' from incompatible pointer type" } */ + /* { dg-begin-multiline-output "" } + return callee_8 (first, second, third); + ^~~~~~ + | + int * + { dg-end-multiline-output "" } */ + /* { dg-message "expected 'float \\*' but argument is of type 'int \\*'" "" { target *-*-* } callee_8 } */ + /* { dg-begin-multiline-output "" } + extern int callee_8 (int one, float *two, float (three)); + ~~~~~~~^~~ + { dg-end-multiline-output "" } */ +} + +/* -Wpointer-sign for a parameter. */ + +extern int callee_9 (int one, int *two, float (three)); /* { dg-line callee_9 } */ + +int test_9 (int first, unsigned int *second, float third) +{ + return callee_9 (first, second, third); /* { dg-warning "pointer targets in passing argument 2 of 'callee_9' differ in signedness" } */ + /* { dg-begin-multiline-output "" } + return callee_9 (first, second, third); + ^~~~~~ + | + unsigned int * + { dg-end-multiline-output "" } */ + /* { dg-message "expected 'int \\*' but argument is of type 'unsigned int \\*'" "" { target *-*-* } callee_9 } */ + /* { dg-begin-multiline-output "" } + extern int callee_9 (int one, int *two, float (three)); + ~~~~~^~~ + { dg-end-multiline-output "" } */ +} diff --git a/gcc/testsuite/gcc.dg/param-type-mismatch.c b/gcc/testsuite/gcc.dg/param-type-mismatch.c index 9e654a9e9c6..f6d68749cd8 100644 --- a/gcc/testsuite/gcc.dg/param-type-mismatch.c +++ b/gcc/testsuite/gcc.dg/param-type-mismatch.c @@ -1,4 +1,4 @@ -/* { dg-options "-fdiagnostics-show-caret -Wpointer-sign" } */ +/* { dg-options "-fpermissive -fdiagnostics-show-caret -Wpointer-sign" } */ /* A collection of calls where argument 2 is of the wrong type. */ diff --git a/gcc/testsuite/gcc.dg/permerror-default.c b/gcc/testsuite/gcc.dg/permerror-default.c index ea0be1dc89f..5235a427175 100644 --- a/gcc/testsuite/gcc.dg/permerror-default.c +++ b/gcc/testsuite/gcc.dg/permerror-default.c @@ -26,26 +26,26 @@ int * int_conversion_1 (int flag) { void f2 (int *); - flag ? "1" : 1; /* { dg-warning "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ - flag ? 1 : "1"; /* { dg-warning "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ - f2 (flag); /* { dg-warning "passing argument 1 of 'f2' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + flag ? "1" : 1; /* { dg-error "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ + flag ? 1 : "1"; /* { dg-error "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ + f2 (flag); /* { dg-error "passing argument 1 of 'f2' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ { - int i1 = &flag; /* { dg-warning "initialization of 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ - i1 = &flag; /* { dg-warning "assignment to 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + int i1 = &flag; /* { dg-error "initialization of 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + i1 = &flag; /* { dg-error "assignment to 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ } - return flag; /* { dg-warning "returning 'int' from a function with return type 'int \\\*' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + return flag; /* { dg-error "returning 'int' from a function with return type 'int \\\*' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ } int int_conversion_2 (int flag) { void f3 (int); - f3 (&flag); /* { dg-warning "passing argument 1 of 'f3' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + f3 (&flag); /* { dg-error "passing argument 1 of 'f3' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ { - int *i1 = flag; /* { dg-warning "initialization of 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ - i1 = flag; /* { dg-warning "assignment to 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + int *i1 = flag; /* { dg-error "initialization of 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + i1 = flag; /* { dg-error "assignment to 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ } - return &flag; /* { dg-warning "returning 'int \\\*' from a function with return type 'int' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + return &flag; /* { dg-error "returning 'int \\\*' from a function with return type 'int' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ } int * diff --git a/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c b/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c index 6d42bc61d5c..0780e42b5cc 100644 --- a/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c +++ b/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c @@ -26,26 +26,26 @@ int * int_conversion_1 (int flag) { void f2 (int *); - flag ? "1" : 1; /* { dg-warning "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ - flag ? 1 : "1"; /* { dg-warning "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ - f2 (flag); /* { dg-warning "passing argument 1 of 'f2' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + flag ? "1" : 1; /* { dg-error "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ + flag ? 1 : "1"; /* { dg-error "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" } */ + f2 (flag); /* { dg-error "passing argument 1 of 'f2' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ { - int i1 = &flag; /* { dg-warning "initialization of 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ - i1 = &flag; /* { dg-warning "assignment to 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + int i1 = &flag; /* { dg-error "initialization of 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + i1 = &flag; /* { dg-error "assignment to 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ } - return flag; /* { dg-warning "returning 'int' from a function with return type 'int \\\*' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + return flag; /* { dg-error "returning 'int' from a function with return type 'int \\\*' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ } int int_conversion_2 (int flag) { void f3 (int); - f3 (&flag); /* { dg-warning "passing argument 1 of 'f3' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + f3 (&flag); /* { dg-error "passing argument 1 of 'f3' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ { - int *i1 = flag; /* { dg-warning "initialization of 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ - i1 = flag; /* { dg-warning "assignment to 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + int *i1 = flag; /* { dg-error "initialization of 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ + i1 = flag; /* { dg-error "assignment to 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" } */ } - return &flag; /* { dg-warning "returning 'int \\\*' from a function with return type 'int' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ + return &flag; /* { dg-error "returning 'int \\\*' from a function with return type 'int' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" } */ } int * diff --git a/gcc/testsuite/gcc.dg/permerror-system.c b/gcc/testsuite/gcc.dg/permerror-system.c index e6a978e494d..75e08887ef1 100644 --- a/gcc/testsuite/gcc.dg/permerror-system.c +++ b/gcc/testsuite/gcc.dg/permerror-system.c @@ -6,4 +6,15 @@ expected. */ #include -/* These errors come from permerror-default.c. No errors yet. */ +/* These errors come from permerror-default.c. */ + +/* { dg-error "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" "" { target *-*-* } 29 } */ +/* { dg-error "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" "" { target *-*-* } 30 } */ +/* { dg-error "passing argument 1 of 'f2' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" "" { target *-*-* } 31 } */ +/* { dg-error "initialization of 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" "" { target *-*-* } 33 } */ +/* { dg-error "assignment to 'int' from 'int \\\*' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" "" { target *-*-* } 34 } */ +/* { dg-error "returning 'int' from a function with return type 'int \\\*' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" "" { target *-*-* } 36 } */ +/* { dg-error "passing argument 1 of 'f3' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" "" { target *-*-* } 43 } */ +/* { dg-error "initialization of 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" "" { target *-*-* } 45 } */ +/* { dg-error "assignment to 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" "" { target *-*-* } 46 } */ +/* { dg-error "returning 'int \\\*' from a function with return type 'int' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" "" { target *-*-* } 48 } */ diff --git a/gcc/testsuite/gcc.dg/pr61162-2.c b/gcc/testsuite/gcc.dg/pr61162-2.c index 4aa8493d1a3..a7d0b45a310 100644 --- a/gcc/testsuite/gcc.dg/pr61162-2.c +++ b/gcc/testsuite/gcc.dg/pr61162-2.c @@ -1,6 +1,6 @@ /* PR c/61162 */ /* { dg-do compile } */ -/* { dg-options "-Wc++-compat -Wpointer-sign -Wpedantic" } */ +/* { dg-options "-fpermissive -Wc++-compat -Wpointer-sign -Wpedantic" } */ enum e { A }; struct s { int a; }; diff --git a/gcc/testsuite/gcc.dg/pr61162-3.c b/gcc/testsuite/gcc.dg/pr61162-3.c new file mode 100644 index 00000000000..c48625797d8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr61162-3.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +int +fn4 (int *a) +{ + return a; /* { dg-error "10:returning 'int \\*' from a function with return type 'int' makes integer from pointer without a cast" } */ +} + +int * +fn5 (int a) +{ + return a; /* { dg-error "10:returning 'int' from a function with return type 'int \\*' makes pointer from integer without a cast" } */ +} diff --git a/gcc/testsuite/gcc.dg/spec-barrier-3.c b/gcc/testsuite/gcc.dg/spec-barrier-3.c index 3ed4d39061a..0940a2105c6 100644 --- a/gcc/testsuite/gcc.dg/spec-barrier-3.c +++ b/gcc/testsuite/gcc.dg/spec-barrier-3.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-Wpedantic" } */ +/* { dg-options "-fpermissive -Wpedantic" } */ /* __builtin_speculation_safe_value returns a value with the same type as its first argument. There should be a warning if that isn't diff --git a/gcc/testsuite/gcc.dg/spec-barrier-3a.c b/gcc/testsuite/gcc.dg/spec-barrier-3a.c new file mode 100644 index 00000000000..ee98ad0ca50 --- /dev/null +++ b/gcc/testsuite/gcc.dg/spec-barrier-3a.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-Wpedantic" } */ + +/* __builtin_speculation_safe_value returns a value with the same type + as its first argument. There should be an error if that isn't + type-compatible with the use. */ +int * +f (int x) +{ + return __builtin_speculation_safe_value (x); /* { dg-error "returning 'int' from a function with return type 'int \\*' makes pointer from integer without a cast" } */ +} + +/* { dg-prune-output "this target does not define a speculation barrier;" } */ diff --git a/gcc/testsuite/gcc.target/aarch64/acle/memtag_2.c b/gcc/testsuite/gcc.target/aarch64/acle/memtag_2.c index fcab05b7abe..806e0750fd1 100644 --- a/gcc/testsuite/gcc.target/aarch64/acle/memtag_2.c +++ b/gcc/testsuite/gcc.target/aarch64/acle/memtag_2.c @@ -2,7 +2,7 @@ /* { dg-do compile } */ /* { dg-require-effective-target lp64 } */ -/* { dg-options "-O3 -march=armv8.5-a+memtag" } */ +/* { dg-options "-fpermissive -O3 -march=armv8.5-a+memtag" } */ #include "arm_acle.h" @@ -67,4 +67,4 @@ test_memtag_error_argument (void) __arm_mte_ptrdiff(no_decl2, 0); /* { dg-error {} } */ __arm_mte_ptrdiff(0); /* { dg-error {} } */ __arm_mte_ptrdiff(); /* { dg-error {} } */ -} \ No newline at end of file +} diff --git a/gcc/testsuite/gcc.target/aarch64/acle/memtag_2a.c b/gcc/testsuite/gcc.target/aarch64/acle/memtag_2a.c new file mode 100644 index 00000000000..16db40df663 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/acle/memtag_2a.c @@ -0,0 +1,71 @@ +/* Test the MEMTAG intrinsic qualifier warnings and argument errors. */ + +/* { dg-do compile } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O3 -march=armv8.5-a+memtag" } */ + +#include "arm_acle.h" + +void +test_memtag_warning_return_qualifier (void) +{ + const char *c; + volatile char *v; + char *n; + int *i; + int64_t d; + + v = __arm_mte_get_tag(c); /* { dg-warning {assignment} } */ + n = __arm_mte_get_tag(c); /* { dg-warning {assignment} } */ + i = __arm_mte_get_tag(c); /* { dg-warning {assignment} } */ + c = __arm_mte_get_tag(v); /* { dg-warning {assignment} } */ + n = __arm_mte_get_tag(v); /* { dg-warning {assignment} } */ + + i = __arm_mte_create_random_tag (c, 0); /* { dg-warning {assignment} } */ + i = __arm_mte_increment_tag (c, 0); /* { dg-warning {assignment} } */ + + c = __arm_mte_get_tag(n); /* No warning. */ + d = __arm_mte_ptrdiff(c, i); /* No warning. */ +} + +void +test_memtag_warning_argument (void) +{ + const char *c; + __arm_mte_exclude_tag(0, 0); /* No warning. */ + __arm_mte_create_random_tag (0, 0); /* No warning. */ + __arm_mte_set_tag(0); /* No warning. */ + __arm_mte_get_tag(0); /* No warning. */ + __arm_mte_increment_tag (0, 15); /* No warning. */ + __arm_mte_ptrdiff(c, 0); /* No warning. */ + __arm_mte_ptrdiff(0, c); /* No warning. */ +} + +void +test_memtag_error_argument (void) +{ + /* Produce errors properly for invalid arguments. */ + __arm_mte_exclude_tag(no_decl, 0); /* { dg-error {} } */ + __arm_mte_exclude_tag(); /* { dg-error {} } */ + __arm_mte_ptrdiff(no_decl2, 0); /* { dg-error {} } */ + __arm_mte_ptrdiff(0); /* { dg-error {} } */ + __arm_mte_ptrdiff(); /* { dg-error {} } */ + + const char *c; + uint64_t i; + __arm_mte_exclude_tag(i, 0); /* { dg-error {argument} } */ + __arm_mte_create_random_tag (i, 0); /* { dg-error {argument} } */ + __arm_mte_set_tag(i); /* { dg-error {argument} } */ + __arm_mte_get_tag(i); /* { dg-error {argument} } */ + __arm_mte_increment_tag (i, 15); /* { dg-error {argument} } */ + __arm_mte_ptrdiff(c, i); /* { dg-error {argument} } */ + __arm_mte_ptrdiff(i, c); /* { dg-error {argument} } */ + + __arm_mte_exclude_tag(1, 0); /* { dg-error {argument} } */ + __arm_mte_create_random_tag (1, 0); /* { dg-error {argument} } */ + __arm_mte_set_tag(1); /* { dg-error {argument} } */ + __arm_mte_get_tag(1); /* { dg-error {argument} } */ + __arm_mte_increment_tag (1, 15); /* { dg-error {argument} } */ + __arm_mte_ptrdiff(c, 1); /* { dg-error {argument} } */ + __arm_mte_ptrdiff(1, c); /* { dg-error {argument} } */ +} diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_3.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_3.c index 770203f64c8..34166395ecc 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_3.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_3.c @@ -13,6 +13,6 @@ f1 (svbool_t pg, signed char *s8_ptr, svint8_t s8) svld1_vnum (pg, s8_ptr, 0, 0); /* { dg-error {too many arguments to function 'svld1_vnum'} } */ svld1_vnum (0, s8_ptr, 0); /* { dg-error {passing 'int' to argument 1 of 'svld1_vnum', which expects 'svbool_t'} } */ svld1_vnum (pg, 0, 0); /* { dg-error {passing 'int' to argument 2 of 'svld1_vnum', which expects a pointer type} } */ - svld1_vnum (pg, s8_ptr, s8_ptr); /* { dg-warning "passing argument 3 of 'svld1_vnum_s8' makes integer from pointer without a cast" } */ + svld1_vnum (pg, s8_ptr, s8_ptr); /* { dg-error "passing argument 3 of 'svld1_vnum_s8' makes integer from pointer without a cast" } */ svld1_vnum (pg, s8_ptr, s8); /* { dg-error {passing 'svint8_t' to argument 3 of 'svld1_vnum', which expects 'int64_t'} } */ } diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_2.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_2.c index c718b3ee04e..669f8844bc1 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_2.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_2.c @@ -14,7 +14,7 @@ f1 (svbool_t pg, signed char *s8_ptr, void *void_ptr, struct s *s_ptr, svst1_vnum (0, s8_ptr, 0, s8); /* { dg-error {passing 'int' to argument 1 of 'svst1_vnum', which expects 'svbool_t'} } */ svst1_vnum (pg, s8_ptr, pg, s8); /* { dg-error {passing 'svbool_t' to argument 3 of 'svst1_vnum', which expects 'int64_t'} } */ svst1_vnum (pg, s8_ptr, s8, s8); /* { dg-error {passing 'svint8_t' to argument 3 of 'svst1_vnum', which expects 'int64_t'} } */ - svst1_vnum (pg, s8_ptr, void_ptr, s8); /* { dg-warning "passing argument 3 of 'svst1_vnum_s8' makes integer from pointer without a cast" } */ + svst1_vnum (pg, s8_ptr, void_ptr, s8); /* { dg-error "passing argument 3 of 'svst1_vnum_s8' makes integer from pointer without a cast" } */ svst1_vnum (pg, void_ptr, 0, 0); /* { dg-error {passing 'int' to argument 4 of 'svst1_vnum', which expects an SVE vector type} } */ svst1_vnum (pg, void_ptr, 0, pg); /* { dg-error {'svst1_vnum' has no form that takes 'svbool_t' arguments} } */ svst1_vnum (pg, 0, 0, s8); diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_index_1.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_index_1.c index 89528237522..29f4510c49b 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_index_1.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_index_1.c @@ -26,7 +26,7 @@ f1 (svbool_t pg, signed char *s8_ptr, short *s16_ptr, svst1_scatter_index (pg, cf32_ptr, s32, f32); /* { dg-warning "passing argument 2 of 'svst1_scatter_s32index_f32' from incompatible pointer type" } */ svst1_scatter_index (pg, s, s32, s32); /* { dg-error {passing 'struct s' to argument 2 of 'svst1_scatter_index', which expects a vector or pointer base address} } */ - svst1_scatter_index (pg, u32, void_ptr, s32); /* { dg-warning "passing argument 3 of 'svst1_scatter_u32base_index_s32' makes integer from pointer without a cast" } */ + svst1_scatter_index (pg, u32, void_ptr, s32); /* { dg-error "passing argument 3 of 'svst1_scatter_u32base_index_s32' makes integer from pointer without a cast" } */ svst1_scatter_index (pg, u32, pg, s32); /* { dg-error {passing 'svbool_t' to argument 3 of 'svst1_scatter_index', which expects 'int64_t'} } */ svst1_scatter_index (pg, u32, s32, s32); /* { dg-error {passing 'svint32_t' to argument 3 of 'svst1_scatter_index', which expects 'int64_t'} } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_index_restricted_1.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_index_restricted_1.c index 5e31362c412..ab718b5eeee 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_index_restricted_1.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_index_restricted_1.c @@ -28,7 +28,7 @@ f1 (svbool_t pg, signed char *s8_ptr, short *s16_ptr, svstnt1_scatter_index (pg, cf64_ptr, s64, f64); /* { dg-warning "passing argument 2 of 'svstnt1_scatter_s64index_f64' from incompatible pointer type" } */ svstnt1_scatter_index (pg, s, s64, s64); /* { dg-error {passing 'struct s' to argument 2 of 'svstnt1_scatter_index', which expects a vector or pointer base address} } */ - svstnt1_scatter_index (pg, u32, void_ptr, s32); /* { dg-warning "passing argument 3 of 'svstnt1_scatter_u32base_index_s32' makes integer from pointer without a cast" } */ + svstnt1_scatter_index (pg, u32, void_ptr, s32); /* { dg-error "passing argument 3 of 'svstnt1_scatter_u32base_index_s32' makes integer from pointer without a cast" } */ svstnt1_scatter_index (pg, u32, pg, s32); /* { dg-error {passing 'svbool_t' to argument 3 of 'svstnt1_scatter_index', which expects 'int64_t'} } */ svstnt1_scatter_index (pg, u32, s32, s32); /* { dg-error {passing 'svint32_t' to argument 3 of 'svstnt1_scatter_index', which expects 'int64_t'} } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_2.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_2.c index 4854818cae6..311b1744c91 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_2.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_2.c @@ -26,7 +26,7 @@ f1 (svbool_t pg, signed char *s8_ptr, short *s16_ptr, svst1_scatter_offset (pg, cf32_ptr, s32, f32); /* { dg-warning "passing argument 2 of 'svst1_scatter_s32offset_f32' from incompatible pointer type" } */ svst1_scatter_offset (pg, s, s32, s32); /* { dg-error {passing 'struct s' to argument 2 of 'svst1_scatter_offset', which expects a vector or pointer base address} } */ - svst1_scatter_offset (pg, u32, void_ptr, s32); /* { dg-warning "passing argument 3 of 'svst1_scatter_u32base_offset_s32' makes integer from pointer without a cast" } */ + svst1_scatter_offset (pg, u32, void_ptr, s32); /* { dg-error "passing argument 3 of 'svst1_scatter_u32base_offset_s32' makes integer from pointer without a cast" } */ svst1_scatter_offset (pg, u32, pg, s32); /* { dg-error {passing 'svbool_t' to argument 3 of 'svst1_scatter_offset', which expects 'int64_t'} } */ svst1_scatter_offset (pg, u32, s32, s32); /* { dg-error {passing 'svint32_t' to argument 3 of 'svst1_scatter_offset', which expects 'int64_t'} } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_restricted_1.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_restricted_1.c index 100624b7b03..5b251127a47 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_restricted_1.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_restricted_1.c @@ -28,7 +28,7 @@ f1 (svbool_t pg, signed char *s8_ptr, short *s16_ptr, svstnt1_scatter_offset (pg, cf32_ptr, u32, f32); /* { dg-warning "passing argument 2 of 'svstnt1_scatter_u32offset_f32' from incompatible pointer type" } */ svstnt1_scatter_offset (pg, s, u32, s32); /* { dg-error {passing 'struct s' to argument 2 of 'svstnt1_scatter_offset', which expects a vector or pointer base address} } */ - svstnt1_scatter_offset (pg, u32, void_ptr, s32); /* { dg-warning "passing argument 3 of 'svstnt1_scatter_u32base_offset_s32' makes integer from pointer without a cast" } */ + svstnt1_scatter_offset (pg, u32, void_ptr, s32); /* { dg-error "passing argument 3 of 'svstnt1_scatter_u32base_offset_s32' makes integer from pointer without a cast" } */ svstnt1_scatter_offset (pg, u32, pg, s32); /* { dg-error {passing 'svbool_t' to argument 3 of 'svstnt1_scatter_offset', which expects 'int64_t'} } */ svstnt1_scatter_offset (pg, u32, s32, s32); /* { dg-error {passing 'svint32_t' to argument 3 of 'svstnt1_scatter_offset', which expects 'int64_t'} } */ From patchwork Mon Nov 20 09:56:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 167020 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp2090093vqn; Mon, 20 Nov 2023 01:57:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IHKmW4JL3fPQzmG1R5S8pywzpCXSawh7dYs0aDGAK8RKD3qCPCdlxqFRFr0rySa867Ra77w X-Received: by 2002:a05:620a:268e:b0:779:e75d:e80e with SMTP id c14-20020a05620a268e00b00779e75de80emr8538771qkp.15.1700474245462; Mon, 20 Nov 2023 01:57:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700474245; cv=pass; d=google.com; s=arc-20160816; b=NYrEdC27hrnqeb1eITOPqJgfpw1yf+gRnVOsyi0pvYQaeND1vF6Swz3xPenQRHwmB0 WlmccJmcUpAMUrVJP7DAkq0R5gDRu8etcSfyXwEjwfBx0cSlWNY25bnheBGbcLbzoUVx 6Znn2mO7qbl86v7VNsxDSjV12IMqmiNZELHPwV+b9GA2th615He3QdGYfK2exbqPea8h GjtXrr71ozuKd5ReNthQTNHlEJA9XAfOoYjAS1HoLpnJ8o4yBdGbV5y1ZkzGnZNowwKy 68kOpGTvTETL/KPq106NcrGgkKMdcSC9+aD6TdXFMn0vA/iZ41b2nFKCMVo5cnKBZETc EaQA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent:date :references:message-id:in-reply-to:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=xMFbmhput7M4sFBH/m2oLpNzIgFM+j9VI0FaEmP5Plw=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=chqIF/EyhijFtdgoMNQmEHL98ff/BRiTDMOKM3kyHZY3FR0ywCDI8j1jQcNsVRQwkn NwO2X0EJTnd2YgqaK12u6lRjN/6nYyV8YQxg8D1MdqGh8OdhepBD9GopQM3W9piDhHKc M9fl7lUJq6yIDVFPIDr9y/0fIEqFMS8h47qLD5Xl7CoiEQymyH/d2Gkf5Czxb/4h2Afa IYFkl9PGDXNJfw8+HqRmQYYrtsUCZNPcvrmjz3Om28w5A8x1GACaqG21CbHtKp7sVuHP qG1mWxA5yA0RqnjVfFFvw17eeBzaerAebBjHGGDLgMEekDCA5kCOc+4PnmajJJw/Jyhx h8cg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NAhIOJRX; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ea25-20020a05620a489900b007757fdc191dsi7288046qkb.451.2023.11.20.01.57.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 01:57:25 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NAhIOJRX; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 86372388455F for ; Mon, 20 Nov 2023 09:57:11 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 299EC3882671 for ; Mon, 20 Nov 2023 09:56:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 299EC3882671 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 299EC3882671 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700474201; cv=none; b=ps1jNiDTe1pNIcPUyDgbgtDgql3npzvyER2ycw42fiNlQuLFLyRrZtAbiv6+PGGI7Qr1d81/EKz0N60Z0gjAX0hDOF0ystFyV1rXAVV1D3gDNqcILXT9uyQZuB2CsnpmPh8DYLlAD28uyR57TaGyU3x/ejsdKBpyq+Yby3B4+pg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700474201; c=relaxed/simple; bh=w0s4+nukiFMGifQwVnEBkvsSy2pycDjiob0WfjwFTzE=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=VRqu54Uss5tdVfovoxU/vvl56dOzQTb+k2bOeXdxWjgvbfDuGTaprbtusKhdJ592nkBN8CtBS4twroBSuTx8ts+CJRGcibwlM8qZb8CA1WtAwKTK50UcbUHIT2Sqc63+xezUEF3K3WP8SWVmAg1RO+eIa7QBPJAdUIoXYl5Yvio= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700474190; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xMFbmhput7M4sFBH/m2oLpNzIgFM+j9VI0FaEmP5Plw=; b=NAhIOJRX7e+yYpbmwrTl+nBOPOI6iOGQbOzpcSscouKv1H9XhsW6iKzfZUG3hXxPlkUaxS ASQ2ziSgRbzb2lAVciKfZ1dDxO/CQyno64bD56HK4MgNwRYA4Zf919KYIktTAKnCbjxniX NetaRH4ZeU28xzMQbn8vDVOXSTFRU/s= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-629-1BPIhBGBPi-n4cYe2xR10A-1; Mon, 20 Nov 2023 04:56:28 -0500 X-MC-Unique: 1BPIhBGBPi-n4cYe2xR10A-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8EBE01C06E31 for ; Mon, 20 Nov 2023 09:56:28 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ED48E492BFA for ; Mon, 20 Nov 2023 09:56:27 +0000 (UTC) From: Florian Weimer To: gcc-patches@gcc.gnu.org Subject: [PATCH v3 08/11] c: Do not ignore some forms of -Wimplicit-int in system headers In-Reply-To: Message-ID: <7b09c1315253d91868e0f4e95debb75c41a62873.1700473918.git.fweimer@redhat.com> References: X-From-Line: 7b09c1315253d91868e0f4e95debb75c41a62873 Mon Sep 17 00:00:00 2001 Date: Mon, 20 Nov 2023 10:56:26 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783076482439588433 X-GMAIL-MSGID: 1783076482439588433 Most -Wimplicit-int warnings were unconditionally disabled for system headers. Only missing types for parameters in old-style function definitions resulted in warnings. This is inconsistent with the treatment of other permerrors, which are active in system headers. gcc/c/ * c-decl.cc (grokdeclarator): Do not skip -Wimplicit-int warnings or errors in system headers. gcc/testsuite/ * gcc.dg/permerror-system.c: Expect all -Wimplicit-int permerrors. --- gcc/c/c-decl.cc | 2 +- gcc/testsuite/gcc.dg/permerror-system.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index 893e24f7dc6..d16958113a8 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -6845,7 +6845,7 @@ grokdeclarator (const struct c_declarator *declarator, /* Diagnose defaulting to "int". */ - if (declspecs->default_int_p && !in_system_header_at (input_location)) + if (declspecs->default_int_p) { /* Issue a warning if this is an ISO C 99 program or if -Wreturn-type and this is a function, or if -Wimplicit; diff --git a/gcc/testsuite/gcc.dg/permerror-system.c b/gcc/testsuite/gcc.dg/permerror-system.c index 60c65ffc1d4..cad48c93f90 100644 --- a/gcc/testsuite/gcc.dg/permerror-system.c +++ b/gcc/testsuite/gcc.dg/permerror-system.c @@ -10,7 +10,12 @@ /* { dg-error "'f1' \\\[-Wimplicit-function-declaration\\\]" "" { target *-*-* } 10 } */ +/* { dg-error "'implicit_int_1' \\\[-Wimplicit-int\\\]" "" { target *-*-* } 13 } */ +/* { dg-error "'implicit_int_2' \\\[-Wimplicit-int\\\]" "" { target *-*-* } 14 } */ +/* { dg-error "'implicit_int_3' \\\[-Wimplicit-int\\]" "" { target *-*-* } 15 } */ +/* { dg-error "return type defaults to 'int' \\\[-Wimplicit-int\\\]" "" { target *-*-* } 16 } */ /* { dg-error "type of 'i' defaults to 'int' \\\[-Wimplicit-int\\\]" "" { target *-*-*} 16 } */ +/* { dg-error "type defaults to 'int' in type name \\\[-Wimplicit-int\\\]" "" { target *-*-* } 19 } */ /* { dg-error "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" "" { target *-*-* } 29 } */ /* { dg-error "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" "" { target *-*-* } 30 } */ From patchwork Mon Nov 20 09:56:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 167023 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp2090441vqn; Mon, 20 Nov 2023 01:58:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IFlaZwXyLqhZnsIiEYeHCjZR23SiIqTF1XQ37VOgS8FQMMjsVz58d58VP/VtvFhksMDhBvT X-Received: by 2002:a05:6102:1174:b0:462:877d:ceb9 with SMTP id k20-20020a056102117400b00462877dceb9mr2174886vsg.32.1700474311705; Mon, 20 Nov 2023 01:58:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700474311; cv=pass; d=google.com; s=arc-20160816; b=LaGaEBmwXIzZhNc4Kt/iG8/gRoN+kzjQenVWCwRAmsM9lfK9yl4iMgvYKyl0+x4i4l jyQCQLOitxzCfdpibXrEgfooycnweFwne5uguKmpVwk78KikJhDft4ToRjvKIP7yW257 rtDLeXBWmvbIk3s9rf6uPHXOM1kQgrTI7rOm8Mvokgw945aS8C5reQzuy5mQwZwU2UbD PAG7haxVFtslOReNH6WSR9d/LbysygadRy10enRFV+EeI54qR7Yg+mZajugPdehz/anh D61EL7gyQBOXL1AqI3VcuFa2xNTQlljyLhmQgHHVIurnln7LhStTSBn8/Q7VIiNKYcnK yxng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent:date :references:message-id:in-reply-to:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=/F2YshU4vmrI/jv7QebiikBqWTma9ENOpWsu2rpc/Z4=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=u+31ykHQmRXqFgkHIhY40HgNeHaFLgFXv048DE0jLA3DK9PtDlE3bBsDpvpLMGNgNG DkHtnPCSkL3iXOOrqGckBEMNviO/x1434YA1GPjVPM2qAyCtAv+a9a34SyX2S0WqyxLH eJUwnKrtxNH8SM1wfwQ5nRVjqXBg+xiOgSVRGahqXSTF58LEgfMfO2QXqSvIjcsRi3mL 6Q5WuS84BeXyXYGTs2QueFZ4gkvF+IzFh+dkcGgPfgjJB8mFdrdNrnFE4YWSglayf7Ug cXOf4bf6U6stUGShwgmfoCDLbkkMUtR0pc/eQBdJcRP23q/l98fHI2PZsGLxr4G6wuDF XXzQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cDqM12l8; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id m2-20020a05620a214200b00773ae74632asi7098046qkm.604.2023.11.20.01.58.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 01:58:31 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cDqM12l8; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 127F73882643 for ; Mon, 20 Nov 2023 09:58:27 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 662133844741 for ; Mon, 20 Nov 2023 09:56:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 662133844741 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 662133844741 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700474202; cv=none; b=ezPBWqEmtpkEsPeK8wrbqY6dRGbvcFQ1PbV5Z+8El6k6Rnj8sC5MGYBJLp297BHfN+MHjYJZh2CyapmgcMEbM2oQY5tEZfCvlaZ7JLMxEYKTegx0Qb4LOl0wmUYqa32ki7si010XRi8rq5zPKyFsSGScmCyT2Dgws+bY7hxXVx4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700474202; c=relaxed/simple; bh=tJly3dqLAPMQ6iS/XxhPnJbfqp4/C93FWiuilioqkyU=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=vgz22BMHSbgMToFJTUanpD6xd/SzNYziD09AF5umgXYXG3zykF7y4nxRs74khSDIuFdv7Vp3ivM6lj1z+MW6OJrgIVmzWMEQlGxLEk5wRdgf0YmBM7h50g/SbB3eoQUcuKib8JDgWiNCvbIvkUypu4uTjvcXM7/Cr+nF2V95IQ0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700474195; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/F2YshU4vmrI/jv7QebiikBqWTma9ENOpWsu2rpc/Z4=; b=cDqM12l8s3U1E3IbHpeqfcvzL6ve9tTj6p0ad5JnpYQd+FJQlPL/Ome/S+DxWossRb6Jys cGEarW/1QE6zijPp+aqkNA/3VpZfMP9mGfYFfgHJe9mo5sYXHDrNsRBKUTB+yhHxlc8zKl BnnzsCwj6nrNcczcwO/fmOZRRBBPZx4= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-210-5enGr-s9PN2JYvRyND_v5Q-1; Mon, 20 Nov 2023 04:56:33 -0500 X-MC-Unique: 5enGr-s9PN2JYvRyND_v5Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4AAFD1C06ED8 for ; Mon, 20 Nov 2023 09:56:33 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D1C442026D4C for ; Mon, 20 Nov 2023 09:56:31 +0000 (UTC) From: Florian Weimer To: gcc-patches@gcc.gnu.org Subject: [PATCH v3 09/11] c: Turn -Wreturn-mismatch into a permerror In-Reply-To: Message-ID: <2a00ce2d44edbda185460d72519a879fbac9bf59.1700473918.git.fweimer@redhat.com> References: X-From-Line: 2a00ce2d44edbda185460d72519a879fbac9bf59 Mon Sep 17 00:00:00 2001 Date: Mon, 20 Nov 2023 10:56:30 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783076551874104924 X-GMAIL-MSGID: 1783076551874104924 gcc/ * doc/invoke.texi (Warning Options): Document changes. gcc/c/ PR c/96284 * c-typeck.cc (c_finish_return): Use permerrors for OPT_Wreturn_mismatch diagnostics. gcc/testsuite/ * gcc.dg/permerror-default.c (return_mismatch_1) (return_mismatch_2): Expect new permerror. * gcc.dg/permerror-gnu89-nopermissive.c (return_mismatch_1): Likewise. * gcc.dg/permerror-system.c: Likewise. * gcc.dg/20030906-1.c: Compile with -fpermissive due to expected -Wreturn-mismatch error. * gcc.dg/20030906-1a.c: New test. Copied from gcc.dg/20030906-1.c. Expect the error. * gcc.dg/20030906-2.c: Compile with -fpermissive due to expected -Wreturn-mismatch error. * gcc.dg/20030906-2a.c: New test. Copied from gcc.dg/20030906-2.c. Expect the error. * gcc.dg/Wreturn-mismatch-1.c: Compile with -fpermissive due to expected -Wreturn-mismatch error. * gcc.dg/Wreturn-mismatch-1a.c: New test. Copied from gcc.dg/Wreturn-mismatch-1.c. Expect the error. * gcc.dg/Wreturn-mismatch-2.c: Compile with -fpermissive due to expected -Wreturn-mismatch error. * gcc.dg/Wreturn-mismatch-2a.c: New test. Copied from gcc.dg/Wreturn-mismatch-2.c. Expect the error. * gcc.dg/diagnostic-range-bad-return.c: Compile with -fpermissive due to expected -Wreturn-mismatch error. * gcc.dg/diagnostic-range-bad-return-2.c: New test. Copied from gcc.dg/diagnostic-range-bad-return.c. Expect the error. * gcc.dg/pr105635-2.c: Expect -Wreturn-mismatch error. * gcc.dg/pr23075.c: Build with -fpermissive due to expected -Wreturn-mismatch error. * gcc.dg/pr23075-2.c: New test. Copied from gcc.dg/pr23075.c. Expect the error. * gcc.dg/pr29521.c: Compile with -fpermissive due to expected -Wreturn-mismatch error. * gcc.dg/pr29521-a.c: New test. Copied from gcc.dg/pr29521.c. Expect error. * gcc.dg/pr67730.c: Compile with -fpermissive due to expected -Wreturn-mismatch error. * gcc.dg/pr67730-a.c: New test. Copied from gcc.dg/pr67730-a.c. Expect error. * gcc.target/powerpc/conditional-return.c: Compile with -fpermissive due to expected -Wreturn-mismatch error. --- gcc/c/c-typeck.cc | 4 +- gcc/doc/invoke.texi | 6 ++- gcc/testsuite/gcc.dg/20030906-1.c | 2 +- gcc/testsuite/gcc.dg/20030906-1a.c | 21 ++++++++ gcc/testsuite/gcc.dg/20030906-2.c | 2 +- gcc/testsuite/gcc.dg/20030906-2a.c | 21 ++++++++ gcc/testsuite/gcc.dg/Wreturn-mismatch-1.c | 2 +- gcc/testsuite/gcc.dg/Wreturn-mismatch-1a.c | 40 ++++++++++++++ gcc/testsuite/gcc.dg/Wreturn-mismatch-2.c | 2 +- gcc/testsuite/gcc.dg/Wreturn-mismatch-2a.c | 41 +++++++++++++++ .../gcc.dg/diagnostic-range-bad-return-2.c | 52 +++++++++++++++++++ .../gcc.dg/diagnostic-range-bad-return.c | 2 +- gcc/testsuite/gcc.dg/permerror-default.c | 4 +- .../gcc.dg/permerror-gnu89-nopermissive.c | 2 +- gcc/testsuite/gcc.dg/permerror-system.c | 3 ++ gcc/testsuite/gcc.dg/pr105635-2.c | 2 +- gcc/testsuite/gcc.dg/pr23075-2.c | 14 +++++ gcc/testsuite/gcc.dg/pr23075.c | 2 +- gcc/testsuite/gcc.dg/pr29521-a.c | 15 ++++++ gcc/testsuite/gcc.dg/pr29521.c | 2 +- gcc/testsuite/gcc.dg/pr67730-a.c | 11 ++++ gcc/testsuite/gcc.dg/pr67730.c | 2 +- .../gcc.target/powerpc/conditional-return.c | 2 +- 23 files changed, 238 insertions(+), 16 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/20030906-1a.c create mode 100644 gcc/testsuite/gcc.dg/20030906-2a.c create mode 100644 gcc/testsuite/gcc.dg/Wreturn-mismatch-1a.c create mode 100644 gcc/testsuite/gcc.dg/Wreturn-mismatch-2a.c create mode 100644 gcc/testsuite/gcc.dg/diagnostic-range-bad-return-2.c create mode 100644 gcc/testsuite/gcc.dg/pr23075-2.c create mode 100644 gcc/testsuite/gcc.dg/pr29521-a.c create mode 100644 gcc/testsuite/gcc.dg/pr67730-a.c diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index c7b35a27e3f..f4b700117ff 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -11205,7 +11205,7 @@ c_finish_return (location_t loc, tree retval, tree origtype) && valtype != NULL_TREE && TREE_CODE (valtype) != VOID_TYPE) { no_warning = true; - if (emit_diagnostic (flag_isoc99 ? DK_PEDWARN : DK_WARNING, + if (emit_diagnostic (flag_isoc99 ? DK_PERMERROR : DK_WARNING, loc, OPT_Wreturn_mismatch, "% with no value," " in function returning non-void")) @@ -11218,7 +11218,7 @@ c_finish_return (location_t loc, tree retval, tree origtype) current_function_returns_null = 1; bool warned_here; if (TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE) - warned_here = pedwarn + warned_here = permerror_opt (xloc, OPT_Wreturn_mismatch, "% with a value, in function returning void"); else diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index eb7417fd9be..831242d134b 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -6185,6 +6185,7 @@ that have their own flag: -Wimplicit-int @r{(C)} -Wint-conversion @r{(C)} -Wnarrowing @r{(C++)} +-Wreturn-mismatch @r{(C)} } The @option{-fpermissive} option is the default for historic C language @@ -7375,7 +7376,10 @@ Attempting to use the return value of a non-@code{void} function other than @code{main} that flows off the end by reaching the closing curly brace that terminates the function is undefined. -This warning is specific to C and enabled by default. +This warning is specific to C and enabled by default. In C99 and later +language dialects, it is treated as an error. It an be downgraded +to a warning using @option{-fpermissive} (along with other warnings), +or for just this warning, with @option{-Wno-error=return-mismatch}. @opindex Wreturn-type @opindex Wno-return-type diff --git a/gcc/testsuite/gcc.dg/20030906-1.c b/gcc/testsuite/gcc.dg/20030906-1.c index c416f55ee75..6ba5b3d770a 100644 --- a/gcc/testsuite/gcc.dg/20030906-1.c +++ b/gcc/testsuite/gcc.dg/20030906-1.c @@ -2,7 +2,7 @@ Copyright (C) 2003 Free Software Foundation Inc. */ /* { dg-do compile } */ -/* { dg-options "-O -finline-functions -Wreturn-type" } */ +/* { dg-options "-fpermissive -O -finline-functions -Wreturn-type" } */ extern int i; extern int foo (void); diff --git a/gcc/testsuite/gcc.dg/20030906-1a.c b/gcc/testsuite/gcc.dg/20030906-1a.c new file mode 100644 index 00000000000..46ca1771a4d --- /dev/null +++ b/gcc/testsuite/gcc.dg/20030906-1a.c @@ -0,0 +1,21 @@ +/* Bug 9862 -- Spurious warnings with -finline-functions. + Copyright (C) 2003 Free Software Foundation Inc. */ + +/* { dg-do compile } */ +/* { dg-options "-O -finline-functions -Wreturn-type" } */ + +extern int i; +extern int foo (void); +extern int bar (void); + +int foo (void) +{ + if( i ) return 0; + else return 1; +} + +int bar (void) +{ + if( i ) return; /* { dg-error "'return' with no value, in function returning non-void" } */ + else return 1; +} diff --git a/gcc/testsuite/gcc.dg/20030906-2.c b/gcc/testsuite/gcc.dg/20030906-2.c index 1191133e6a0..a85d91f46f3 100644 --- a/gcc/testsuite/gcc.dg/20030906-2.c +++ b/gcc/testsuite/gcc.dg/20030906-2.c @@ -2,7 +2,7 @@ Copyright (C) 2003 Free Software Foundation Inc. */ /* { dg-do compile } */ -/* { dg-options "-O -finline-functions -Wreturn-type" } */ +/* { dg-options "-fpermissive -O -finline-functions -Wreturn-type" } */ extern int i; extern int foo (void); diff --git a/gcc/testsuite/gcc.dg/20030906-2a.c b/gcc/testsuite/gcc.dg/20030906-2a.c new file mode 100644 index 00000000000..a6ffbacb46d --- /dev/null +++ b/gcc/testsuite/gcc.dg/20030906-2a.c @@ -0,0 +1,21 @@ +/* Bug 9862 -- Spurious warnings with -finline-functions. + Copyright (C) 2003 Free Software Foundation Inc. */ + +/* { dg-do compile } */ +/* { dg-options "-O -finline-functions -Wreturn-type" } */ + +extern int i; +extern int foo (void); +extern int bar (void); + +int foo (void) +{ + if( i ) return; /* { dg-error "'return' with no value, in function returning non-void" } */ + else return 1; +} + +int bar (void) +{ + if( i ) return 0; + else return 1; +} diff --git a/gcc/testsuite/gcc.dg/Wreturn-mismatch-1.c b/gcc/testsuite/gcc.dg/Wreturn-mismatch-1.c index 3bad847ecf7..aef6782cbeb 100644 --- a/gcc/testsuite/gcc.dg/Wreturn-mismatch-1.c +++ b/gcc/testsuite/gcc.dg/Wreturn-mismatch-1.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "" } */ +/* { dg-options "-fpermissive" } */ void f1 (void); diff --git a/gcc/testsuite/gcc.dg/Wreturn-mismatch-1a.c b/gcc/testsuite/gcc.dg/Wreturn-mismatch-1a.c new file mode 100644 index 00000000000..70c7c9ddb86 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wreturn-mismatch-1a.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void f1 (void); + +int +f2 (void) +{ + f1 (); +} + +static inline int +f3 (void) +{ + f1 (); +} + +void +f4 (void) +{ + return 1; /* { dg-error "'return' with a value\[^\n\r\]*-Wreturn-mismatch" } */ +} + +void +f5 (void) +{ + return f1 (); /* { dg-bogus "ISO C" } */ +} + +int +f6 (void) +{ + return; /* { dg-error "'return' with no value\[^\n\r\]*-Wreturn-mismatch" } */ +} + +int +f7 (void) +{ + return f1 (); /* { dg-error "void value not ignored as it ought to be" } */ +} diff --git a/gcc/testsuite/gcc.dg/Wreturn-mismatch-2.c b/gcc/testsuite/gcc.dg/Wreturn-mismatch-2.c index 49eb5a5a95c..08811024b7e 100644 --- a/gcc/testsuite/gcc.dg/Wreturn-mismatch-2.c +++ b/gcc/testsuite/gcc.dg/Wreturn-mismatch-2.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-Wall" } */ +/* { dg-options "-fpermissive -Wall" } */ void f1 (void); diff --git a/gcc/testsuite/gcc.dg/Wreturn-mismatch-2a.c b/gcc/testsuite/gcc.dg/Wreturn-mismatch-2a.c new file mode 100644 index 00000000000..836651ed925 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wreturn-mismatch-2a.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +void f1 (void); + +int +f2 (void) +{ + f1 (); +} /* { dg-warning "control reaches end of non-void\[^\n\r\]*-Wreturn-type" } */ + +static inline int +f3 (void) +{ + f1 (); +} /* { dg-warning "no return statement in function\[^\n\r\]*-Wreturn-type" } */ + +void +f4 (void) +{ + return 1; /* { dg-error "with a value,\[^\n\r\]*-Wreturn-mismatch" } */ +} + +void +f5 (void) +{ + return f1 (); +} + +int +f6 (void) +{ + return; /* { dg-error "with no value,\[^\n\r\]*Wreturn-mismatch" } */ +} + +int +f7 (void) +{ + return f1 (); /* { dg-error "void value not ignored as it ought to be" } */ +} /* { dg-warning "control reaches end of non-void\[^\n\r\]*-Wreturn-type" } */ + diff --git a/gcc/testsuite/gcc.dg/diagnostic-range-bad-return-2.c b/gcc/testsuite/gcc.dg/diagnostic-range-bad-return-2.c new file mode 100644 index 00000000000..2fe8d341dba --- /dev/null +++ b/gcc/testsuite/gcc.dg/diagnostic-range-bad-return-2.c @@ -0,0 +1,52 @@ +/* { dg-options "-fdiagnostics-show-caret -Wreturn-local-addr" } */ + +int *address_of_local (void) +{ + int some_local; + return &some_local; /* { dg-warning "function returns address of local variable" } */ +/* { dg-begin-multiline-output "" } + return &some_local; + ^~~~~~~~~~~ + { dg-end-multiline-output "" } */ +} + +void surplus_return_when_void_1 (void) +{ + return 500; /* { dg-error "'return' with a value, in function returning void" } */ +/* { dg-begin-multiline-output "" } + return 500; + ^~~ + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } + void surplus_return_when_void_1 (void) + ^~~~~~~~~~~~~~~~~~~~~~~~~~ + { dg-end-multiline-output "" } */ +} + +void surplus_return_when_void_2 (int i, int j) +{ + return i * j; /* { dg-error "'return' with a value, in function returning void" } */ +/* { dg-begin-multiline-output "" } + return i * j; + ~~^~~ + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } + void surplus_return_when_void_2 (int i, int j) + ^~~~~~~~~~~~~~~~~~~~~~~~~~ + { dg-end-multiline-output "" } */ +} + +int missing_return_value (void) +{ + return; /* { dg-error "'return' with no value, in function returning non-void" } */ +/* { dg-begin-multiline-output "" } + return; + ^~~~~~ + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } + int missing_return_value (void) + ^~~~~~~~~~~~~~~~~~~~ + { dg-end-multiline-output "" } */ +/* TODO: ideally we'd underline the return type i.e. "int", but that + location isn't captured. */ +} diff --git a/gcc/testsuite/gcc.dg/diagnostic-range-bad-return.c b/gcc/testsuite/gcc.dg/diagnostic-range-bad-return.c index 063fdf1f636..b74481b870c 100644 --- a/gcc/testsuite/gcc.dg/diagnostic-range-bad-return.c +++ b/gcc/testsuite/gcc.dg/diagnostic-range-bad-return.c @@ -1,4 +1,4 @@ -/* { dg-options "-fdiagnostics-show-caret -Wreturn-local-addr" } */ +/* { dg-options "-fpermissive -fdiagnostics-show-caret -Wreturn-local-addr" } */ int *address_of_local (void) { diff --git a/gcc/testsuite/gcc.dg/permerror-default.c b/gcc/testsuite/gcc.dg/permerror-default.c index 90f2220037c..9ed9814d69e 100644 --- a/gcc/testsuite/gcc.dg/permerror-default.c +++ b/gcc/testsuite/gcc.dg/permerror-default.c @@ -75,11 +75,11 @@ incompatible_pointer_types (int flag) void return_mismatch_1 (void) { - return 0; /* { dg-warning "'return' with a value, in function returning void \\\[-Wreturn-mismatch\\\]" } */ + return 0; /* { dg-error "'return' with a value, in function returning void \\\[-Wreturn-mismatch\\\]" } */ } int return_mismatch_2 (void) { - return; /* { dg-warning "return' with no value, in function returning non-void \\\[-Wreturn-mismatch\\\]" } */ + return; /* { dg-error "return' with no value, in function returning non-void \\\[-Wreturn-mismatch\\\]" } */ } diff --git a/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c b/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c index 0780e42b5cc..dc282a44489 100644 --- a/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c +++ b/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c @@ -75,7 +75,7 @@ incompatible_pointer_types (int flag) void return_mismatch_1 (void) { - return 0; /* { dg-warning "'return' with a value, in function returning void \\\[-Wreturn-mismatch\\\]" } */ + return 0; /* { dg-error "'return' with a value, in function returning void \\\[-Wreturn-mismatch\\\]" } */ } int diff --git a/gcc/testsuite/gcc.dg/permerror-system.c b/gcc/testsuite/gcc.dg/permerror-system.c index cad48c93f90..f00420358d9 100644 --- a/gcc/testsuite/gcc.dg/permerror-system.c +++ b/gcc/testsuite/gcc.dg/permerror-system.c @@ -27,3 +27,6 @@ /* { dg-error "initialization of 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" "" { target *-*-* } 45 } */ /* { dg-error "assignment to 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" "" { target *-*-* } 46 } */ /* { dg-error "returning 'int \\\*' from a function with return type 'int' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" "" { target *-*-* } 48 } */ + +/* { dg-error "'return' with a value, in function returning void \\\[-Wreturn-mismatch\\\]" "" { target *-*-* } 78 } */ +/* { dg-error "return' with no value, in function returning non-void \\\[-Wreturn-mismatch\\\]" "" { target *-*-* } 84 } */ diff --git a/gcc/testsuite/gcc.dg/pr105635-2.c b/gcc/testsuite/gcc.dg/pr105635-2.c index 807eef0b7cd..019dbc7e557 100644 --- a/gcc/testsuite/gcc.dg/pr105635-2.c +++ b/gcc/testsuite/gcc.dg/pr105635-2.c @@ -7,5 +7,5 @@ void foo (int, int[*]); /* { dg-message "previous declaration of 'foo' with type foo (int x, int y) /* { dg-error "return type defaults to 'int'" } */ { /* { dg-warning "conflicting types for 'foo'" "" { target *-*-* } .-1 } */ /* { dg-message "declared here" "" { target *-*-* } .-2 } */ - return (x >= 0) != (y < 0); /* { dg-warning "'return' with a value, in function returning void" } */ + return (x >= 0) != (y < 0); /* { dg-error "'return' with a value, in function returning void" } */ } diff --git a/gcc/testsuite/gcc.dg/pr23075-2.c b/gcc/testsuite/gcc.dg/pr23075-2.c new file mode 100644 index 00000000000..0702ddf1a66 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr23075-2.c @@ -0,0 +1,14 @@ +/* PR c/23075 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wreturn-type" } */ + +int +foo (void) +{ + return; /* { dg-error "with no value" } */ +} /* { dg-bogus "control reaches end" } */ + +int +bar (void) +{ +} /* { dg-warning "control reaches end" } */ diff --git a/gcc/testsuite/gcc.dg/pr23075.c b/gcc/testsuite/gcc.dg/pr23075.c index 2d85fb0650f..28baf41006a 100644 --- a/gcc/testsuite/gcc.dg/pr23075.c +++ b/gcc/testsuite/gcc.dg/pr23075.c @@ -1,6 +1,6 @@ /* PR c/23075 */ /* { dg-do compile } */ -/* { dg-options "-O2 -Wreturn-type" } */ +/* { dg-options "-O2 -fpermissive -Wreturn-type" } */ int foo (void) diff --git a/gcc/testsuite/gcc.dg/pr29521-a.c b/gcc/testsuite/gcc.dg/pr29521-a.c new file mode 100644 index 00000000000..2c6a48b7e30 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr29521-a.c @@ -0,0 +1,15 @@ +/* PR 29521 : warning for return with expression in function returning void */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void func (void) { } + +void func2 (void) +{ + return func (); +} + +void func3 (void) +{ + return 1; /* { dg-error "'return' with a value" } */ +} diff --git a/gcc/testsuite/gcc.dg/pr29521.c b/gcc/testsuite/gcc.dg/pr29521.c index b6fb535fab7..cd431514ed2 100644 --- a/gcc/testsuite/gcc.dg/pr29521.c +++ b/gcc/testsuite/gcc.dg/pr29521.c @@ -1,6 +1,6 @@ /* PR 29521 : warning for return with expression in function returning void */ /* { dg-do compile } */ -/* { dg-options "" } */ +/* { dg-options "-fpermissive" } */ void func (void) { } diff --git a/gcc/testsuite/gcc.dg/pr67730-a.c b/gcc/testsuite/gcc.dg/pr67730-a.c new file mode 100644 index 00000000000..08737cc9811 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr67730-a.c @@ -0,0 +1,11 @@ +/* PR c/67730 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +#include + +void +fn1 (void) +{ + return NULL; /* { dg-error "10:.return. with a value" } */ +} diff --git a/gcc/testsuite/gcc.dg/pr67730.c b/gcc/testsuite/gcc.dg/pr67730.c index 54d73a62cf8..cc51858c531 100644 --- a/gcc/testsuite/gcc.dg/pr67730.c +++ b/gcc/testsuite/gcc.dg/pr67730.c @@ -1,6 +1,6 @@ /* PR c/67730 */ /* { dg-do compile } */ -/* { dg-options "" } */ +/* { dg-options "-fpermissive" } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/conditional-return.c b/gcc/testsuite/gcc.target/powerpc/conditional-return.c index 6b3ef5f52ca..c6491216752 100644 --- a/gcc/testsuite/gcc.target/powerpc/conditional-return.c +++ b/gcc/testsuite/gcc.target/powerpc/conditional-return.c @@ -1,7 +1,7 @@ /* Check that a conditional return is used. */ /* { dg-do compile } */ -/* { dg-options "-O2 -w" } */ +/* { dg-options "-O2 -fpermissive -w" } */ /* { dg-final { scan-assembler {\mbeqlr\M} } } */ From patchwork Mon Nov 20 09:56:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 167025 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp2090714vqn; Mon, 20 Nov 2023 01:59:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IGZcLJyNbs51wb9mbdOBfgiBWw8U6WLxb9xXJAYLO8GTni2gNk+X7yv0eb5uqqm6MiOzrAD X-Received: by 2002:a0d:d087:0:b0:5a7:ba53:6544 with SMTP id s129-20020a0dd087000000b005a7ba536544mr6691490ywd.12.1700474355569; Mon, 20 Nov 2023 01:59:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700474355; cv=pass; d=google.com; s=arc-20160816; b=ziNQrj01M8QmD0ZPr1SqI9HXyGUafKcG4SxabLIb7AxcdE/4fPtUIBqjC43/EMZchn ++7StP5hGR2QcLpYCENFifCGKMZ9dFmI9zYRyrcBcmh2/4f2mTl+VLF9m0t7+E5Y3ssX V2qiKXQeWzSRBN/d4LX071H9NqaIgeGG8l2hafkubF29JJAA7CCFX8D3qFYH5QDn8PZz DaFtI3Qx7zH2Y2oERSVXuH4xgNGUhz/pj+zlBv4lzm/KzkHcIyb0JaqNIoIiOhxs92CW LjCDgyUoOL4zsXuin9t/rbANabkOsJGN2JW48Wp/AdNRg+1dGajRDEQDSoPEObzFNfTZ 0v4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent:date :references:message-id:in-reply-to:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=h3PoQ6JnilM2tk8Yz50q+r/em007OGbfO/uhPneNBqk=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=rFC3QEkf/3MRtPF3fodtDue8uPvPwX+tHYGYnNAHfK4j88ZhpOW8UuxsGl+MmjEDQb YliZ77ikWC9eulYH3zSuYtJgNxedpKJDkb/Dl76Z+EIsc/uixg4W4vVzSQoGPPETcGgj h2RdoaCh3WirdMCBYl0gtY1520nqYW2iSboBDvuPcoKMZM6aevy0FwlaUGZaPqvxmafG ZiayTb9/QVJ7XSWISoBaYV+WZA2/Y62Eelf26IOhQHCzMIJvTQsmVtPZXSdYWbDSsMN6 rBue7c3EZvIrv1BGdH7AQuTEAXDzDek4KqDGfdHUpi3iC0uPtGnhpK44887zPciCCUzh kVSQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cZXkYkFL; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id mh6-20020a056214564600b00677d88bd9basi6945168qvb.93.2023.11.20.01.59.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 01:59:15 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cZXkYkFL; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 23913384F488 for ; Mon, 20 Nov 2023 09:59:13 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id EBB573858C50 for ; Mon, 20 Nov 2023 09:56:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EBB573858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EBB573858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700474209; cv=none; b=bJGC1reIXFKhUmSKaRhgcUlcBRJ+x9tQ1IYKb6+O4TjGSqCUxscuEH/0xDWx8b656rWN21UmdFi7fJOaLjdG1YMC3yu4uBKnqMco+HdQbRZtDevb5KEsGFmYJEsyKUzY+fJ2+tLA3p8gDI5ez+I9Mso/RoxF+DubAT1ui12grbQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700474209; c=relaxed/simple; bh=CzJBC/aw7RtjbrRmJaJmRebOApXVPDH7m5ULLsThuzw=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=Okrav2nKKe2FXXrw0eZVS4YDHGGoaren3JtcBxiHYYkPpKPZp/5weU55QDc08X0TCsUq10yTkW6GO53T/VrFeX+Y81QY6fConYBsGICQhFeWa92O+kgwDuwv+XKDRqfbsmXJWE/wRY8Buzim0ZwPMUlvw+bSX8A/VWc9FbPDqSg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700474203; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=h3PoQ6JnilM2tk8Yz50q+r/em007OGbfO/uhPneNBqk=; b=cZXkYkFLurTkXfLd9hdpCiMHJBOftt9oSayKbOav4A1+U31IeohWhh/4ACEey+GZXlluOe DaTEDtBVwIXOBQ119Pn35AMrHCCJ3mzEnhHrMG19qvlkLT1BfwCV3if6cw2gdLGsYUJYyL GDM5jjnFdqCdEvWVIhBMIwNuAkbHWTI= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-351-JEG8jquYMgSij9PCFgJ4Mg-1; Mon, 20 Nov 2023 04:56:41 -0500 X-MC-Unique: JEG8jquYMgSij9PCFgJ4Mg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A6BD93C0E64C for ; Mon, 20 Nov 2023 09:56:40 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DEB331121306 for ; Mon, 20 Nov 2023 09:56:38 +0000 (UTC) From: Florian Weimer To: gcc-patches@gcc.gnu.org Subject: [PATCH v3 10/11] c: Turn -Wincompatible-pointer-types into a permerror In-Reply-To: Message-ID: <9e40a64880a14cf27d788ecbaf23365b9a5ac069.1700473918.git.fweimer@redhat.com> References: X-From-Line: 9e40a64880a14cf27d788ecbaf23365b9a5ac069 Mon Sep 17 00:00:00 2001 Date: Mon, 20 Nov 2023 10:56:36 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783076597924539595 X-GMAIL-MSGID: 1783076597924539595 The change to build_conditional_expr drops the downgrade from a pedwarn to warning for builtins for C99 and later language dialects. It remains a warning in C89 mode (not a permerror), as the -std=gnu89 -fno-permissive test shows. gcc/ * doc/invoke.texi (Warning Options): Document changes. gcc/c/ PR c/96284 * c-typeck.cc (build_conditional_expr): Upgrade most pointer type mismatches to a permerror. (convert_for_assignment): Use permerror_opt and permerror_init for OPT_Wincompatible_pointer_types warnings. gcc/testsuite/ * gcc.dg/permerror-default.c (incompatible_pointer_types): Expect new permerror. * gcc.dg/permerror-gnu89-nopermissive.c (incompatible_pointer_types): Likewise. * gcc.dg/permerror-pedantic.c (incompatible_pointer_types): Likewise. * gcc.dg/permerror-system.c: Likewise. * gcc.dg/Wincompatible-pointer-types-2.c: Compile with -fpermissive due to expected errors. * gcc.dg/Wincompatible-pointer-types-5.c: New test. Copied from gcc.dg/Wincompatible-pointer-types-2.c. Expect errors. * gcc.dg/anon-struct-11.c: Compile with -fpermissive due to expected errors. * gcc.dg/anon-struct-11a.c: New test. Copied from gcc.dg/anon-struct-11.c. Expect errors. * gcc.dg/anon-struct-13.c: Compile with -fpermissive due to expected errors. * gcc.dg/anon-struct-13a.c: New test. Copied from gcc.dg/anon-struct-13.c. Expect errors. * gcc.dg/builtin-arith-overflow-4.c: Compile with -fpermissive due to expected errors. * gcc.dg/builtin-arith-overflow-4a.c: New test. Copied from gcc.dg/builtin-arith-overflow-4.c. Expect errors. * gcc.dg/c23-qual-4.c: Expect -Wincompatible-pointer-types errors. * gcc.dg/dfp/composite-type.c: Compile with -fpermissive due to expected errors. * gcc.dg/dfp/composite-type-2.c: New test. Copied from gcc.dg/dfp/composite-type.c. Expect errors. * gcc.dg/diag-aka-1.c: Compile with -fpermissive due to expected errors. * gcc.dg/diag-aka-1a.c: New test. Copied from gcc.dg/diag-aka-1a.c. Expect errors. * gcc.dg/enum-compat-1.c: Compile with -fpermissive due to expected errors. * gcc.dg/enum-compat-2.c: New test. Copied from gcc.dg/enum-compat-1.c. Expect errors. * gcc.dg/func-ptr-conv-1.c: Compile with -fpermissive due to expected errors. * gcc.dg/func-ptr-conv-2.c: New test. Copied from gcc.dg/func-ptr-conv-1.c. Expect errors. * gcc.dg/init-bad-7.c: Compile with -fpermissive due to expected errors. * gcc.dg/init-bad-7a.c: New test. Copied from gcc.dg/init-bad-7.c. Expect errors. * gcc.dg/noncompile/incomplete-3.c (foo): Expect -Wincompatible-pointer-types error. * gcc.dg/param-type-mismatch-2.c (test8): Likewise. * gcc.dg/pointer-array-atomic.c: Compile with -fpermissive due to expected errors. * gcc.dg/pointer-array-atomic-2.c: New test. Copied from gcc.dg/pointer-array-atomic.c. Expect errors. * gcc.dg/pointer-array-quals-1.c (test): Expect -Wincompatible-pointer-types errors. * gcc.dg/transparent-union-1.c: Compile with -fpermissive due to expected errors. * gcc.dg/transparent-union-1a.c: New test. Copied from gcc.dg/transparent-union-1.c. Expect errors. * gcc.target/aarch64/acle/memtag_2a.c (test_memtag_warning_return_qualifier): Expect additional errors. * gcc.target/aarch64/sve/acle/general-c/load_2.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_1.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_2.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_3.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_4.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_5.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_1.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_2.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_3.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_4.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/sizeless-1.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/sizeless-2.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/store_1.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/store_2.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/store_scatter_index_1.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/store_scatter_index_restricted_1.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_2.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_restricted_1.c (f1): Likewise. * gcc.target/aarch64/sve/acle/general/attributes_7.c (f1): Likewise. * gcc.target/i386/sse2-bfloat16-scalar-typecheck.c (footest): Expect -Wincompatible-pointer-types errors. * gcc.target/i386/vect-bfloat16-typecheck_1.c (footest): Likewise. * gcc.target/i386/vect-bfloat16-typecheck_2.c (footest): Likewise. --- gcc/c/c-typeck.cc | 63 +++++----- gcc/doc/invoke.texi | 6 + .../gcc.dg/Wincompatible-pointer-types-2.c | 2 +- .../gcc.dg/Wincompatible-pointer-types-5.c | 10 ++ gcc/testsuite/gcc.dg/anon-struct-11.c | 5 +- gcc/testsuite/gcc.dg/anon-struct-11a.c | 111 ++++++++++++++++++ gcc/testsuite/gcc.dg/anon-struct-13.c | 2 +- gcc/testsuite/gcc.dg/anon-struct-13a.c | 76 ++++++++++++ .../gcc.dg/builtin-arith-overflow-4.c | 2 +- .../gcc.dg/builtin-arith-overflow-4a.c | 43 +++++++ gcc/testsuite/gcc.dg/c23-qual-4.c | 6 +- gcc/testsuite/gcc.dg/dfp/composite-type-2.c | 58 +++++++++ gcc/testsuite/gcc.dg/dfp/composite-type.c | 2 +- gcc/testsuite/gcc.dg/diag-aka-1.c | 2 +- gcc/testsuite/gcc.dg/diag-aka-1a.c | 29 +++++ gcc/testsuite/gcc.dg/enum-compat-1.c | 2 +- gcc/testsuite/gcc.dg/enum-compat-2.c | 32 +++++ gcc/testsuite/gcc.dg/func-ptr-conv-1.c | 2 +- gcc/testsuite/gcc.dg/func-ptr-conv-2.c | 56 +++++++++ gcc/testsuite/gcc.dg/init-bad-7.c | 2 +- gcc/testsuite/gcc.dg/init-bad-7a.c | 12 ++ .../gcc.dg/noncompile/incomplete-3.c | 2 +- gcc/testsuite/gcc.dg/param-type-mismatch-2.c | 2 +- gcc/testsuite/gcc.dg/permerror-default.c | 20 ++-- .../gcc.dg/permerror-gnu89-nopermissive.c | 18 +-- gcc/testsuite/gcc.dg/permerror-pedantic.c | 2 +- gcc/testsuite/gcc.dg/permerror-system.c | 11 ++ gcc/testsuite/gcc.dg/pointer-array-atomic-2.c | 60 ++++++++++ gcc/testsuite/gcc.dg/pointer-array-atomic.c | 2 +- gcc/testsuite/gcc.dg/pointer-array-quals-1.c | 6 +- gcc/testsuite/gcc.dg/transparent-union-1.c | 2 +- gcc/testsuite/gcc.dg/transparent-union-1a.c | 85 ++++++++++++++ .../gcc.target/aarch64/acle/memtag_2a.c | 6 +- .../aarch64/sve/acle/general-c/load_2.c | 4 +- .../acle/general-c/load_ext_gather_offset_1.c | 2 +- .../acle/general-c/load_ext_gather_offset_2.c | 2 +- .../acle/general-c/load_ext_gather_offset_3.c | 2 +- .../acle/general-c/load_ext_gather_offset_4.c | 2 +- .../acle/general-c/load_ext_gather_offset_5.c | 2 +- .../load_ext_gather_offset_restricted_1.c | 2 +- .../load_ext_gather_offset_restricted_2.c | 2 +- .../load_ext_gather_offset_restricted_3.c | 2 +- .../load_ext_gather_offset_restricted_4.c | 2 +- .../aarch64/sve/acle/general-c/sizeless-1.c | 8 +- .../aarch64/sve/acle/general-c/sizeless-2.c | 8 +- .../aarch64/sve/acle/general-c/store_1.c | 8 +- .../aarch64/sve/acle/general-c/store_2.c | 8 +- .../acle/general-c/store_scatter_index_1.c | 6 +- .../store_scatter_index_restricted_1.c | 6 +- .../acle/general-c/store_scatter_offset_2.c | 6 +- .../store_scatter_offset_restricted_1.c | 6 +- .../aarch64/sve/acle/general/attributes_7.c | 28 ++--- .../i386/sse2-bfloat16-scalar-typecheck.c | 4 +- .../i386/vect-bfloat16-typecheck_1.c | 4 +- .../i386/vect-bfloat16-typecheck_2.c | 4 +- 55 files changed, 727 insertions(+), 130 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/Wincompatible-pointer-types-5.c create mode 100644 gcc/testsuite/gcc.dg/anon-struct-11a.c create mode 100644 gcc/testsuite/gcc.dg/anon-struct-13a.c create mode 100644 gcc/testsuite/gcc.dg/builtin-arith-overflow-4a.c create mode 100644 gcc/testsuite/gcc.dg/dfp/composite-type-2.c create mode 100644 gcc/testsuite/gcc.dg/diag-aka-1a.c create mode 100644 gcc/testsuite/gcc.dg/enum-compat-2.c create mode 100644 gcc/testsuite/gcc.dg/func-ptr-conv-2.c create mode 100644 gcc/testsuite/gcc.dg/init-bad-7a.c create mode 100644 gcc/testsuite/gcc.dg/pointer-array-atomic-2.c create mode 100644 gcc/testsuite/gcc.dg/transparent-union-1a.c diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index f4b700117ff..39efb518835 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -5434,8 +5434,15 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp, else { int qual = ENCODE_QUAL_ADDR_SPACE (as_common); - if (emit_diagnostic (bltin1 && bltin2 ? DK_WARNING : DK_PEDWARN, - colon_loc, OPT_Wincompatible_pointer_types, + diagnostic_t kind = DK_PERMERROR; + if (!flag_isoc99) + /* This downgrade to a warning ensures that -std=gnu89 + -pedantic-errors does not flag these mismatches between + builtins as errors (as DK_PERMERROR would). ISO C99 + and later do not have implicit function declarations, + so the mismatch cannot occur naturally there. */ + kind = bltin1 && bltin2 ? DK_WARNING : DK_PEDWARN; + if (emit_diagnostic (kind, colon_loc, OPT_Wincompatible_pointer_types, "pointer type mismatch " "in conditional expression")) { @@ -7573,46 +7580,48 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, auto_diagnostic_group d; range_label_for_type_mismatch rhs_label (rhstype, type); gcc_rich_location richloc (expr_loc, &rhs_label); - if (pedwarn (&richloc, OPT_Wincompatible_pointer_types, - "passing argument %d of %qE from incompatible " - "pointer type", parmnum, rname)) + if (permerror_opt (&richloc, OPT_Wincompatible_pointer_types, + "passing argument %d of %qE from " + "incompatible pointer type", + parmnum, rname)) inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); } break; case ic_assign: if (bltin) - pedwarn (location, OPT_Wincompatible_pointer_types, - "assignment to %qT from pointer to " - "%qD with incompatible type %qT", - type, bltin, rhstype); + permerror_opt (location, OPT_Wincompatible_pointer_types, + "assignment to %qT from pointer to " + "%qD with incompatible type %qT", + type, bltin, rhstype); else - pedwarn (location, OPT_Wincompatible_pointer_types, - "assignment to %qT from incompatible pointer type %qT", - type, rhstype); + permerror_opt (location, OPT_Wincompatible_pointer_types, + "assignment to %qT from incompatible pointer " + "type %qT", + type, rhstype); break; case ic_init: case ic_init_const: if (bltin) - pedwarn_init (location, OPT_Wincompatible_pointer_types, - "initialization of %qT from pointer to " - "%qD with incompatible type %qT", - type, bltin, rhstype); + permerror_init (location, OPT_Wincompatible_pointer_types, + "initialization of %qT from pointer to " + "%qD with incompatible type %qT", + type, bltin, rhstype); else - pedwarn_init (location, OPT_Wincompatible_pointer_types, - "initialization of %qT from incompatible " - "pointer type %qT", - type, rhstype); + permerror_init (location, OPT_Wincompatible_pointer_types, + "initialization of %qT from incompatible " + "pointer type %qT", + type, rhstype); break; case ic_return: if (bltin) - pedwarn (location, OPT_Wincompatible_pointer_types, - "returning pointer to %qD of type %qT from " - "a function with incompatible type %qT", - bltin, rhstype, type); + permerror_opt (location, OPT_Wincompatible_pointer_types, + "returning pointer to %qD of type %qT from " + "a function with incompatible type %qT", + bltin, rhstype, type); else - pedwarn (location, OPT_Wincompatible_pointer_types, - "returning %qT from a function with incompatible " - "return type %qT", rhstype, type); + permerror_opt (location, OPT_Wincompatible_pointer_types, + "returning %qT from a function with " + "incompatible return type %qT", rhstype, type); break; default: gcc_unreachable (); diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 831242d134b..be33da71c44 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -6183,6 +6183,7 @@ that have their own flag: @gccoptlist{ -Wimplicit-function-declaration @r{(C)} -Wimplicit-int @r{(C)} +-Wincompatible-pointer-types @r{(C)} -Wint-conversion @r{(C)} -Wnarrowing @r{(C++)} -Wreturn-mismatch @r{(C)} @@ -8549,6 +8550,11 @@ types. This warning is for cases not covered by @option{-Wno-pointer-sign}, which warns for pointer argument passing or assignment with different signedness. +By default, in C99 and later dialects of C, GCC treats this issue as an +error. The error can be downgraded to a warning using +@option{-fpermissive} (along with certain other errors), or for this +error alone, with @option{-Wno-error=incompatible-pointer-types}. + This warning is upgraded to an error by @option{-pedantic-errors}. @opindex Wno-int-conversion diff --git a/gcc/testsuite/gcc.dg/Wincompatible-pointer-types-2.c b/gcc/testsuite/gcc.dg/Wincompatible-pointer-types-2.c index 19276bbcfba..bbf983c1536 100644 --- a/gcc/testsuite/gcc.dg/Wincompatible-pointer-types-2.c +++ b/gcc/testsuite/gcc.dg/Wincompatible-pointer-types-2.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "" } */ +/* { dg-options "-fpermissive" } */ void * f1 (int flag, int *a, long *b) diff --git a/gcc/testsuite/gcc.dg/Wincompatible-pointer-types-5.c b/gcc/testsuite/gcc.dg/Wincompatible-pointer-types-5.c new file mode 100644 index 00000000000..dcbfa4767de --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wincompatible-pointer-types-5.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void * +f1 (int flag, int *a, long *b) +{ + return flag ? a : b; /* { dg-error "pointer type mismatch in conditional expression \\\[-Wincompatible-pointer-types\\\]" } */ + /* { dg-note "first expression has type 'int \\*'" "" { target *-*-* } .-1 } */ + /* { dg-note "second expression has type 'long int \\*'" "" { target *-*-* } .-2 } */ +} diff --git a/gcc/testsuite/gcc.dg/anon-struct-11.c b/gcc/testsuite/gcc.dg/anon-struct-11.c index c2f85fc24e4..622fb7cacc6 100644 --- a/gcc/testsuite/gcc.dg/anon-struct-11.c +++ b/gcc/testsuite/gcc.dg/anon-struct-11.c @@ -1,8 +1,7 @@ /* { dg-do compile } */ -/* No special options--in particular, turn off the default - -pedantic-errors option. */ -/* { dg-options "" } */ +/* Also turn off the default -pedantic-errors option. */ +/* { dg-options "-fpermissive" } */ /* When not using -fplan9-extensions, we don't support automatic conversion of pointer types, and we don't support referring to a diff --git a/gcc/testsuite/gcc.dg/anon-struct-11a.c b/gcc/testsuite/gcc.dg/anon-struct-11a.c new file mode 100644 index 00000000000..9ee3bb63ebf --- /dev/null +++ b/gcc/testsuite/gcc.dg/anon-struct-11a.c @@ -0,0 +1,111 @@ +/* { dg-do compile } */ + +/* No special options--in particular, turn off the default + -pedantic-errors option. */ +/* { dg-options "" } */ + +/* When not using -fplan9-extensions, we don't support automatic + conversion of pointer types, and we don't support referring to a + typedef name directly. */ + +extern void exit (int); +extern void abort (void); + +struct A { char a; }; + +struct B { + char b; + struct A; /* { dg-warning "does not declare anything" } */ + char c; +}; + +void +f1 (struct A *p) /* { dg-message "expected" } */ +{ + p->a = 1; +} + +void +test1 (void) +{ + struct B b; + struct A *p; + + b.b = 2; + b.c = 3; + f1 (&b); /* { dg-error "incompatible pointer type" } */ + if (b.a != 1) /* { dg-error "no member" } */ + abort (); + if (b.b != 2 || b.c != 3) + abort (); + p = &b; /* { dg-error "incompatible pointer type" } */ + if (p->a != 1) + abort (); +} + +typedef struct { char d; } D; + +struct E { + char b; + struct F { char f; }; /* { dg-warning "does not declare anything" } */ + char c; + union { + D; /* { dg-warning "does not declare anything" } */ + }; + char e; +}; + +void +f2 (struct F *p) /* { dg-message "expected" } */ +{ + p->f = 6; +} + +void +f3 (D *p) /* { dg-message "expected" } */ +{ + p->d = 4; +} + +void +f4 (D d) +{ +} + +void +test2 (void) +{ + struct E e; + struct F *pf; + D *pd; + D d; + + e.b = 2; + e.c = 3; + e.e = 5; + f2 (&e); /* { dg-error "incompatible pointer type" } */ + f3 (&e); /* { dg-error "incompatible pointer type" } */ + if (e.d != 4) /* { dg-error "no member" } */ + abort (); + if (e.f != 6) /* { dg-error "no member" } */ + abort (); + if (e.b != 2 || e.c != 3 || e.e != 5) + abort (); + pf = &e; /* { dg-error "incompatible pointer type" } */ + if (pf->f != 6) + abort (); + pd = &e; /* { dg-error "incompatible pointer type" } */ + if (pd->d != 4) + abort (); + d = e.D; /* { dg-error "no member" } */ + f3 (&e.D); /* { dg-error "no member" } */ + f4 (e.D); /* { dg-error "no member" } */ +} + +int +main () +{ + test1 (); + test2 (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/anon-struct-13.c b/gcc/testsuite/gcc.dg/anon-struct-13.c index 6a508141bac..de478b9684b 100644 --- a/gcc/testsuite/gcc.dg/anon-struct-13.c +++ b/gcc/testsuite/gcc.dg/anon-struct-13.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-fplan9-extensions" } */ +/* { dg-options "-fpermissive -fplan9-extensions" } */ /* Test for ambiguity when using the Plan 9 extensions. */ diff --git a/gcc/testsuite/gcc.dg/anon-struct-13a.c b/gcc/testsuite/gcc.dg/anon-struct-13a.c new file mode 100644 index 00000000000..9e6c5d96595 --- /dev/null +++ b/gcc/testsuite/gcc.dg/anon-struct-13a.c @@ -0,0 +1,76 @@ +/* { dg-do compile } */ +/* { dg-options "-fplan9-extensions" } */ + +/* Test for ambiguity when using the Plan 9 extensions. */ + +struct A { + char a; /* { dg-error "duplicate member" } */ +}; + +struct B +{ + struct A; + struct A; +}; + +char +f1 (struct B *p) +{ + return p->a; /* { dg-error "no member" } */ +} + +void +f2 (struct A *p) /* { dg-message "expected" } */ +{ +} + +void +f3 (struct B *p) +{ + f2 (p); /* { dg-error "incompatible pointer type" } */ +} + +struct C +{ + char c; /* { dg-error "duplicate member" } */ +}; + +struct D +{ + struct C; +}; + +struct E +{ + struct C; + struct D; +}; + +char +f4 (struct E *p) +{ + return p->c; /* { dg-error "no member" } */ +} + +void +f6 (struct C *p) /* { dg-message "expected" } */ +{ +} + +void +f7 (struct E *p) +{ + f6 (p); /* { dg-error "incompatible pointer type" } */ +} + +struct A +f8 (struct B *p) +{ + return p->A; /* { dg-error "no member" } */ +} + +struct C +f9 (struct E *p) +{ + return p->C; /* { dg-error "no member" } */ +} diff --git a/gcc/testsuite/gcc.dg/builtin-arith-overflow-4.c b/gcc/testsuite/gcc.dg/builtin-arith-overflow-4.c index ab7d82a8d83..4c2c89ff616 100644 --- a/gcc/testsuite/gcc.dg/builtin-arith-overflow-4.c +++ b/gcc/testsuite/gcc.dg/builtin-arith-overflow-4.c @@ -1,6 +1,6 @@ /* PR c/90628 */ /* { dg-do compile } */ -/* { dg-options "" } */ +/* { dg-options "-fpermissive" } */ _Atomic int a = 1, b = 2, c = 3; _Atomic long d = 4, e = 5, f = 6; diff --git a/gcc/testsuite/gcc.dg/builtin-arith-overflow-4a.c b/gcc/testsuite/gcc.dg/builtin-arith-overflow-4a.c new file mode 100644 index 00000000000..c021cabdc24 --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtin-arith-overflow-4a.c @@ -0,0 +1,43 @@ +/* PR c/90628 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +_Atomic int a = 1, b = 2, c = 3; +_Atomic long d = 4, e = 5, f = 6; +_Atomic long long g = 7, h = 8, i = 9; + +void +f1 () +{ + __builtin_add_overflow (a, b, &c); /* { dg-error "argument 3 in call to function '__builtin_add_overflow' has pointer to '_Atomic' type" } */ +} + +void +f2 () +{ + __builtin_sub_overflow (d, e, &f); /* { dg-error "argument 3 in call to function '__builtin_sub_overflow' has pointer to '_Atomic' type" } */ +} + +void +f3 () +{ + __builtin_mul_overflow (g, h, &i); /* { dg-error "argument 3 in call to function '__builtin_mul_overflow' has pointer to '_Atomic' type" } */ +} + +void +f4 () +{ + __builtin_sadd_overflow (a, b, &c); /* { dg-error "passing argument 3 of '__builtin_sadd_overflow' from incompatible pointer type" } */ +} + +void +f5 () +{ + __builtin_ssubl_overflow (d, e, &f); /* { dg-error "passing argument 3 of '__builtin_ssubl_overflow' from incompatible pointer type" } */ +} + +void +f6 () +{ + __builtin_smulll_overflow (g, h, &i); /* { dg-error "passing argument 3 of '__builtin_smulll_overflow' from incompatible pointer type" } */ +} diff --git a/gcc/testsuite/gcc.dg/c23-qual-4.c b/gcc/testsuite/gcc.dg/c23-qual-4.c index 8a7a9f2be35..a8538de74e8 100644 --- a/gcc/testsuite/gcc.dg/c23-qual-4.c +++ b/gcc/testsuite/gcc.dg/c23-qual-4.c @@ -83,9 +83,9 @@ void test(void) (void)(1 ? x0 : z0); (void)(1 ? x1 : z1); (void)(1 ? x2 : z2); - (void)(1 ? x0 : x1); /* { dg-warning "pointer type mismatch in conditional expression" } */ - (void)(1 ? x1 : x2); /* { dg-warning "pointer type mismatch in conditional expression" } */ - (void)(1 ? x2 : x0); /* { dg-warning "pointer type mismatch in conditional expression" } */ + (void)(1 ? x0 : x1); /* { dg-error "pointer type mismatch in conditional expression" } */ + (void)(1 ? x1 : x2); /* { dg-error "pointer type mismatch in conditional expression" } */ + (void)(1 ? x2 : x0); /* { dg-error "pointer type mismatch in conditional expression" } */ v0p = (1 ? z0 : v0p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ v1p = (1 ? z1 : v1p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ v2p = (1 ? z2 : v2p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ diff --git a/gcc/testsuite/gcc.dg/dfp/composite-type-2.c b/gcc/testsuite/gcc.dg/dfp/composite-type-2.c new file mode 100644 index 00000000000..5c6d95cc200 --- /dev/null +++ b/gcc/testsuite/gcc.dg/dfp/composite-type-2.c @@ -0,0 +1,58 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wall -ftrack-macro-expansion=0" } */ + +/* C99 6.2.7: Compatible type and composite type. */ + +#define DECIMAL_COMPOSITE_DECL(TYPE) \ + _Decimal##TYPE g1_##TYPE(); \ + _Decimal##TYPE g2_##TYPE(); \ + _Decimal##TYPE (*h1_##TYPE)[2]; \ + _Decimal##TYPE (*h2_##TYPE)[3]; \ + _Decimal##TYPE (*h3_##TYPE)[4]; \ + _Decimal##TYPE f1_##TYPE(_Decimal##TYPE(*)()); \ + _Decimal##TYPE f1_##TYPE(_Decimal##TYPE(*)(_Decimal##TYPE*)); \ + _Decimal##TYPE f1_##TYPE (_Decimal##TYPE(*g)(_Decimal##TYPE*)) \ + { \ + _Decimal##TYPE d##TYPE; \ + d##TYPE = ((_Decimal##TYPE (*) (_Decimal##TYPE*)) g)(&d##TYPE); \ + d##TYPE = ((_Decimal##TYPE (*) ()) g); \ + return d##TYPE; \ + } \ + _Decimal##TYPE f2_##TYPE(_Decimal##TYPE(*)[]); \ + _Decimal##TYPE f2_##TYPE(_Decimal##TYPE(*)[3]); + +#define DECIMAL_COMPOSITE_TEST(TYPE) \ +do \ +{ \ + _Decimal##TYPE d##TYPE; \ + d##TYPE = f1_##TYPE(g1_##TYPE); \ + d##TYPE = f1_##TYPE(g2_##TYPE); \ + d##TYPE = f2_##TYPE(h1_##TYPE); \ + d##TYPE = f2_##TYPE(h2_##TYPE); \ + d##TYPE = f2_##TYPE(h3_##TYPE); \ + (void) d##TYPE; \ +} while(0) + +DECIMAL_COMPOSITE_DECL(32); /* { dg-error "incompatible types when assigning to type '\[^\n\]*' from type '\[^\n\]*'" } */ +/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } .-1 } */ + + +DECIMAL_COMPOSITE_DECL(64); /* { dg-error "incompatible types when assigning to type '\[^\n\]*' from type '\[^\n\]*'" } */ +/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } .-1 } */ + + +DECIMAL_COMPOSITE_DECL(128); /* { dg-error "incompatible types when assigning to type '\[^\n\]*' from type '\[^\n\]*'" } */ +/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } .-1 } */ + + +int main() +{ + DECIMAL_COMPOSITE_TEST(32); /* { dg-error "incompatible pointer type" } */ + DECIMAL_COMPOSITE_TEST(64); /* { dg-error "incompatible pointer type" } */ + DECIMAL_COMPOSITE_TEST(128); /* { dg-error "incompatible pointer type" } */ + + return 0; +} + +/* The invalid function redeclarations might also trigger: + { dg-prune-output "-Warray-parameter" } */ diff --git a/gcc/testsuite/gcc.dg/dfp/composite-type.c b/gcc/testsuite/gcc.dg/dfp/composite-type.c index ce7d5c1a0a0..2eb601400b5 100644 --- a/gcc/testsuite/gcc.dg/dfp/composite-type.c +++ b/gcc/testsuite/gcc.dg/dfp/composite-type.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O -Wall -ftrack-macro-expansion=0" } */ +/* { dg-options "-fpermissive -O -Wall -ftrack-macro-expansion=0" } */ /* C99 6.2.7: Compatible type and composite type. */ diff --git a/gcc/testsuite/gcc.dg/diag-aka-1.c b/gcc/testsuite/gcc.dg/diag-aka-1.c index 3383c1c263b..485a8a5f85d 100644 --- a/gcc/testsuite/gcc.dg/diag-aka-1.c +++ b/gcc/testsuite/gcc.dg/diag-aka-1.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-Wc++-compat" } */ +/* { dg-options "-fpermissive -Wc++-compat" } */ typedef struct A { int i; } B; typedef struct T { int i; } *T; /* { dg-warning "using 'T' as both a typedef and a tag is invalid" } */ diff --git a/gcc/testsuite/gcc.dg/diag-aka-1a.c b/gcc/testsuite/gcc.dg/diag-aka-1a.c new file mode 100644 index 00000000000..d161b785e7d --- /dev/null +++ b/gcc/testsuite/gcc.dg/diag-aka-1a.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +typedef struct A { int i; } B; +typedef struct T { int i; } *T; /* { dg-warning "using 'T' as both a typedef and a tag is invalid" } */ +typedef const float TFA; +typedef TFA TFB; +typedef TFB TFC; +typedef int IA[]; +typedef IA *IAP; +extern IAP arr[]; + +void fn1 (B *); /* { dg-message "expected 'B \\*' {aka 'struct A \\*'} but argument is of type 'struct B \\*'" } */ +void fn2 (TFC *); + +void +bar (B *b, int *i) +{ + fn1 ((struct B *) b); /* { dg-error "passing argument" } */ + fn2 (i); /* { dg-error "passing argument" } */ + sizeof (arr); /* { dg-error "invalid application of .sizeof. to incomplete type .int \\(\\*\\\[\\\]\\)\\\[\\\]." } */ +} + +int +foo (void *a) +{ + T t = a; /* { dg-warning "request for implicit conversion from 'void \\*' to 'T' {aka 'struct T \\*'} not" } */ + return t->i; +} diff --git a/gcc/testsuite/gcc.dg/enum-compat-1.c b/gcc/testsuite/gcc.dg/enum-compat-1.c index 5fb150cee79..b7352f6ddc3 100644 --- a/gcc/testsuite/gcc.dg/enum-compat-1.c +++ b/gcc/testsuite/gcc.dg/enum-compat-1.c @@ -3,7 +3,7 @@ /* Origin: Joseph Myers , based on PR c/6024 from Richard Earnshaw */ /* { dg-do compile } */ -/* { dg-options "" } */ +/* { dg-options "-fpermissive" } */ /* Original test from PR c/6024. */ enum e1 {a, b}; diff --git a/gcc/testsuite/gcc.dg/enum-compat-2.c b/gcc/testsuite/gcc.dg/enum-compat-2.c new file mode 100644 index 00000000000..69509012480 --- /dev/null +++ b/gcc/testsuite/gcc.dg/enum-compat-2.c @@ -0,0 +1,32 @@ +/* Test that enumerated types are only considered compatible when they + are the same type. PR c/6024. */ +/* Origin: Joseph Myers , based on + PR c/6024 from Richard Earnshaw */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* Original test from PR c/6024. */ +enum e1 {a, b}; +enum e2 {c, d}; + +void f(enum e1); /* { dg-error "prototype" "error at decl" } */ + +void f(x) + enum e2 x; /* { dg-error "doesn't match prototype" } */ +{ + return; +} + +/* Other compatibility tests. */ +enum e3 { A }; +enum e4 { B }; + +enum e3 v3; +enum e4 *p = &v3; /* { dg-error "incompatible" "incompatible pointer" } */ +enum e3 *q = &v3; + +void g(enum e3); /* { dg-message "note: previous declaration" "error at first decl" } */ +void g(enum e4); /* { dg-error "conflicting types" "error at second decl" } */ + +void h(enum e3); +void h(enum e3); diff --git a/gcc/testsuite/gcc.dg/func-ptr-conv-1.c b/gcc/testsuite/gcc.dg/func-ptr-conv-1.c index 5c8a101343e..7c2876cc998 100644 --- a/gcc/testsuite/gcc.dg/func-ptr-conv-1.c +++ b/gcc/testsuite/gcc.dg/func-ptr-conv-1.c @@ -5,7 +5,7 @@ are not permitted. PR c/11234. */ /* Origin: Joseph Myers */ /* { dg-do compile } */ -/* { dg-options "-pedantic" } */ +/* { dg-options "-fpermissive -pedantic" } */ void f(void); diff --git a/gcc/testsuite/gcc.dg/func-ptr-conv-2.c b/gcc/testsuite/gcc.dg/func-ptr-conv-2.c new file mode 100644 index 00000000000..a9884a6c919 --- /dev/null +++ b/gcc/testsuite/gcc.dg/func-ptr-conv-2.c @@ -0,0 +1,56 @@ +/* Conversions between function and object pointers are not permitted + in any version of ISO C, even with casts, except for the special + case of converting a null pointer constant to function pointer + type. Likewise, comparisons between function and object pointers + are not permitted. PR c/11234. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +void f(void); + +void *v1 = f; /* { dg-warning "12:pointer" "bad conversion" } */ +void *v2 = &f; /* { dg-warning "12:pointer" "bad conversion" } */ +void *v3 = (void *)f; /* { dg-warning "12:pointer" "bad conversion" } */ +void *v4 = (void *)&f; /* { dg-warning "12:pointer" "bad conversion" } */ +void *v5; +char *c1 = f; /* { dg-error "12:pointer" "bad conversion" } */ +char *c2 = &f; /* { dg-error "12:pointer" "bad conversion" } */ +char *c3 = (char *)f; /* { dg-warning "12:pointer" "bad conversion" } */ +char *c4 = (char *)&f; /* { dg-warning "12:pointer" "bad conversion" } */ +char *c5; +void (*fp)(void); +int a; + +void +g(void) +{ + v5 = f; /* { dg-warning "6:pointer" "bad conversion" } */ + v5 = &f; /* { dg-warning "6:pointer" "bad conversion" } */ + v5 = (void *)f; /* { dg-warning "8:pointer" "bad conversion" } */ + v5 = (void *)&f; /* { dg-warning "8:pointer" "bad conversion" } */ + c5 = f; /* { dg-error "6:pointer" "bad conversion" } */ + c5 = &f; /* { dg-error "6:pointer" "bad conversion" } */ + c5 = (char *)f; /* { dg-warning "8:pointer" "bad conversion" } */ + c5 = (char *)&f; /* { dg-warning "8:pointer" "bad conversion" } */ + fp = v5; /* { dg-warning "6:pointer" "bad conversion" } */ + fp = c5; /* { dg-error "6:pointer" "bad conversion" } */ + fp = (void (*)(void))v5; /* { dg-warning "8:pointer" "bad conversion" } */ + fp = (void (*)(void))c5; /* { dg-warning "8:pointer" "bad conversion" } */ + (a ? f : v3); /* { dg-warning "10:pointer" "bad conversion" } */ + (a ? v2 : fp); /* { dg-warning "11:pointer" "bad conversion" } */ + /* The following are OK. */ + fp = 0; + fp = (void *)0; + fp = 0L; + fp = (void (*)(void))0; + fp = (void (*)(void))(void *)0; + (a ? f : 0); + (a ? f : (void *)0); + (a ? (void *)0 : fp); + (a ? 0 : fp); +} + +/* The following are OK. */ +void (*fp2)(void) = 0; +void (*fp3)(void) = (void *)0; diff --git a/gcc/testsuite/gcc.dg/init-bad-7.c b/gcc/testsuite/gcc.dg/init-bad-7.c index de5e570978c..caa8c783d65 100644 --- a/gcc/testsuite/gcc.dg/init-bad-7.c +++ b/gcc/testsuite/gcc.dg/init-bad-7.c @@ -1,6 +1,6 @@ /* PR c/37724 */ /* { dg-do compile } */ -/* { dg-options "-std=gnu99 -pedantic" } */ +/* { dg-options "-fpermissive -std=gnu99 -pedantic" } */ struct f { diff --git a/gcc/testsuite/gcc.dg/init-bad-7a.c b/gcc/testsuite/gcc.dg/init-bad-7a.c new file mode 100644 index 00000000000..9ead2901c4c --- /dev/null +++ b/gcc/testsuite/gcc.dg/init-bad-7a.c @@ -0,0 +1,12 @@ +/* PR c/37724 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct f +{ + int *a; +}; + +char b[10]; +struct f g = {b}; /* { dg-error "initialization of 'int \\*' from incompatible pointer type" } */ +/* { dg-note "near initialization for" "" { target *-*-* } .-1 } */ diff --git a/gcc/testsuite/gcc.dg/noncompile/incomplete-3.c b/gcc/testsuite/gcc.dg/noncompile/incomplete-3.c index 0618b4d8170..b783052d145 100644 --- a/gcc/testsuite/gcc.dg/noncompile/incomplete-3.c +++ b/gcc/testsuite/gcc.dg/noncompile/incomplete-3.c @@ -4,6 +4,6 @@ typedef struct { int a; } b_t; int foo (void) { b_t d; - struct b_t *c = &d; /* { dg-warning "incompatible pointer type" } */ + struct b_t *c = &d; /* { dg-error "incompatible pointer type" } */ c->a; /* { dg-error "invalid use of undefined type" } */ } diff --git a/gcc/testsuite/gcc.dg/param-type-mismatch-2.c b/gcc/testsuite/gcc.dg/param-type-mismatch-2.c index 91d998437d1..83bc360fbc9 100644 --- a/gcc/testsuite/gcc.dg/param-type-mismatch-2.c +++ b/gcc/testsuite/gcc.dg/param-type-mismatch-2.c @@ -152,7 +152,7 @@ extern int callee_8 (int one, float *two, float (three)); /* { dg-line callee_8 int test_8 (int first, int *second, float third) { - return callee_8 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_8' from incompatible pointer type" } */ + return callee_8 (first, second, third); /* { dg-error "passing argument 2 of 'callee_8' from incompatible pointer type" } */ /* { dg-begin-multiline-output "" } return callee_8 (first, second, third); ^~~~~~ diff --git a/gcc/testsuite/gcc.dg/permerror-default.c b/gcc/testsuite/gcc.dg/permerror-default.c index 9ed9814d69e..45b58b0131d 100644 --- a/gcc/testsuite/gcc.dg/permerror-default.c +++ b/gcc/testsuite/gcc.dg/permerror-default.c @@ -52,24 +52,24 @@ int * incompatible_pointer_types (int flag) { void f4 (int *); - flag ? __builtin_abs : __builtin_labs; /* { dg-warning "pointer type mismatch in conditional expression \\\[-Wincompatible-pointer-types\\\]" } */ + flag ? __builtin_abs : __builtin_labs; /* { dg-error "pointer type mismatch in conditional expression \\\[-Wincompatible-pointer-types\\\]" } */ { - int *p1 = __builtin_abs; /* { dg-warning "initialization of 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ - p1 = __builtin_abs; /* { dg-warning "assignment to 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + int *p1 = __builtin_abs; /* { dg-error "initialization of 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + p1 = __builtin_abs; /* { dg-error "assignment to 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ } { - int *p2 = incompatible_pointer_types; /* { dg-warning "initialization of 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ - p2 = incompatible_pointer_types; /* { dg-warning "assignment to 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + int *p2 = incompatible_pointer_types; /* { dg-error "initialization of 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + p2 = incompatible_pointer_types; /* { dg-error "assignment to 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ { - int *p3 = &p2; /* { dg-warning "initialization of 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ - p3 = &p2; /* { dg-warning "assignment to 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + int *p3 = &p2; /* { dg-error "initialization of 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + p3 = &p2; /* { dg-error "assignment to 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ } - f4 (&p2); /* { dg-warning "passing argument 1 of 'f4' from incompatible pointer type \\\[-Wincompatible-pointer-types\\\]" } */ + f4 (&p2); /* { dg-error "passing argument 1 of 'f4' from incompatible pointer type \\\[-Wincompatible-pointer-types\\\]" } */ } if (flag) - return __builtin_abs; /* { dg-warning "returning pointer to '__builtin_abs' of type 'int \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + return __builtin_abs; /* { dg-error "returning pointer to '__builtin_abs' of type 'int \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ else - return incompatible_pointer_types; /* { dg-warning "returning 'int \\\* \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible return type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + return incompatible_pointer_types; /* { dg-error "returning 'int \\\* \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible return type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ } void diff --git a/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c b/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c index dc282a44489..93504b94139 100644 --- a/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c +++ b/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c @@ -54,22 +54,22 @@ incompatible_pointer_types (int flag) void f4 (int *); flag ? __builtin_abs : __builtin_labs; /* { dg-warning "pointer type mismatch in conditional expression \\\[-Wincompatible-pointer-types\\\]" } */ { - int *p1 = __builtin_abs; /* { dg-warning "initialization of 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ - p1 = __builtin_abs; /* { dg-warning "assignment to 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + int *p1 = __builtin_abs; /* { dg-error "initialization of 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + p1 = __builtin_abs; /* { dg-error "assignment to 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ } { - int *p2 = incompatible_pointer_types; /* { dg-warning "initialization of 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ - p2 = incompatible_pointer_types; /* { dg-warning "assignment to 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + int *p2 = incompatible_pointer_types; /* { dg-error "initialization of 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ + p2 = incompatible_pointer_types; /* { dg-error "assignment to 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ { - int *p3 = &p2; /* { dg-warning "initialization of 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ - p3 = &p2; /* { dg-warning "assignment to 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + int *p3 = &p2; /* { dg-error "initialization of 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + p3 = &p2; /* { dg-error "assignment to 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" } */ } - f4 (&p2); /* { dg-warning "passing argument 1 of 'f4' from incompatible pointer type \\\[-Wincompatible-pointer-types\\\]" } */ + f4 (&p2); /* { dg-error "passing argument 1 of 'f4' from incompatible pointer type \\\[-Wincompatible-pointer-types\\\]" } */ } if (flag) - return __builtin_abs; /* { dg-warning "returning pointer to '__builtin_abs' of type 'int \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + return __builtin_abs; /* { dg-error "returning pointer to '__builtin_abs' of type 'int \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ else - return incompatible_pointer_types; /* { dg-warning "returning 'int \\\* \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible return type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ + return incompatible_pointer_types; /* { dg-error "returning 'int \\\* \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible return type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" } */ } void diff --git a/gcc/testsuite/gcc.dg/permerror-pedantic.c b/gcc/testsuite/gcc.dg/permerror-pedantic.c index 852e7daa38d..95dda18acd4 100644 --- a/gcc/testsuite/gcc.dg/permerror-pedantic.c +++ b/gcc/testsuite/gcc.dg/permerror-pedantic.c @@ -52,7 +52,7 @@ int * incompatible_pointer_types (int flag) { void f4 (int *); - flag ? __builtin_abs : __builtin_labs; /* { dg-warning "pointer type mismatch in conditional expression \\\[-Wincompatible-pointer-types\\\]" } */ + flag ? __builtin_abs : __builtin_labs; /* { dg-error "pointer type mismatch in conditional expression \\\[-Wincompatible-pointer-types\\\]" } */ { int *p1 = __builtin_abs; /* { dg-error "initialization of 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ p1 = __builtin_abs; /* { dg-error "assignment to 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" } */ diff --git a/gcc/testsuite/gcc.dg/permerror-system.c b/gcc/testsuite/gcc.dg/permerror-system.c index f00420358d9..bd923138461 100644 --- a/gcc/testsuite/gcc.dg/permerror-system.c +++ b/gcc/testsuite/gcc.dg/permerror-system.c @@ -28,5 +28,16 @@ /* { dg-error "assignment to 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" "" { target *-*-* } 46 } */ /* { dg-error "returning 'int \\\*' from a function with return type 'int' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" "" { target *-*-* } 48 } */ +/* { dg-error "pointer type mismatch in conditional expression \\\[-Wincompatible-pointer-types\\\]" "" { target *-*-* } 55 } */ +/* { dg-error "initialization of 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" "" { target *-*-* } 57 } */ +/* { dg-error "assignment to 'int \\\*' from pointer to '__builtin_abs' with incompatible type 'int \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" "" { target *-*-* } 58 } */ +/* { dg-error "initialization of 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" "" { target *-*-* } 61 } */ +/* { dg-error "assignment to 'int \\\*' from incompatible pointer type 'int \\\* \\\(\\\*\\\)\\\(int\\\)' \\\[-Wincompatible-pointer-types\\\]" "" { target *-*-* } 62 } */ +/* { dg-error "initialization of 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" "" { target *-*-* } 64 } */ +/* { dg-error "assignment to 'int \\\*' from incompatible pointer type 'int \\\*\\\*' \\\[-Wincompatible-pointer-types\\\]" "" { target *-*-* } 65 } */ +/* { dg-error "passing argument 1 of 'f4' from incompatible pointer type \\\[-Wincompatible-pointer-types\\\]" "" { target *-*-* } 67 } */ +/* { dg-error "returning pointer to '__builtin_abs' of type 'int \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" "" { target *-*-* } 70 } */ +/* { dg-error "returning 'int \\\* \\\(\\\*\\\)\\\(int\\\)' from a function with incompatible return type 'int \\\*' \\\[-Wincompatible-pointer-types\\\]" "" { target *-*-* } 72 } */ + /* { dg-error "'return' with a value, in function returning void \\\[-Wreturn-mismatch\\\]" "" { target *-*-* } 78 } */ /* { dg-error "return' with no value, in function returning non-void \\\[-Wreturn-mismatch\\\]" "" { target *-*-* } 84 } */ diff --git a/gcc/testsuite/gcc.dg/pointer-array-atomic-2.c b/gcc/testsuite/gcc.dg/pointer-array-atomic-2.c new file mode 100644 index 00000000000..de63ff141a3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pointer-array-atomic-2.c @@ -0,0 +1,60 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c11" } */ +/* Origin: Martin Uecker */ +void tvoid(void* x); +void transpose0(double* out, _Atomic double* in) { } +void transpose1(double out[2][2], _Atomic double in[2][2]) { } +void transpose2(double out[2][2][2], _Atomic double in[2][2][2]) { } +// return +int (*x2(_Atomic int x[3][3]))[3] { return x; } /* { dg-error "returning '_Atomic int \\(\\*\\)\\\[3\\\]' from a function with incompatible return type" } */ +_Atomic int (*x3(int x[3][3]))[3] { return x; } /* { dg-error "returning 'int \\(\\*\\)\\\[3\\\]' from a function with incompatible return type" } */ +void test(void) +{ + double x0[2]; + double y0[2]; + _Atomic double z0[4]; + double x1[2][2]; + double y1[2][2]; + double o1[2][3]; + _Atomic double z1[2][2]; + double x2[2][2][2]; + double y2[2][2][2]; + double o2[2][2][3]; + _Atomic double z2[2][2][2]; + tvoid(z0); + tvoid(z1); + tvoid(z2); + // passing as arguments + transpose0(y0, x0); /* { dg-error "passing argument 2 of 'transpose0' from incompatible pointer type" } */ + transpose1(y1, o1); /* { dg-error "passing argument 2 of 'transpose1' from incompatible pointer type" } */ + transpose1(y1, x1); /* { dg-error "passing argument 2 of 'transpose1' from incompatible pointer type" } */ + transpose2(y2, o2); /* { dg-error "passing argument 2 of 'transpose2' from incompatible pointer type" } */ + transpose2(y2, x2); /* { dg-error "passing argument 2 of 'transpose2' from incompatible pointer type" } */ + // initialization + _Atomic double (*x0p) = x0; /* { dg-error "initialization of '_Atomic double \\*' from incompatible pointer type" } */ + _Atomic double (*x1p)[2] = x1; /* { dg-error "initialization of '_Atomic double \\(\\*\\)\\\[2\\\]' from incompatible pointer type" } */ + _Atomic double (*x2p)[2][2] = x2; /* { dg-error "initialization of '_Atomic double \\(\\*\\)\\\[2\\\]\\\[2\\\]' from incompatible pointer type" } */ + // assignment + x0p = x0; /* { dg-error "assignment to '_Atomic double \\*' from incompatible pointer type" } */ + x1p = x1; /* { dg-error "assignment to '_Atomic double \\(\\*\\)\\\[2\\\]' from incompatible pointer type" } */ + x2p = x2; /* { dg-error "assignment to '_Atomic double \\(\\*\\)\\\[2\\\]\\\[2\\\]' from incompatible pointer type" } */ + // subtraction + &(x0[1]) - &(z0[0]); /* { dg-error "invalid operands to binary" } */ + &(x1[1]) - &(z1[0]); /* { dg-error "invalid operands to binary" } */ + &(x2[1]) - &(z2[0]); /* { dg-error "invalid operands to binary" } */ + // comparison + x0 == z0; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */ + x1 == z1; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */ + x2 == z2; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */ + x0 > z0; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */ + x1 > z1; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */ + x2 > z2; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */ + x0 < z0; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */ + x1 < z1; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */ + x2 < z2; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */ + // conditional expressions + (void)(1 ? x0 : z0); /* { dg-error "pointer type mismatch in conditional expression" } */ + (void)(1 ? x1 : z1); /* { dg-error "pointer type mismatch in conditional expression" } */ + (void)(1 ? x2 : z2); /* { dg-error "pointer type mismatch in conditional expression" } */ +} + diff --git a/gcc/testsuite/gcc.dg/pointer-array-atomic.c b/gcc/testsuite/gcc.dg/pointer-array-atomic.c index bb63797b237..87d177a71a4 100644 --- a/gcc/testsuite/gcc.dg/pointer-array-atomic.c +++ b/gcc/testsuite/gcc.dg/pointer-array-atomic.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-std=c11" } */ +/* { dg-options "-fpermissive -std=c11" } */ /* Origin: Martin Uecker */ void tvoid(void* x); void transpose0(double* out, _Atomic double* in) { } diff --git a/gcc/testsuite/gcc.dg/pointer-array-quals-1.c b/gcc/testsuite/gcc.dg/pointer-array-quals-1.c index 498ab223162..be80912723a 100644 --- a/gcc/testsuite/gcc.dg/pointer-array-quals-1.c +++ b/gcc/testsuite/gcc.dg/pointer-array-quals-1.c @@ -84,9 +84,9 @@ void test(void) (void)(1 ? x0 : z0); (void)(1 ? x1 : z1); (void)(1 ? x2 : z2); - (void)(1 ? x0 : x1); /* { dg-warning "pointer type mismatch in conditional expression" } */ - (void)(1 ? x1 : x2); /* { dg-warning "pointer type mismatch in conditional expression" } */ - (void)(1 ? x2 : x0); /* { dg-warning "pointer type mismatch in conditional expression" } */ + (void)(1 ? x0 : x1); /* { dg-error "pointer type mismatch in conditional expression" } */ + (void)(1 ? x1 : x2); /* { dg-error "pointer type mismatch in conditional expression" } */ + (void)(1 ? x2 : x0); /* { dg-error "pointer type mismatch in conditional expression" } */ v0p = (1 ? z0 : v0p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ v1p = (1 ? z1 : v1p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ v2p = (1 ? z2 : v2p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ diff --git a/gcc/testsuite/gcc.dg/transparent-union-1.c b/gcc/testsuite/gcc.dg/transparent-union-1.c index 3f0c260c906..518adfb6ce0 100644 --- a/gcc/testsuite/gcc.dg/transparent-union-1.c +++ b/gcc/testsuite/gcc.dg/transparent-union-1.c @@ -1,6 +1,6 @@ /* PR c/20043 */ /* { dg-do compile } */ -/* { dg-options "-std=gnu99" } */ +/* { dg-options "-fpermissive -std=gnu99" } */ extern void f0 (int *); extern void f0 (int *__restrict); diff --git a/gcc/testsuite/gcc.dg/transparent-union-1a.c b/gcc/testsuite/gcc.dg/transparent-union-1a.c new file mode 100644 index 00000000000..9796ceab490 --- /dev/null +++ b/gcc/testsuite/gcc.dg/transparent-union-1a.c @@ -0,0 +1,85 @@ +/* PR c/20043 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +extern void f0 (int *); +extern void f0 (int *__restrict); + +extern void f1 (int *__restrict); +extern void f1 (int *); + +typedef union { int *i; long *l; } U2 + __attribute__((transparent_union)); +extern void f2 (U2); +extern void f2 (int *); + +typedef union { int *__restrict i; long *__restrict l; } U3 + __attribute__((transparent_union)); +extern void f3 (U3); +extern void f3 (int *__restrict); + +extern void f4 (U3); +extern void f4 (int *); + +extern void f5 (U2); +extern void f5 (int *__restrict); + +typedef union { long *l; int *i; } U6 + __attribute__((transparent_union)); +extern void f6 (U6); +extern void f6 (int *); + +typedef union { long *__restrict l; int *__restrict i; } U7 + __attribute__((transparent_union)); +extern void f7 (U7); +extern void f7 (int *__restrict); + +extern void f8 (U7); +extern void f8 (int *); + +extern void f9 (U6); +extern void f9 (int *__restrict); + +extern void f10 (U2); +extern void f11 (U3); +extern void f12 (U6); +extern void f13 (U7); + +int i; +long l; + +int +main (void) +{ + f0 (&i); + f0 (&l); /* { dg-error "passing argument 1 of 'f0' from incompatible pointer type" } */ + f1 (&i); + f1 (&l); /* { dg-error "passing argument 1 of 'f1' from incompatible pointer type" } */ + f2 (&i); + f2 (&l); /* { dg-error "passing argument 1 of 'f2' from incompatible pointer type" } */ + f3 (&i); + f3 (&l); /* { dg-error "passing argument 1 of 'f3' from incompatible pointer type" } */ + f4 (&i); + f4 (&l); /* { dg-error "passing argument 1 of 'f4' from incompatible pointer type" } */ + f5 (&i); + f5 (&l); /* { dg-error "passing argument 1 of 'f5' from incompatible pointer type" } */ + f6 (&i); + f6 (&l); /* { dg-error "passing argument 1 of 'f6' from incompatible pointer type" } */ + f7 (&i); + f7 (&l); /* { dg-error "passing argument 1 of 'f7' from incompatible pointer type" } */ + f8 (&i); + f8 (&l); /* { dg-error "passing argument 1 of 'f8' from incompatible pointer type" } */ + f9 (&i); + f9 (&l); /* { dg-error "passing argument 1 of 'f9' from incompatible pointer type" } */ + f10 (&i); + f10 (&l); + f11 (&i); + f11 (&l); + f12 (&i); + f12 (&l); + f13 (&i); + f13 (&l); + return 0; +} + +/* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.target/aarch64/acle/memtag_2a.c b/gcc/testsuite/gcc.target/aarch64/acle/memtag_2a.c index 16db40df663..9ae371d8867 100644 --- a/gcc/testsuite/gcc.target/aarch64/acle/memtag_2a.c +++ b/gcc/testsuite/gcc.target/aarch64/acle/memtag_2a.c @@ -17,12 +17,12 @@ test_memtag_warning_return_qualifier (void) v = __arm_mte_get_tag(c); /* { dg-warning {assignment} } */ n = __arm_mte_get_tag(c); /* { dg-warning {assignment} } */ - i = __arm_mte_get_tag(c); /* { dg-warning {assignment} } */ + i = __arm_mte_get_tag(c); /* { dg-error {assignment} } */ c = __arm_mte_get_tag(v); /* { dg-warning {assignment} } */ n = __arm_mte_get_tag(v); /* { dg-warning {assignment} } */ - i = __arm_mte_create_random_tag (c, 0); /* { dg-warning {assignment} } */ - i = __arm_mte_increment_tag (c, 0); /* { dg-warning {assignment} } */ + i = __arm_mte_create_random_tag (c, 0); /* { dg-error {assignment} } */ + i = __arm_mte_increment_tag (c, 0); /* { dg-error {assignment} } */ c = __arm_mte_get_tag(n); /* No warning. */ d = __arm_mte_ptrdiff(c, i); /* No warning. */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_2.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_2.c index a8288762695..5f4cbeaea2e 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_2.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_2.c @@ -15,8 +15,8 @@ f1 (svbool_t pg, signed char *s8_ptr, void *void_ptr, struct s *s_ptr, svld1_s8 (pg, 0); svld1_s32 (pg, (int32_t *) 0); svld1_s8 (pg, void_ptr); - svld1_s8 (pg, s_ptr); /* { dg-warning {passing argument 2 of 'svld1_s8' from incompatible pointer type} } */ + svld1_s8 (pg, s_ptr); /* { dg-error {passing argument 2 of 'svld1_s8' from incompatible pointer type} } */ svld1_f32 (pg, f32_ptr); - svld1_f32 (pg, cf32_ptr); /* { dg-warning {passing argument 2 of 'svld1_f32' from incompatible pointer type} } */ + svld1_f32 (pg, cf32_ptr); /* { dg-error {passing argument 2 of 'svld1_f32' from incompatible pointer type} } */ return svld1_s8 (pg, s8_ptr); /* { dg-error {incompatible types when returning type 'svint8_t' but 'svuint8_t' was expected} } */ } diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_1.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_1.c index cd849f89941..41bf2da0fab 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_1.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_1.c @@ -14,7 +14,7 @@ f1 (svbool_t pg, signed char *s8_ptr, short *s16_ptr, svld1sb_gather_offset (pg, s8_ptr, s32); /* { dg-error {implicit declaration of function 'svld1sb_gather_offset'; did you mean 'svld1_gather_offset'} } */ svld1sb_gather_offset_s32 (pg, s8_ptr); /* { dg-error {too few arguments to function 'svld1sb_gather_offset_s32'} } */ svld1sb_gather_offset_s32 (pg, s8_ptr, s32, 0); /* { dg-error {too many arguments to function 'svld1sb_gather_offset_s32'} } */ - svld1sb_gather_offset_s32 (pg, s16_ptr, s32); /* { dg-warning {passing argument 2 of 'svld1sb_gather_s32offset_s32' from incompatible pointer type} } */ + svld1sb_gather_offset_s32 (pg, s16_ptr, s32); /* { dg-error {passing argument 2 of 'svld1sb_gather_s32offset_s32' from incompatible pointer type} } */ svld1sb_gather_offset_s32 (pg, s8_ptr, pg); /* { dg-error {passing 'svbool_t' to argument 3 of 'svld1sb_gather_offset_s32', which expects a vector of 32-bit integers} } */ svld1sb_gather_offset_s32 (pg, s8_ptr, s8); /* { dg-error {passing 'svint8_t' to argument 3 of 'svld1sb_gather_offset_s32', which expects a vector of 32-bit integers} } */ svld1sb_gather_offset_s32 (pg, s8_ptr, s16); /* { dg-error {passing 'svint16_t' to argument 3 of 'svld1sb_gather_offset_s32', which expects a vector of 32-bit integers} } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_2.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_2.c index 850eecf99f6..1261b49d487 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_2.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_2.c @@ -14,7 +14,7 @@ f1 (svbool_t pg, signed char *s8_ptr, short *s16_ptr, svld1sb_gather_offset (pg, s8_ptr, s32); /* { dg-error {implicit declaration of function 'svld1sb_gather_offset'; did you mean 'svld1_gather_offset'} } */ svld1sb_gather_offset_u32 (pg, s8_ptr); /* { dg-error {too few arguments to function 'svld1sb_gather_offset_u32'} } */ svld1sb_gather_offset_u32 (pg, s8_ptr, s32, 0); /* { dg-error {too many arguments to function 'svld1sb_gather_offset_u32'} } */ - svld1sb_gather_offset_u32 (pg, s16_ptr, s32); /* { dg-warning {passing argument 2 of 'svld1sb_gather_s32offset_u32' from incompatible pointer type} } */ + svld1sb_gather_offset_u32 (pg, s16_ptr, s32); /* { dg-error {passing argument 2 of 'svld1sb_gather_s32offset_u32' from incompatible pointer type} } */ svld1sb_gather_offset_u32 (pg, s8_ptr, pg); /* { dg-error {passing 'svbool_t' to argument 3 of 'svld1sb_gather_offset_u32', which expects a vector of 32-bit integers} } */ svld1sb_gather_offset_u32 (pg, s8_ptr, s8); /* { dg-error {passing 'svint8_t' to argument 3 of 'svld1sb_gather_offset_u32', which expects a vector of 32-bit integers} } */ svld1sb_gather_offset_u32 (pg, s8_ptr, s16); /* { dg-error {passing 'svint16_t' to argument 3 of 'svld1sb_gather_offset_u32', which expects a vector of 32-bit integers} } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_3.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_3.c index 93a728593f9..518348d1146 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_3.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_3.c @@ -14,7 +14,7 @@ f1 (svbool_t pg, signed char *s8_ptr, short *s16_ptr, svld1sb_gather_offset (pg, s8_ptr, s64); /* { dg-error {implicit declaration of function 'svld1sb_gather_offset'; did you mean 'svld1_gather_offset'} } */ svld1sb_gather_offset_s64 (pg, s8_ptr); /* { dg-error {too few arguments to function 'svld1sb_gather_offset_s64'} } */ svld1sb_gather_offset_s64 (pg, s8_ptr, s64, 0); /* { dg-error {too many arguments to function 'svld1sb_gather_offset_s64'} } */ - svld1sb_gather_offset_s64 (pg, s16_ptr, s64); /* { dg-warning {passing argument 2 of 'svld1sb_gather_s64offset_s64' from incompatible pointer type} } */ + svld1sb_gather_offset_s64 (pg, s16_ptr, s64); /* { dg-error {passing argument 2 of 'svld1sb_gather_s64offset_s64' from incompatible pointer type} } */ svld1sb_gather_offset_s64 (pg, s8_ptr, pg); /* { dg-error {passing 'svbool_t' to argument 3 of 'svld1sb_gather_offset_s64', which expects a vector of 64-bit integers} } */ svld1sb_gather_offset_s64 (pg, s8_ptr, s8); /* { dg-error {passing 'svint8_t' to argument 3 of 'svld1sb_gather_offset_s64', which expects a vector of 64-bit integers} } */ svld1sb_gather_offset_s64 (pg, s8_ptr, s16); /* { dg-error {passing 'svint16_t' to argument 3 of 'svld1sb_gather_offset_s64', which expects a vector of 64-bit integers} } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_4.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_4.c index d54dc8eafab..6086911fd5d 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_4.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_4.c @@ -14,7 +14,7 @@ f1 (svbool_t pg, signed char *s8_ptr, short *s16_ptr, svld1sb_gather_offset (pg, s8_ptr, s64); /* { dg-error {implicit declaration of function 'svld1sb_gather_offset'; did you mean 'svld1_gather_offset'} } */ svld1sb_gather_offset_u64 (pg, s8_ptr); /* { dg-error {too few arguments to function 'svld1sb_gather_offset_u64'} } */ svld1sb_gather_offset_u64 (pg, s8_ptr, s64, 0); /* { dg-error {too many arguments to function 'svld1sb_gather_offset_u64'} } */ - svld1sb_gather_offset_u64 (pg, s16_ptr, s64); /* { dg-warning {passing argument 2 of 'svld1sb_gather_s64offset_u64' from incompatible pointer type} } */ + svld1sb_gather_offset_u64 (pg, s16_ptr, s64); /* { dg-error {passing argument 2 of 'svld1sb_gather_s64offset_u64' from incompatible pointer type} } */ svld1sb_gather_offset_u64 (pg, s8_ptr, pg); /* { dg-error {passing 'svbool_t' to argument 3 of 'svld1sb_gather_offset_u64', which expects a vector of 64-bit integers} } */ svld1sb_gather_offset_u64 (pg, s8_ptr, s8); /* { dg-error {passing 'svint8_t' to argument 3 of 'svld1sb_gather_offset_u64', which expects a vector of 64-bit integers} } */ svld1sb_gather_offset_u64 (pg, s8_ptr, s16); /* { dg-error {passing 'svint16_t' to argument 3 of 'svld1sb_gather_offset_u64', which expects a vector of 64-bit integers} } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_5.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_5.c index 3b521d5c141..9e2cceec2e9 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_5.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_5.c @@ -14,7 +14,7 @@ f1 (svbool_t pg, unsigned char *s8_ptr, unsigned short *s16_ptr, svld1ub_gather_offset (pg, s8_ptr, s32); /* { dg-error {implicit declaration of function 'svld1ub_gather_offset'; did you mean 'svld1_gather_offset'} } */ svld1ub_gather_offset_s32 (pg, s8_ptr); /* { dg-error {too few arguments to function 'svld1ub_gather_offset_s32'} } */ svld1ub_gather_offset_s32 (pg, s8_ptr, s32, 0); /* { dg-error {too many arguments to function 'svld1ub_gather_offset_s32'} } */ - svld1ub_gather_offset_s32 (pg, s16_ptr, s32); /* { dg-warning {passing argument 2 of 'svld1ub_gather_s32offset_s32' from incompatible pointer type} } */ + svld1ub_gather_offset_s32 (pg, s16_ptr, s32); /* { dg-error {passing argument 2 of 'svld1ub_gather_s32offset_s32' from incompatible pointer type} } */ svld1ub_gather_offset_s32 (pg, s8_ptr, pg); /* { dg-error {passing 'svbool_t' to argument 3 of 'svld1ub_gather_offset_s32', which expects a vector of 32-bit integers} } */ svld1ub_gather_offset_s32 (pg, s8_ptr, s8); /* { dg-error {passing 'svint8_t' to argument 3 of 'svld1ub_gather_offset_s32', which expects a vector of 32-bit integers} } */ svld1ub_gather_offset_s32 (pg, s8_ptr, s16); /* { dg-error {passing 'svint16_t' to argument 3 of 'svld1ub_gather_offset_s32', which expects a vector of 32-bit integers} } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_1.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_1.c index 96d8ad55074..18e16630944 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_1.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_1.c @@ -16,7 +16,7 @@ f1 (svbool_t pg, signed char *s8_ptr, short *s16_ptr, svldnt1sb_gather_offset (pg, s8_ptr, s32); /* { dg-error {implicit declaration of function 'svldnt1sb_gather_offset'; did you mean 'svldnt1_gather_offset'} } */ svldnt1sb_gather_offset_s32 (pg, s8_ptr); /* { dg-error {too few arguments to function 'svldnt1sb_gather_offset_s32'} } */ svldnt1sb_gather_offset_s32 (pg, s8_ptr, u32, 0); /* { dg-error {too many arguments to function 'svldnt1sb_gather_offset_s32'} } */ - svldnt1sb_gather_offset_s32 (pg, s16_ptr, u32); /* { dg-warning {passing argument 2 of 'svldnt1sb_gather_u32offset_s32' from incompatible pointer type} } */ + svldnt1sb_gather_offset_s32 (pg, s16_ptr, u32); /* { dg-error {passing argument 2 of 'svldnt1sb_gather_u32offset_s32' from incompatible pointer type} } */ svldnt1sb_gather_offset_s32 (pg, s8_ptr, pg); /* { dg-error {passing 'svbool_t' to argument 3 of 'svldnt1sb_gather_offset_s32', which expects a vector of 32-bit integers} } */ svldnt1sb_gather_offset_s32 (pg, s8_ptr, s8); /* { dg-error {passing 'svint8_t' to argument 3 of 'svldnt1sb_gather_offset_s32', which expects a vector of 32-bit integers} } */ svldnt1sb_gather_offset_s32 (pg, s8_ptr, s16); /* { dg-error {passing 'svint16_t' to argument 3 of 'svldnt1sb_gather_offset_s32', which expects a vector of 32-bit integers} } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_2.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_2.c index 25ce7268a1e..6bb9998bff5 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_2.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_2.c @@ -16,7 +16,7 @@ f1 (svbool_t pg, signed char *s8_ptr, short *s16_ptr, svldnt1sb_gather_offset (pg, s8_ptr, s32); /* { dg-error {implicit declaration of function 'svldnt1sb_gather_offset'; did you mean 'svldnt1_gather_offset'} } */ svldnt1sb_gather_offset_u32 (pg, s8_ptr); /* { dg-error {too few arguments to function 'svldnt1sb_gather_offset_u32'} } */ svldnt1sb_gather_offset_u32 (pg, s8_ptr, u32, 0); /* { dg-error {too many arguments to function 'svldnt1sb_gather_offset_u32'} } */ - svldnt1sb_gather_offset_u32 (pg, s16_ptr, u32); /* { dg-warning {passing argument 2 of 'svldnt1sb_gather_u32offset_u32' from incompatible pointer type} } */ + svldnt1sb_gather_offset_u32 (pg, s16_ptr, u32); /* { dg-error {passing argument 2 of 'svldnt1sb_gather_u32offset_u32' from incompatible pointer type} } */ svldnt1sb_gather_offset_u32 (pg, s8_ptr, pg); /* { dg-error {passing 'svbool_t' to argument 3 of 'svldnt1sb_gather_offset_u32', which expects a vector of 32-bit integers} } */ svldnt1sb_gather_offset_u32 (pg, s8_ptr, s8); /* { dg-error {passing 'svint8_t' to argument 3 of 'svldnt1sb_gather_offset_u32', which expects a vector of 32-bit integers} } */ svldnt1sb_gather_offset_u32 (pg, s8_ptr, s16); /* { dg-error {passing 'svint16_t' to argument 3 of 'svldnt1sb_gather_offset_u32', which expects a vector of 32-bit integers} } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_3.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_3.c index 04465f251b1..8dc160ce9c3 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_3.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_3.c @@ -16,7 +16,7 @@ f1 (svbool_t pg, signed char *s8_ptr, short *s16_ptr, svldnt1sb_gather_offset (pg, s8_ptr, s64); /* { dg-error {implicit declaration of function 'svldnt1sb_gather_offset'; did you mean 'svldnt1_gather_offset'} } */ svldnt1sb_gather_offset_s64 (pg, s8_ptr); /* { dg-error {too few arguments to function 'svldnt1sb_gather_offset_s64'} } */ svldnt1sb_gather_offset_s64 (pg, s8_ptr, s64, 0); /* { dg-error {too many arguments to function 'svldnt1sb_gather_offset_s64'} } */ - svldnt1sb_gather_offset_s64 (pg, s16_ptr, s64); /* { dg-warning {passing argument 2 of 'svldnt1sb_gather_s64offset_s64' from incompatible pointer type} } */ + svldnt1sb_gather_offset_s64 (pg, s16_ptr, s64); /* { dg-error {passing argument 2 of 'svldnt1sb_gather_s64offset_s64' from incompatible pointer type} } */ svldnt1sb_gather_offset_s64 (pg, s8_ptr, pg); /* { dg-error {passing 'svbool_t' to argument 3 of 'svldnt1sb_gather_offset_s64', which expects a vector of 64-bit integers} } */ svldnt1sb_gather_offset_s64 (pg, s8_ptr, s8); /* { dg-error {passing 'svint8_t' to argument 3 of 'svldnt1sb_gather_offset_s64', which expects a vector of 64-bit integers} } */ svldnt1sb_gather_offset_s64 (pg, s8_ptr, s16); /* { dg-error {passing 'svint16_t' to argument 3 of 'svldnt1sb_gather_offset_s64', which expects a vector of 64-bit integers} } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_4.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_4.c index 479be66996d..9a418f28089 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_4.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_4.c @@ -16,7 +16,7 @@ f1 (svbool_t pg, signed char *s8_ptr, short *s16_ptr, svldnt1sb_gather_offset (pg, s8_ptr, s64); /* { dg-error {implicit declaration of function 'svldnt1sb_gather_offset'; did you mean 'svldnt1_gather_offset'} } */ svldnt1sb_gather_offset_u64 (pg, s8_ptr); /* { dg-error {too few arguments to function 'svldnt1sb_gather_offset_u64'} } */ svldnt1sb_gather_offset_u64 (pg, s8_ptr, s64, 0); /* { dg-error {too many arguments to function 'svldnt1sb_gather_offset_u64'} } */ - svldnt1sb_gather_offset_u64 (pg, s16_ptr, s64); /* { dg-warning {passing argument 2 of 'svldnt1sb_gather_s64offset_u64' from incompatible pointer type} } */ + svldnt1sb_gather_offset_u64 (pg, s16_ptr, s64); /* { dg-error {passing argument 2 of 'svldnt1sb_gather_s64offset_u64' from incompatible pointer type} } */ svldnt1sb_gather_offset_u64 (pg, s8_ptr, pg); /* { dg-error {passing 'svbool_t' to argument 3 of 'svldnt1sb_gather_offset_u64', which expects a vector of 64-bit integers} } */ svldnt1sb_gather_offset_u64 (pg, s8_ptr, s8); /* { dg-error {passing 'svint8_t' to argument 3 of 'svldnt1sb_gather_offset_u64', which expects a vector of 64-bit integers} } */ svldnt1sb_gather_offset_u64 (pg, s8_ptr, s16); /* { dg-error {passing 'svint16_t' to argument 3 of 'svldnt1sb_gather_offset_u64', which expects a vector of 64-bit integers} } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-1.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-1.c index 01cfd14f873..b0389fa00a8 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-1.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-1.c @@ -105,8 +105,8 @@ statements (int n) /* Pointer assignment. */ - gnu_sc_ptr = sve_sc_ptr; /* { dg-warning {assignment to [^\n]* from incompatible pointer type} } */ - sve_sc_ptr = gnu_sc_ptr; /* { dg-warning {assignment to [^\n]* from incompatible pointer type} } */ + gnu_sc_ptr = sve_sc_ptr; /* { dg-error {assignment to [^\n]* from incompatible pointer type} } */ + sve_sc_ptr = gnu_sc_ptr; /* { dg-error {assignment to [^\n]* from incompatible pointer type} } */ /* Pointer arithmetic. */ @@ -153,8 +153,8 @@ statements (int n) 0 ? 0 : sve_sc1; /* { dg-error {type mismatch in conditional expression} } */ 0 ?: sve_sc1; /* { dg-error {type mismatch in conditional expression} } */ 0 ? sve_sc_ptr : sve_sc_ptr; - 0 ? sve_sc_ptr : gnu_sc_ptr; /* { dg-warning {pointer type mismatch in conditional expression} } */ - 0 ? gnu_sc_ptr : sve_sc_ptr; /* { dg-warning {pointer type mismatch in conditional expression} } */ + 0 ? sve_sc_ptr : gnu_sc_ptr; /* { dg-error {pointer type mismatch in conditional expression} } */ + 0 ? gnu_sc_ptr : sve_sc_ptr; /* { dg-error {pointer type mismatch in conditional expression} } */ /* Generic associations. */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-2.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-2.c index 613b9c47878..d16f40b5f2a 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-2.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-2.c @@ -105,8 +105,8 @@ statements (int n) /* Pointer assignment. */ - gnu_sc_ptr = sve_sc_ptr; /* { dg-warning {incompatible pointer type} } */ - sve_sc_ptr = gnu_sc_ptr; /* { dg-warning {incompatible pointer type} } */ + gnu_sc_ptr = sve_sc_ptr; /* { dg-error {incompatible pointer type} } */ + sve_sc_ptr = gnu_sc_ptr; /* { dg-error {incompatible pointer type} } */ /* Pointer arithmetic. */ @@ -153,8 +153,8 @@ statements (int n) 0 ? 0 : sve_sc1; /* { dg-error {type mismatch in conditional expression} } */ 0 ?: sve_sc1; /* { dg-error {type mismatch in conditional expression} } */ 0 ? sve_sc_ptr : sve_sc_ptr; - 0 ? sve_sc_ptr : gnu_sc_ptr; /* { dg-warning {pointer type mismatch} } */ - 0 ? gnu_sc_ptr : sve_sc_ptr; /* { dg-warning {pointer type mismatch} } */ + 0 ? sve_sc_ptr : gnu_sc_ptr; /* { dg-error {pointer type mismatch} } */ + 0 ? gnu_sc_ptr : sve_sc_ptr; /* { dg-error {pointer type mismatch} } */ /* Generic associations. */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_1.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_1.c index 625f059af44..3669b3088a7 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_1.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_1.c @@ -16,11 +16,11 @@ f1 (svbool_t pg, signed char *s8_ptr, void *void_ptr, struct s *s_ptr, svst1 (pg, void_ptr, 0); /* { dg-error {passing 'int' to argument 3 of 'svst1', which expects an SVE vector type} } */ svst1 (pg, void_ptr, pg); /* { dg-error {'svst1' has no form that takes 'svbool_t' arguments} } */ svst1 (pg, 0, s8); - svst1 (pg, (int32_t *) 0, s8); /* { dg-warning "passing argument 2 of 'svst1_s8' from incompatible pointer type" } */ + svst1 (pg, (int32_t *) 0, s8); /* { dg-error "passing argument 2 of 'svst1_s8' from incompatible pointer type" } */ svst1 (pg, void_ptr, s8); - svst1 (pg, s_ptr, s8); /* { dg-warning "passing argument 2 of 'svst1_s8' from incompatible pointer type" } */ - svst1 (pg, f32_ptr, s8); /* { dg-warning "passing argument 2 of 'svst1_s8' from incompatible pointer type" } */ + svst1 (pg, s_ptr, s8); /* { dg-error "passing argument 2 of 'svst1_s8' from incompatible pointer type" } */ + svst1 (pg, f32_ptr, s8); /* { dg-error "passing argument 2 of 'svst1_s8' from incompatible pointer type" } */ svst1 (pg, f32_ptr, f32); - svst1 (pg, cf32_ptr, f32); /* { dg-warning "passing argument 2 of 'svst1_f32' from incompatible pointer type" } */ + svst1 (pg, cf32_ptr, f32); /* { dg-error "passing argument 2 of 'svst1_f32' from incompatible pointer type" } */ svst1 (pg, s, s8); /* { dg-error {passing 'struct s' to argument 2 of 'svst1', which expects a scalar pointer} } */ } diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_2.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_2.c index 669f8844bc1..30a0a4c8586 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_2.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_2.c @@ -18,10 +18,10 @@ f1 (svbool_t pg, signed char *s8_ptr, void *void_ptr, struct s *s_ptr, svst1_vnum (pg, void_ptr, 0, 0); /* { dg-error {passing 'int' to argument 4 of 'svst1_vnum', which expects an SVE vector type} } */ svst1_vnum (pg, void_ptr, 0, pg); /* { dg-error {'svst1_vnum' has no form that takes 'svbool_t' arguments} } */ svst1_vnum (pg, 0, 0, s8); - svst1_vnum (pg, (int32_t *) 0, 0, s8); /* { dg-warning "passing argument 2 of 'svst1_vnum_s8' from incompatible pointer type" } */ + svst1_vnum (pg, (int32_t *) 0, 0, s8); /* { dg-error "passing argument 2 of 'svst1_vnum_s8' from incompatible pointer type" } */ svst1_vnum (pg, void_ptr, 0, s8); - svst1_vnum (pg, s_ptr, 0, s8); /* { dg-warning "passing argument 2 of 'svst1_vnum_s8' from incompatible pointer type" } */ - svst1_vnum (pg, f32_ptr, 0, s8); /* { dg-warning "passing argument 2 of 'svst1_vnum_s8' from incompatible pointer type" } */ + svst1_vnum (pg, s_ptr, 0, s8); /* { dg-error "passing argument 2 of 'svst1_vnum_s8' from incompatible pointer type" } */ + svst1_vnum (pg, f32_ptr, 0, s8); /* { dg-error "passing argument 2 of 'svst1_vnum_s8' from incompatible pointer type" } */ svst1_vnum (pg, f32_ptr, 0, f32); - svst1_vnum (pg, cf32_ptr, 0, f32); /* { dg-warning "passing argument 2 of 'svst1_vnum_f32' from incompatible pointer type" } */ + svst1_vnum (pg, cf32_ptr, 0, f32); /* { dg-error "passing argument 2 of 'svst1_vnum_f32' from incompatible pointer type" } */ } diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_index_1.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_index_1.c index 29f4510c49b..21bd93afb3f 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_index_1.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_index_1.c @@ -20,10 +20,10 @@ f1 (svbool_t pg, signed char *s8_ptr, short *s16_ptr, svst1_scatter_index (pg, 0, s32, s32); svst1_scatter_index (pg, (int32_t *) 0, s32, s32); svst1_scatter_index (pg, void_ptr, s32, s32); - svst1_scatter_index (pg, s_ptr, s32, s32); /* { dg-warning "passing argument 2 of 'svst1_scatter_s32index_s32' from incompatible pointer type" } */ - svst1_scatter_index (pg, f32_ptr, s32, s32); /* { dg-warning "passing argument 2 of 'svst1_scatter_s32index_s32' from incompatible pointer type" } */ + svst1_scatter_index (pg, s_ptr, s32, s32); /* { dg-error "passing argument 2 of 'svst1_scatter_s32index_s32' from incompatible pointer type" } */ + svst1_scatter_index (pg, f32_ptr, s32, s32); /* { dg-error "passing argument 2 of 'svst1_scatter_s32index_s32' from incompatible pointer type" } */ svst1_scatter_index (pg, f32_ptr, s32, f32); - svst1_scatter_index (pg, cf32_ptr, s32, f32); /* { dg-warning "passing argument 2 of 'svst1_scatter_s32index_f32' from incompatible pointer type" } */ + svst1_scatter_index (pg, cf32_ptr, s32, f32); /* { dg-error "passing argument 2 of 'svst1_scatter_s32index_f32' from incompatible pointer type" } */ svst1_scatter_index (pg, s, s32, s32); /* { dg-error {passing 'struct s' to argument 2 of 'svst1_scatter_index', which expects a vector or pointer base address} } */ svst1_scatter_index (pg, u32, void_ptr, s32); /* { dg-error "passing argument 3 of 'svst1_scatter_u32base_index_s32' makes integer from pointer without a cast" } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_index_restricted_1.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_index_restricted_1.c index ab718b5eeee..ec99f8af23e 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_index_restricted_1.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_index_restricted_1.c @@ -22,10 +22,10 @@ f1 (svbool_t pg, signed char *s8_ptr, short *s16_ptr, svstnt1_scatter_index (pg, 0, s64, s64); svstnt1_scatter_index (pg, (int64_t *) 0, s64, s64); svstnt1_scatter_index (pg, void_ptr, s64, s64); - svstnt1_scatter_index (pg, s_ptr, s64, s64); /* { dg-warning "passing argument 2 of 'svstnt1_scatter_s64index_s64' from incompatible pointer type" } */ - svstnt1_scatter_index (pg, f32_ptr, s64, s64); /* { dg-warning "passing argument 2 of 'svstnt1_scatter_s64index_s64' from incompatible pointer type" } */ + svstnt1_scatter_index (pg, s_ptr, s64, s64); /* { dg-error "passing argument 2 of 'svstnt1_scatter_s64index_s64' from incompatible pointer type" } */ + svstnt1_scatter_index (pg, f32_ptr, s64, s64); /* { dg-error "passing argument 2 of 'svstnt1_scatter_s64index_s64' from incompatible pointer type" } */ svstnt1_scatter_index (pg, f64_ptr, s64, f64); - svstnt1_scatter_index (pg, cf64_ptr, s64, f64); /* { dg-warning "passing argument 2 of 'svstnt1_scatter_s64index_f64' from incompatible pointer type" } */ + svstnt1_scatter_index (pg, cf64_ptr, s64, f64); /* { dg-error "passing argument 2 of 'svstnt1_scatter_s64index_f64' from incompatible pointer type" } */ svstnt1_scatter_index (pg, s, s64, s64); /* { dg-error {passing 'struct s' to argument 2 of 'svstnt1_scatter_index', which expects a vector or pointer base address} } */ svstnt1_scatter_index (pg, u32, void_ptr, s32); /* { dg-error "passing argument 3 of 'svstnt1_scatter_u32base_index_s32' makes integer from pointer without a cast" } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_2.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_2.c index 311b1744c91..318f0dddfb1 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_2.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_2.c @@ -20,10 +20,10 @@ f1 (svbool_t pg, signed char *s8_ptr, short *s16_ptr, svst1_scatter_offset (pg, 0, s32, s32); svst1_scatter_offset (pg, (int32_t *) 0, s32, s32); svst1_scatter_offset (pg, void_ptr, s32, s32); - svst1_scatter_offset (pg, s_ptr, s32, s32); /* { dg-warning "passing argument 2 of 'svst1_scatter_s32offset_s32' from incompatible pointer type" } */ - svst1_scatter_offset (pg, f32_ptr, s32, s32); /* { dg-warning "passing argument 2 of 'svst1_scatter_s32offset_s32' from incompatible pointer type" } */ + svst1_scatter_offset (pg, s_ptr, s32, s32); /* { dg-error "passing argument 2 of 'svst1_scatter_s32offset_s32' from incompatible pointer type" } */ + svst1_scatter_offset (pg, f32_ptr, s32, s32); /* { dg-error "passing argument 2 of 'svst1_scatter_s32offset_s32' from incompatible pointer type" } */ svst1_scatter_offset (pg, f32_ptr, s32, f32); - svst1_scatter_offset (pg, cf32_ptr, s32, f32); /* { dg-warning "passing argument 2 of 'svst1_scatter_s32offset_f32' from incompatible pointer type" } */ + svst1_scatter_offset (pg, cf32_ptr, s32, f32); /* { dg-error "passing argument 2 of 'svst1_scatter_s32offset_f32' from incompatible pointer type" } */ svst1_scatter_offset (pg, s, s32, s32); /* { dg-error {passing 'struct s' to argument 2 of 'svst1_scatter_offset', which expects a vector or pointer base address} } */ svst1_scatter_offset (pg, u32, void_ptr, s32); /* { dg-error "passing argument 3 of 'svst1_scatter_u32base_offset_s32' makes integer from pointer without a cast" } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_restricted_1.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_restricted_1.c index 5b251127a47..74bd7aefd70 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_restricted_1.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_restricted_1.c @@ -22,10 +22,10 @@ f1 (svbool_t pg, signed char *s8_ptr, short *s16_ptr, svstnt1_scatter_offset (pg, 0, u32, s32); svstnt1_scatter_offset (pg, (int32_t *) 0, u32, s32); svstnt1_scatter_offset (pg, void_ptr, u32, s32); - svstnt1_scatter_offset (pg, s_ptr, u32, s32); /* { dg-warning "passing argument 2 of 'svstnt1_scatter_u32offset_s32' from incompatible pointer type" } */ - svstnt1_scatter_offset (pg, f32_ptr, u32, s32); /* { dg-warning "passing argument 2 of 'svstnt1_scatter_u32offset_s32' from incompatible pointer type" } */ + svstnt1_scatter_offset (pg, s_ptr, u32, s32); /* { dg-error "passing argument 2 of 'svstnt1_scatter_u32offset_s32' from incompatible pointer type" } */ + svstnt1_scatter_offset (pg, f32_ptr, u32, s32); /* { dg-error "passing argument 2 of 'svstnt1_scatter_u32offset_s32' from incompatible pointer type" } */ svstnt1_scatter_offset (pg, f32_ptr, u32, f32); - svstnt1_scatter_offset (pg, cf32_ptr, u32, f32); /* { dg-warning "passing argument 2 of 'svstnt1_scatter_u32offset_f32' from incompatible pointer type" } */ + svstnt1_scatter_offset (pg, cf32_ptr, u32, f32); /* { dg-error "passing argument 2 of 'svstnt1_scatter_u32offset_f32' from incompatible pointer type" } */ svstnt1_scatter_offset (pg, s, u32, s32); /* { dg-error {passing 'struct s' to argument 2 of 'svstnt1_scatter_offset', which expects a vector or pointer base address} } */ svstnt1_scatter_offset (pg, u32, void_ptr, s32); /* { dg-error "passing argument 3 of 'svstnt1_scatter_u32base_offset_s32' makes integer from pointer without a cast" } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/attributes_7.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/attributes_7.c index 95be60591fb..5658a206fa3 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/attributes_7.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/attributes_7.c @@ -135,41 +135,41 @@ g (int c) diff = gs8 - gs8; fs8 = ss8; // { dg-error {invalid conversion} "" { target c++ } } - // { dg-warning {incompatible pointer type} "c" { target c } .-1 } + // { dg-error {incompatible pointer type} "c" { target c } .-1 } fs8 = fs8; fs8 = gs8; // { dg-error {invalid conversion} "" { target c++ } } - // { dg-warning {incompatible pointer type} "c" { target c } .-1 } + // { dg-error {incompatible pointer type} "c" { target c } .-1 } fs8 = su8; // { dg-error {cannot convert} "c++" { target c++ } } - // { dg-warning {incompatible pointer type} "c" { target c } .-1 } + // { dg-error {incompatible pointer type} "c" { target c } .-1 } fs8 = fu8; // { dg-error {cannot convert} "c++" { target c++ } } - // { dg-warning {incompatible pointer type} "c" { target c } .-1 } + // { dg-error {incompatible pointer type} "c" { target c } .-1 } fs8 = gu8; // { dg-error {cannot convert} "c++" { target c++ } } - // { dg-warning {incompatible pointer type} "c" { target c } .-1 } + // { dg-error {incompatible pointer type} "c" { target c } .-1 } fs8 = ss16; // { dg-error {cannot convert} "c++" { target c++ } } - // { dg-warning {incompatible pointer type} "c" { target c } .-1 } + // { dg-error {incompatible pointer type} "c" { target c } .-1 } fs8 = fs16; // { dg-error {cannot convert} "c++" { target c++ } } - // { dg-warning {incompatible pointer type} "c" { target c } .-1 } + // { dg-error {incompatible pointer type} "c" { target c } .-1 } fs8 = gs16; // { dg-error {cannot convert} "c++" { target c++ } } - // { dg-warning {incompatible pointer type} "c" { target c } .-1 } + // { dg-error {incompatible pointer type} "c" { target c } .-1 } select = c ? ss8 : ss8; select = c ? ss8 : fs8; // { dg-error {distinct pointer types} "" { target c++ } } - // { dg-warning {pointer type mismatch} "c" { target c } .-1 } + // { dg-error {pointer type mismatch} "c" { target c } .-1 } select = c ? ss8 : gs8; // { dg-error {distinct pointer types} "" { target c++ } } - // { dg-warning {pointer type mismatch} "c" { target c } .-1 } + // { dg-error {pointer type mismatch} "c" { target c } .-1 } select = c ? fs8 : ss8; // { dg-error {distinct pointer types} "" { target c++ } } - // { dg-warning {pointer type mismatch} "c" { target c } .-1 } + // { dg-error {pointer type mismatch} "c" { target c } .-1 } select = c ? fs8 : fs8; select = c ? fs8 : gs8; // { dg-error {distinct pointer types} "" { target c++ } } - // { dg-warning {pointer type mismatch} "c" { target c } .-1 } + // { dg-error {pointer type mismatch} "c" { target c } .-1 } select = c ? gs8 : ss8; // { dg-error {distinct pointer types} "" { target c++ } } - // { dg-warning {pointer type mismatch} "c" { target c } .-1 } + // { dg-error {pointer type mismatch} "c" { target c } .-1 } select = c ? gs8 : fs8; // { dg-error {distinct pointer types} "" { target c++ } } - // { dg-warning {pointer type mismatch} "c" { target c } .-1 } + // { dg-error {pointer type mismatch} "c" { target c } .-1 } select = c ? gs8 : gs8; diff = sb - sb; // { dg-error {arithmetic on pointer to SVE type 'svbool_t'} } diff --git a/gcc/testsuite/gcc.target/i386/sse2-bfloat16-scalar-typecheck.c b/gcc/testsuite/gcc.target/i386/sse2-bfloat16-scalar-typecheck.c index d1a76db25e9..599b02632fd 100644 --- a/gcc/testsuite/gcc.target/i386/sse2-bfloat16-scalar-typecheck.c +++ b/gcc/testsuite/gcc.target/i386/sse2-bfloat16-scalar-typecheck.c @@ -181,8 +181,8 @@ __bf16 footest (__bf16 scalar0) 0 ? 0.1 : scalar0; 0 ? scalar0 : 0.1; 0 ? bfloat_ptr : bfloat_ptr2; - 0 ? bfloat_ptr : float_ptr; /* { dg-warning {pointer type mismatch in conditional expression} } */ - 0 ? float_ptr : bfloat_ptr; /* { dg-warning {pointer type mismatch in conditional expression} } */ + 0 ? bfloat_ptr : float_ptr; /* { dg-error {pointer type mismatch in conditional expression} } */ + 0 ? float_ptr : bfloat_ptr; /* { dg-error {pointer type mismatch in conditional expression} } */ scalar0 ? scalar0 : scalar0; scalar0 ? is_a_float : scalar0; diff --git a/gcc/testsuite/gcc.target/i386/vect-bfloat16-typecheck_1.c b/gcc/testsuite/gcc.target/i386/vect-bfloat16-typecheck_1.c index 8bc3f4a7b8f..f8bdf2e71fd 100644 --- a/gcc/testsuite/gcc.target/i386/vect-bfloat16-typecheck_1.c +++ b/gcc/testsuite/gcc.target/i386/vect-bfloat16-typecheck_1.c @@ -224,8 +224,8 @@ __m128bf16 footest (__m128bf16 vector0) 0 ? 0.1 : vector0; /* { dg-error {type mismatch in conditional expression} } */ 0 ? vector0 : 0.1; /* { dg-error {type mismatch in conditional expression} } */ 0 ? bfloat_ptr : bfloat_ptr2; - 0 ? bfloat_ptr : float_ptr; /* { dg-warning {pointer type mismatch in conditional expression} } */ - 0 ? float_ptr : bfloat_ptr; /* { dg-warning {pointer type mismatch in conditional expression} } */ + 0 ? bfloat_ptr : float_ptr; /* { dg-error {pointer type mismatch in conditional expression} } */ + 0 ? float_ptr : bfloat_ptr; /* { dg-error {pointer type mismatch in conditional expression} } */ vector0 ? vector0 : vector0; /* { dg-error {used vector type where scalar is required} } */ vector0 ? is_a_float16_vec : vector0; /* { dg-error {used vector type where scalar is required} } */ diff --git a/gcc/testsuite/gcc.target/i386/vect-bfloat16-typecheck_2.c b/gcc/testsuite/gcc.target/i386/vect-bfloat16-typecheck_2.c index 2a8a535daae..b6b7a430efa 100644 --- a/gcc/testsuite/gcc.target/i386/vect-bfloat16-typecheck_2.c +++ b/gcc/testsuite/gcc.target/i386/vect-bfloat16-typecheck_2.c @@ -214,8 +214,8 @@ __m256bf16 footest (__m256bf16 vector0) 0 ? 0.1 : vector0; /* { dg-error {type mismatch in conditional expression} } */ 0 ? vector0 : 0.1; /* { dg-error {type mismatch in conditional expression} } */ 0 ? bfloat_ptr : bfloat_ptr2; - 0 ? bfloat_ptr : float_ptr; /* { dg-warning {pointer type mismatch in conditional expression} } */ - 0 ? float_ptr : bfloat_ptr; /* { dg-warning {pointer type mismatch in conditional expression} } */ + 0 ? bfloat_ptr : float_ptr; /* { dg-error {pointer type mismatch in conditional expression} } */ + 0 ? float_ptr : bfloat_ptr; /* { dg-error {pointer type mismatch in conditional expression} } */ vector0 ? vector0 : vector0; /* { dg-error {used vector type where scalar is required} } */ vector0 ? is_a_float16_vec : vector0; /* { dg-error {used vector type where scalar is required} } */ From patchwork Mon Nov 20 09:56:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 167024 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp2090563vqn; Mon, 20 Nov 2023 01:58:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IGd9Jwi+iIvD4AuFHCn/PuIn3AAQQefkr+VQVkCwjP6Ep5y0sz2xX9TrsHWF4VHq8O0bUqu X-Received: by 2002:a05:620a:bc5:b0:77a:55b2:5dae with SMTP id s5-20020a05620a0bc500b0077a55b25daemr8671323qki.53.1700474333359; Mon, 20 Nov 2023 01:58:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700474333; cv=pass; d=google.com; s=arc-20160816; b=Kt80Mi0JQJIE/+uqVBlNb7TM4oGeV+xc4XfbhqfTJB8uLPSf8wWRM65hx972on/7mT Kr+/DV2SU29qmgV50AZHZ/psLeYaPNcmWUbLxPEsqVdiHDVrgrsO1tkNs7t41tCMsrOC Q5GBzmOWffHiJWNAmi+cYK20adPFk/Gam0fZTBFsCJ6BBN7bVNFmIAIwoamgTcKK3jLl vjS7ErPXf2J/WxCscDWZ+CsF3KbciD9ziptR6jGokZeQIQ0oV8m9lw9vRPoxa93wk1Km jHpvZSDKRGYtJKhA2dyiFhDtLA/rjaVKInarKqome0BMKM1kP9JbeE6LDDRCT0bJJ+RU TJpQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:user-agent:date:references:message-id:in-reply-to :subject:to:from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=B9Xtw36foXpldHnpj+O0uDIQCVuLID97f7xr/BLEFDI=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=tKMtArdddXgALBiW5/KBHL8D54hOwl5iMTi4eyAyThvZbxD16Y9M+hgouxI8z1IYTU 4y1qjHRegZ3pfX2i2aUZt2iU4bH5fH7JrVGZTHV7Zc3KtDmvevlGg96WcDUor5iaGtW9 CFD24cnN9y3nwre3xRk/Ml9FBTS37dfE2Wl6IPXudciwOs20xZhUJ7fusqJsBhXQ2jZM 2zhW0lzoYwXKhHq4j+c+4bIlEGqmbMYqEmEscppEGcMEeoanfzNhrcDlS+txxdIEH6Ge bMemGqfCrjfIR5SFmuTyMICasI8R8ItYQfYG08pYEmZFCCDAXG14SyydJ5j3Y+P+kue9 6DKg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bd+VmldI; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id z11-20020ae9e60b000000b0077be3adfac7si6688451qkf.217.2023.11.20.01.58.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 01:58:53 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bd+VmldI; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2B0233882166 for ; Mon, 20 Nov 2023 09:58:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 57205388266C for ; Mon, 20 Nov 2023 09:56:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 57205388266C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 57205388266C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700474209; cv=none; b=bcMavQkhbVOa2G2qF79SaFSEBS2IqhmfcMg2aDGb/HI7wigDYme4wBiZyZersQ90rWnw9qIR5JwBHWyWoclIsmmTrMjKh2wKJPTPhFtBj1ykLv56/uc7inG+zzwfb0PKqXspS1Sm/5/MhyIP/V7i29vofDQVK/fikGxaptGyF4Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700474209; c=relaxed/simple; bh=RYzwj2kJggj9eYo9Aswm1wZ1ERqypomiq/EfiOB24xg=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=GNnFeFWIUtSMrp7SCMyJCql258Oor2F1vthj3KtNCodoJtIkj/Yeztahslie0xm4CziMvSO76so0yrwVdXv6y8PFfGvHB1qmOMrECTXMQDHfqpUTHTALFhpyEga69FyeA3ZUx0DNk4f/QoiU+WtdlKs2SdLjHbvgN8EYxa9XxxA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700474206; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B9Xtw36foXpldHnpj+O0uDIQCVuLID97f7xr/BLEFDI=; b=bd+VmldIuwkH3lvbVpNZFkvL9M+a6eBmnvZY0GdHAdEBDrD8xkGHRGDtxkS2SsVRanDyPp HDzBrGgXzQs4g6lGSUEFzPLXSC2b/ybIDmC6Tiz1WOqX1wAeIT0VodBR35yAXJPRpX2KC4 /ToK61wWoIKW7tgvR1uvTz/eREDgtis= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-495-JSaDcjduMSSCDAGGnOqu0Q-1; Mon, 20 Nov 2023 04:56:45 -0500 X-MC-Unique: JSaDcjduMSSCDAGGnOqu0Q-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 10A15185A780 for ; Mon, 20 Nov 2023 09:56:45 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 38ED9492BE0 for ; Mon, 20 Nov 2023 09:56:44 +0000 (UTC) From: Florian Weimer To: gcc-patches@gcc.gnu.org Subject: [PATCH v3 11/11] c: Add new -Wdeclaration-missing-parameter-type permerror In-Reply-To: Message-ID: <700d70e4a2874645ddb67a8a335131d83b242e69.1700473918.git.fweimer@redhat.com> References: X-From-Line: 700d70e4a2874645ddb67a8a335131d83b242e69 Mon Sep 17 00:00:00 2001 Date: Mon, 20 Nov 2023 10:56:42 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783076574415887983 X-GMAIL-MSGID: 1783076574415887983 This used to be a warning, enabled by default, without its own option. A subsequent change could improve diagnostics and provide spelling hints for declarations like “void function (int32t);”. gcc/c-family/ * c.opt (Wdeclaration-missing-parameter-type): New. gcc/c/ChangeLog: PR other/44209 * c-decl.cc (grokparms): Issue permerror for OPT_Wdeclaration_missing_parameter_type instead of a pedwarn. gcc/ChangeLog: * doc/invoke.texi (Warning Options): Document -Wdeclaration-missing-parameter-type. gcc/testsuite/ChangeLog: * gcc.dg/permerror-default.c (missing_parameter_type): Expect error. * gcc.dg/permerror-fpermissive.c (missing_parameter_type): Expect -Wdeclaration-missing-parameter-type warning. * gcc.dg/permerror-gnu89-nopermissive.c (missing_parameter_type): Expect -Wdeclaration-missing-parameter-type error. * gcc.dg/permerror-gnu89-pedantic.c (missing_parameter_type): Likewise. * gcc.dg/permerror-gnu89.c (missing_parameter_type): Expect -Wdeclaration-missing-parameter-type warning. * gcc.dg/permerror-noerror.c: Add -Wno-error=declaration-missing-parameter-type to build flags. (missing_parameter_type): Expect -Wdeclaration-missing-parameter-type warning. * gcc.dg/permerror-nowarning.c: Build with -Wno-declaration-missing-parameter-type. Remove previously expected warning. * gcc.dg/permerror-fpermissive-nowarning.c: Likewise. * gcc.dg/permerror-pedantic.c (missing_parameter_type): Expect -Wdeclaration-missing-parameter-type error. * gcc.dg/permerror-system.c (missing_parameter_type): Likewise. --- gcc/c-family/c.opt | 4 ++++ gcc/c/c-decl.cc | 6 ++++-- gcc/doc/invoke.texi | 17 ++++++++++++++++- gcc/testsuite/gcc.dg/permerror-default.c | 2 +- .../gcc.dg/permerror-fpermissive-nowarning.c | 7 +------ gcc/testsuite/gcc.dg/permerror-fpermissive.c | 2 +- .../gcc.dg/permerror-gnu89-nopermissive.c | 2 +- gcc/testsuite/gcc.dg/permerror-gnu89-pedantic.c | 2 +- gcc/testsuite/gcc.dg/permerror-gnu89.c | 2 +- gcc/testsuite/gcc.dg/permerror-noerror.c | 4 ++-- gcc/testsuite/gcc.dg/permerror-nowarning.c | 7 +------ gcc/testsuite/gcc.dg/permerror-pedantic.c | 2 +- gcc/testsuite/gcc.dg/permerror-system.c | 2 ++ 13 files changed, 36 insertions(+), 23 deletions(-) diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index b10c6057cd1..723e8c3e27b 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -591,6 +591,10 @@ Wdeclaration-after-statement C ObjC Var(warn_declaration_after_statement) Init(-1) Warning Warn when a declaration is found after a statement. +Wdeclaration-missing-parameter-type +C ObjC Var(warn_declaration_missing_parameter) Warning Init(1) +Warn for missing parameter types in function declarations. + Wdelete-incomplete C++ ObjC++ Var(warn_delete_incomplete) Init(1) Warning Warn when deleting a pointer to incomplete type. diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index d16958113a8..3d9bee54259 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -8337,8 +8337,10 @@ grokparms (struct c_arg_info *arg_info, bool funcdef_flag) { if (!funcdef_flag) { - pedwarn (input_location, 0, "parameter names (without types) in " - "function declaration"); + permerror_opt (input_location, + OPT_Wdeclaration_missing_parameter_type, + "parameter names (without types) in " + "function declaration"); arg_info->parms = NULL_TREE; } else diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index be33da71c44..7f5da45dcea 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -504,7 +504,8 @@ Objective-C and Objective-C++ Dialects}. @item C and Objective-C-only Warning Options @gccoptlist{-Wbad-function-cast -Wmissing-declarations --Wmissing-parameter-type -Wmissing-prototypes -Wmissing-variable-declarations +-Wmissing-parameter-type -Wdeclaration-missing-parameter-type +-Wmissing-prototypes -Wmissing-variable-declarations -Wnested-externs -Wold-style-declaration -Wold-style-definition -Wstrict-prototypes -Wtraditional -Wtraditional-conversion -Wdeclaration-after-statement -Wpointer-sign} @@ -9734,6 +9735,20 @@ void foo(bar) @{ @} This warning is also enabled by @option{-Wextra}. +@opindex Wno-declaration-missing-parameter-type +@opindex Wdeclaration-missing-parameter-type +@item -Wno-declaration-missing-parameter-type @r{(C and Objective-C only)} +Do not warn if a function declaration contains a parameter name without +a type. Such function declarations do not provide a function prototype +and prevent most type checking in function calls. + +This warning is enabled by default. In C99 and later dialects of C, it +is treated as an error. The error can be downgraded to a warning using +@option{-fpermissive} (along with certain other errors), or for this +error alone, with @option{-Wno-error=declaration-missing-parameter-type}. + +This warning is upgraded to an error by @option{-pedantic-errors}. + @opindex Wmissing-prototypes @opindex Wno-missing-prototypes @item -Wmissing-prototypes @r{(C and Objective-C only)} diff --git a/gcc/testsuite/gcc.dg/permerror-default.c b/gcc/testsuite/gcc.dg/permerror-default.c index 45b58b0131d..c674d689081 100644 --- a/gcc/testsuite/gcc.dg/permerror-default.c +++ b/gcc/testsuite/gcc.dg/permerror-default.c @@ -19,7 +19,7 @@ implicit_int_4 (i) /* { dg-error "return type defaults to 'int' \\\[-Wimplicit-i (const) 0; /* { dg-error "type defaults to 'int' in type name \\\[-Wimplicit-int\\\]" } */ } -extern int missing_parameter_type (i); /* { dg-warning "parameter names \\\(without types\\\) in function declaration\n" } */ +extern int missing_parameter_type (i); /* { dg-error "parameter names \\\(without types\\\) in function declaration \\\[-Wdeclaration-missing-parameter-type\\\]" } */ int * diff --git a/gcc/testsuite/gcc.dg/permerror-fpermissive-nowarning.c b/gcc/testsuite/gcc.dg/permerror-fpermissive-nowarning.c index f15b21ef43d..d07c8636677 100644 --- a/gcc/testsuite/gcc.dg/permerror-fpermissive-nowarning.c +++ b/gcc/testsuite/gcc.dg/permerror-fpermissive-nowarning.c @@ -1,11 +1,6 @@ -/* { dg-options "-fpermissive -Wno-implicit-function-declaration -Wno-implicit-int -Wno-int-conversion -Wno-incompatible-pointer-types -Wno-return-mismatch" } */ +/* { dg-options "-fpermissive -Wno-implicit-function-declaration -Wno-implicit-int -Wno-int-conversion -Wno-incompatible-pointer-types -Wno-return-mismatch -Wno-declaration-missing-parameter-type" } */ /* This test checks that permerrors can be disabled using -Wno-* options even if -fpermissive is used. */ #include "permerror-default.c" - -/* Ideally, we do not want to see any warnings here, but this warning is not - yet controlled by its own option. */ - -/* { dg-warning "parameter names \\\(without types\\\) in function declaration\n" "" { target *-*-* } 22 } */ diff --git a/gcc/testsuite/gcc.dg/permerror-fpermissive.c b/gcc/testsuite/gcc.dg/permerror-fpermissive.c index 139f35ad1c0..fd3020d75ee 100644 --- a/gcc/testsuite/gcc.dg/permerror-fpermissive.c +++ b/gcc/testsuite/gcc.dg/permerror-fpermissive.c @@ -19,7 +19,7 @@ implicit_int_4 (i) /* { dg-warning "return type defaults to 'int' \\\[-Wimplicit (const) 0; /* { dg-warning "type defaults to 'int' in type name \\\[-Wimplicit-int\\\]" } */ } -extern int missing_parameter_type (i); /* { dg-warning "parameter names \\\(without types\\\) in function declaration\n" } */ +extern int missing_parameter_type (i); /* { dg-warning "parameter names \\\(without types\\\) in function declaration \\\[-Wdeclaration-missing-parameter-type\\\]" } */ int * diff --git a/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c b/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c index 93504b94139..aba4b2498f7 100644 --- a/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c +++ b/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c @@ -19,7 +19,7 @@ implicit_int_4 (i) /* { dg-bogus "-Wimplicit-int" } */ (const) 0; /* { dg-bogus "-Wimplicit-int" } */ } -extern int missing_parameter_type (i); /* { dg-warning "parameter names \\\(without types\\\) in function declaration\n" } */ +extern int missing_parameter_type (i); /* { dg-error "parameter names \\\(without types\\\) in function declaration \\\[-Wdeclaration-missing-parameter-type\\\]" } */ int * diff --git a/gcc/testsuite/gcc.dg/permerror-gnu89-pedantic.c b/gcc/testsuite/gcc.dg/permerror-gnu89-pedantic.c index 465a16f5f9a..ef4dbfc86c5 100644 --- a/gcc/testsuite/gcc.dg/permerror-gnu89-pedantic.c +++ b/gcc/testsuite/gcc.dg/permerror-gnu89-pedantic.c @@ -19,7 +19,7 @@ implicit_int_4 (i) /* { dg-bogus "-Wimplicit-int" } */ (const) 0; /* { dg-bogus "-Wimplicit-int" } */ } -extern int missing_parameter_type (i); /* { dg-error "parameter names \\\(without types\\\) in function declaration\n" } */ +extern int missing_parameter_type (i); /* { dg-error "parameter names \\\(without types\\\) in function declaration \\\[-Wdeclaration-missing-parameter-type\\\]" } */ int * diff --git a/gcc/testsuite/gcc.dg/permerror-gnu89.c b/gcc/testsuite/gcc.dg/permerror-gnu89.c index 66f7789269f..83792ecfaac 100644 --- a/gcc/testsuite/gcc.dg/permerror-gnu89.c +++ b/gcc/testsuite/gcc.dg/permerror-gnu89.c @@ -19,7 +19,7 @@ implicit_int_4 (i) /* { dg-bogus "-Wimplicit-int" } */ (const) 0; /* { dg-bogus "-Wimplicit-int" } */ } -extern int missing_parameter_type (i); /* { dg-warning "parameter names \\\(without types\\\) in function declaration\n" } */ +extern int missing_parameter_type (i); /* { dg-warning "parameter names \\\(without types\\\) in function declaration \\\[-Wdeclaration-missing-parameter-type\\\]" } */ int * diff --git a/gcc/testsuite/gcc.dg/permerror-noerror.c b/gcc/testsuite/gcc.dg/permerror-noerror.c index cd1c2013cb5..fc68dfa8bb9 100644 --- a/gcc/testsuite/gcc.dg/permerror-noerror.c +++ b/gcc/testsuite/gcc.dg/permerror-noerror.c @@ -1,4 +1,4 @@ -/* { dg-options "-Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=int-conversion -Wno-error=incompatible-pointer-types -Wno-error=return-mismatch" } */ +/* { dg-options "-Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=int-conversion -Wno-error=incompatible-pointer-types -Wno-error=return-mismatch -Wno-error=declaration-missing-parameter-type" } */ /* This test should emulate the effect of -fpermissive by adding all the -Wno-error= options that are implied by -fpermissive. It needs to be @@ -19,7 +19,7 @@ implicit_int_4 (i) /* { dg-warning "return type defaults to 'int' \\\[-Wimplicit (const) 0; /* { dg-warning "type defaults to 'int' in type name \\\[-Wimplicit-int\\\]" } */ } -extern int missing_parameter_type (i); /* { dg-warning "parameter names \\\(without types\\\) in function declaration\n" } */ +extern int missing_parameter_type (i); /* { dg-warning "parameter names \\\(without types\\\) in function declaration \\\[-Wdeclaration-missing-parameter-type\\\]" } */ int * diff --git a/gcc/testsuite/gcc.dg/permerror-nowarning.c b/gcc/testsuite/gcc.dg/permerror-nowarning.c index da6bd08245d..b1cf7990127 100644 --- a/gcc/testsuite/gcc.dg/permerror-nowarning.c +++ b/gcc/testsuite/gcc.dg/permerror-nowarning.c @@ -1,10 +1,5 @@ -/* { dg-options "-Wno-implicit-function-declaration -Wno-implicit-int -Wno-int-conversion -Wno-incompatible-pointer-types -Wno-return-mismatch" } */ +/* { dg-options "-Wno-implicit-function-declaration -Wno-implicit-int -Wno-int-conversion -Wno-incompatible-pointer-types -Wno-return-mismatch -Wno-declaration-missing-parameter-type" } */ /* This test checks that permerrors can be disabled using -Wno-* options. */ #include "permerror-default.c" - -/* Ideally, we do not want to see any warnings here, but this warning is not - yet controlled by its own option. */ - -/* { dg-warning "parameter names \\\(without types\\\) in function declaration\n" "" { target *-*-* } 22 } */ diff --git a/gcc/testsuite/gcc.dg/permerror-pedantic.c b/gcc/testsuite/gcc.dg/permerror-pedantic.c index 95dda18acd4..2380bb2583c 100644 --- a/gcc/testsuite/gcc.dg/permerror-pedantic.c +++ b/gcc/testsuite/gcc.dg/permerror-pedantic.c @@ -19,7 +19,7 @@ implicit_int_4 (i) /* { dg-error "return type defaults to 'int' \\\[-Wimplicit-i (const) 0; /* { dg-error "type defaults to 'int' in type name \\\[-Wimplicit-int\\\]" } */ } -extern int missing_parameter_type (i); /* { dg-error "parameter names \\\(without types\\\) in function declaration\n" } */ +extern int missing_parameter_type (i); /* { dg-error "parameter names \\\(without types\\\) in function declaration \\\[-Wdeclaration-missing-parameter-type\\\]" } */ int * diff --git a/gcc/testsuite/gcc.dg/permerror-system.c b/gcc/testsuite/gcc.dg/permerror-system.c index bd923138461..790e4f03d66 100644 --- a/gcc/testsuite/gcc.dg/permerror-system.c +++ b/gcc/testsuite/gcc.dg/permerror-system.c @@ -17,6 +17,8 @@ /* { dg-error "type of 'i' defaults to 'int' \\\[-Wimplicit-int\\\]" "" { target *-*-*} 16 } */ /* { dg-error "type defaults to 'int' in type name \\\[-Wimplicit-int\\\]" "" { target *-*-* } 19 } */ +/* { dg-error "parameter names \\\(without types\\\) in function declaration \\\[-Wdeclaration-missing-parameter-type\\\]" "" { target *-*-* } 22 } */ + /* { dg-error "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" "" { target *-*-* } 29 } */ /* { dg-error "pointer/integer type mismatch in conditional expression \\\[-Wint-conversion\\\]" "" { target *-*-* } 30 } */ /* { dg-error "passing argument 1 of 'f2' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" "" { target *-*-* } 31 } */