From patchwork Wed Dec 5 01:04:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 203747 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]) by ozlabs.org (Postfix) with SMTP id 603C82C0082 for ; Wed, 5 Dec 2012 12:04:41 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1355274282; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=/+U4BE4 XZ24v2b2n+44AslURtgY=; b=DAOHfItJa0mXNKyyAZyaesklg+RGmpsdy7jtlz3 +yoaW3kN2hB9WI9TUgUGiI3cGJaeIm82BM/eyEd2QEYaVH5bKd/Lq9+WBF2Yhx+N xJKd3X6I0hWAqeU8TpN7MFbwZUu7m+KaF8JZioQ9Op2t8ynW9mk2SA4M5PJkGFP3 m2Zk= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=mZjhhrLWcMFegRwHXxE4T6uDKziy7x8Vo9MAblFMRjSA3TUZ3XsbheNu+lDbdJ mN0+CS/2S/Jph8nqGA08N7R7yUPuT5Rpg+SZj15TNNVEP9xh+C7f6YOLcpvz7nXk uCwmuIW6f2xtReQ6xrvNcQWOjQpyF/ETzZs431gf7pCK4=; Received: (qmail 11828 invoked by alias); 5 Dec 2012 01:04:37 -0000 Received: (qmail 11803 invoked by uid 22791); 5 Dec 2012 01:04:36 -0000 X-SWARE-Spam-Status: No, hits=-4.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mail-pb0-f47.google.com (HELO mail-pb0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 05 Dec 2012 01:04:31 +0000 Received: by mail-pb0-f47.google.com with SMTP id un1so2937581pbc.20 for ; Tue, 04 Dec 2012 17:04:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type:x-gm-message-state; bh=Xo3Zu0ErOJuyQqIta+RPpGLEOahQawdyf+dLCW4u1bI=; b=h46GoNRyJILnLbC4Gbo2CeyubAiE2zsy5fSEGG0vYPynKiwQk7AF79gy9CRWGZPENS 860ELaC98FX+5dKF6Jx+/f3LTxz7FAj3AXV3ROLFXJ+wxWX6/b0wSH01KEVojEjXSPbS QUlppz29JnCfeODe8fGpGHMklqbwZ+IRu7k8HnHviE2mWAcZbnBYgSgWx/B190xIFbxO Bh3GDYvO4yYxgom71Z0oeCykz7b6dSwwXMEfH+17oro+vkS5AIIMS68YaQXqYH9Mh6w5 HnSM/22vvGOSyy/Q3uvpRWJ5H/0ere8skgaLp+rAUb5V9cYrdcz5qc6onUQbkelek7RP JxrQ== Received: by 10.66.79.72 with SMTP id h8mr39520489pax.49.1354669471223; Tue, 04 Dec 2012 17:04:31 -0800 (PST) Received: from coign.google.com ([2401:fa00:0:9:224:d7ff:fe8f:f634]) by mx.google.com with ESMTPS id iu8sm1841353pbc.71.2012.12.04.17.04.28 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 04 Dec 2012 17:04:30 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Make sure we give error for call to non-function Date: Tue, 04 Dec 2012 17:04:25 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQnwYxh6cgFEnUBWn5MZPUO7Zvi9tHzRMu5v/sX+eTyTo1K5EvlrMhw5yytGcBL8oLg31HuHhcgMtXDlIJKOyD1KxPXoz+m/mYBHYWLjmLAutS3lokmPGz/4qltCZ0edg5aQDE/yqtt4JrlkftvaQhPYJF5VBLLLxFXPxjme+3CR4cOT2VeA6876M1XMp24i0HyV8ycF X-IsSubscribed: yes 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 Because of the efforts the Go frontend takes to avoid knock-on errors, it was possible for some erroneous code to get through without an error message. Specifically, code like v().NonexistentFunction() would not produce an error when v was not a function. This patch fixes that problem. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline and 4.7 branch. Ian diff -r 39b613a05301 -r 76d51e7d9209 go/expressions.cc --- a/go/expressions.cc Tue Dec 04 16:21:16 2012 -0800 +++ b/go/expressions.cc Tue Dec 04 16:52:53 2012 -0800 @@ -8544,6 +8544,16 @@ return Expression::make_cast(this->fn_->type(), this->args_->front(), loc); + // Because do_type will return an error type and thus prevent future + // errors, check for that case now to ensure that the error gets + // reported. + if (this->get_function_type() == NULL) + { + if (!this->fn_->type()->is_error()) + this->report_error(_("expected function")); + return Expression::make_error(loc); + } + // Recognize a call to a builtin function. Func_expression* fne = this->fn_->func_expression(); if (fne != NULL