From patchwork Fri Feb 13 19:07:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 439614 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D9151400B7 for ; Sat, 14 Feb 2015 06:07:28 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=rvcoNhkVGwHCWx38NtqN42up3idPylJxAP++CW32EUnGkDGFZOCik 9uTJtxBk+9BKaegxfGLB9Hd3rSaPaYrY4TO6bWtAaSkeiVY86sCzgXrxJqESYTBu QUFyhI1bPQEz4995w5/IXdaJNNyzj6i3ongDKyJFg2GgCyYz15yAYI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=MpKIsuguCuvZqkO7aDml70rQRY8=; b=mlyRGS1LYEM0RCHsboAA f9Xn6X0shxuLIbWs9doq83LDRn4sFvNg8j6SL5gQrKaycWL7aUvL+tZ4schTqu2o f+3L0mNa+Qm86a13Xl9+Sbvr4h3A+5NpDfPyvZWmKIpihrYzJuf+XYcgGp0Cgzlh alSOdsl5lrX6vl4nCVRquZw= Received: (qmail 26276 invoked by alias); 13 Feb 2015 19:07:21 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 26261 invoked by uid 89); 13 Feb 2015 19:07:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 13 Feb 2015 19:07:19 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1DJ7GLe013066 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 13 Feb 2015 14:07:16 -0500 Received: from redhat.com ([10.40.204.30]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1DJ7Cf5004979 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Fri, 13 Feb 2015 14:07:15 -0500 Date: Fri, 13 Feb 2015 20:07:12 +0100 From: Marek Polacek To: GCC Patches , Joseph Myers Subject: [C PATCH] Improve diagnostics a tiny bit (PR c/65050) Message-ID: <20150213190712.GD23138@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This patch tweaks an error message a little bit so that we also print the type we're talking about. This is neither a regression nor a bug fix - should I queue this for GCC 6, or is it so minor that it can still go into GCC 5? Bootstrapped/regtested on ppc64-linux. 2015-02-13 Marek Polacek PR c/65050 * c-decl.c (grokdeclarator): Print also the type when giving the error message about array's incomplete element type. * gcc.dg/pr65050.c: New test. Marek diff --git gcc/c/c-decl.c gcc/c/c-decl.c index 48c2bcb..4fd3239 100644 --- gcc/c/c-decl.c +++ gcc/c/c-decl.c @@ -5962,7 +5962,8 @@ grokdeclarator (const struct c_declarator *declarator, /* Complain about arrays of incomplete types. */ if (!COMPLETE_TYPE_P (type)) { - error_at (loc, "array type has incomplete element type"); + error_at (loc, "array type has incomplete element type %qT", + type); type = error_mark_node; } else diff --git gcc/testsuite/gcc.dg/pr65050.c gcc/testsuite/gcc.dg/pr65050.c index e69de29..0822a99 100644 --- gcc/testsuite/gcc.dg/pr65050.c +++ gcc/testsuite/gcc.dg/pr65050.c @@ -0,0 +1,23 @@ +/* PR c/65050 */ +/* { dg-do compile } */ + +typedef int A[]; +struct S { int i; A a[5]; } s; /* { dg-error "array type has incomplete element type .A {aka int\\\[\\\]}." } */ +extern void foo (int p[2][]); /* { dg-error "array type has incomplete element type .int\\\[\\\]." } */ +extern void bar (A p[2]); /* { dg-error "array type has incomplete element type .A {aka int\\\[\\\]}." } */ + +void +foo (int p[2][]) /* { dg-error "array type has incomplete element type .int\\\[\\\]." } */ +{ +} + +void +bar (A p[2]) /* { dg-error "array type has incomplete element type .A {aka int\\\[\\\]}." } */ +{ +} + +struct T; +struct T t[5]; /* { dg-error "array type has incomplete element type .struct T." } */ +struct U u[] = { { "abc" } }; /* { dg-error "array type has incomplete element type .struct U." } */ +typedef struct T TT; +TT tt[5]; /* { dg-error "array type has incomplete element type .TT {aka struct T}." } */