From patchwork Mon Jul 9 19:48:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Endo X-Patchwork-Id: 169946 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 4AC822C01FA for ; Tue, 10 Jul 2012 05:49:20 +1000 (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=1342468161; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Subject:From:To:Date:Content-Type:Mime-Version: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=enQvXOWsHFlgkj/EnZCt e0pmF5M=; b=iQWjtn137tsgEBRWcA5g1Vfyq86IEJBJks60EVy8sHi9fUeLrlu3 OUDAQ7lncK+N9mMl4e9CKwtuZrMJ9qHaDqb1fLWudw9FJ55SfhivABj240uN8qTB XzPqTOyHvzZw2B4lJAO0Ry/huz275w1Zvun+P7cLQEYzSCgs0pGqvJg= 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:Received:Message-ID:Subject:From:To:Date:Content-Type:Mime-Version:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=yXnjqlxDLGHrJkCOCi3AjcoeXSTrWNCfFGxwzzWb2TFx1B05MiF46cyJbF/f7F pHiR2ralwVvh2LJZH2COCfCXhXoWtzRcPiWXqaSlVrocdd00nZb7GN1yNz3tTqRQ zxnhIdzZUFBYG0a6bbT/9LAWx0euwEa/B/lTquRh+4JS4=; Received: (qmail 29003 invoked by alias); 9 Jul 2012 19:49:15 -0000 Received: (qmail 28993 invoked by uid 22791); 9 Jul 2012 19:49:14 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_NO, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org Received: from mailout02.t-online.de (HELO mailout02.t-online.de) (194.25.134.17) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 09 Jul 2012 19:49:01 +0000 Received: from fwd15.aul.t-online.de (fwd15.aul.t-online.de ) by mailout02.t-online.de with smtp id 1SoJx5-0000OJ-Io; Mon, 09 Jul 2012 21:48:59 +0200 Received: from [192.168.0.100] (TD0Z0iZQrhWruA9AGsyXrQ7ltjNIj-w9YRloZ4wN3JaxR7aAiLZN9jbx8TtMkTigWu@[93.218.163.145]) by fwd15.t-online.de with esmtp id 1SoJx2-0dYI9g0; Mon, 9 Jul 2012 21:48:56 +0200 Message-ID: <1341863330.2292.26.camel@yam-132-YW-E178-FTW> Subject: [SH] Test case for PR 53886 From: Oleg Endo To: gcc-patches Date: Mon, 09 Jul 2012 21:48:50 +0200 Mime-Version: 1.0 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 Hello, The attached patch adds a c.torture/compile test case for PR 53886. The test case is a slightly modified version of the preprocessed example in the PR (added forward decls to remove warnings). Tested on rev 189361 with make check-gcc RUNTESTFLAGS="compile.exp=pr53886.c --target_board=sh-sim\{-m2/-ml,-m2/-mb,-m2a/-mb,-m2a-single/-mb,-m4/-ml, -m4/-mb,-m4-single/-ml,-m4-single/-mb,-m4a-single/-ml,-m4a-single/-mb}" without the patch http://gcc.gnu.org/ml/gcc-patches/2012-07/msg00342.html (fails) and with the patch (passes). Cheers, Oleg testsuite/ChangeLog: target PR/53886 * gcc.c-torture/compile/pr53886.c: New. Index: gcc/testsuite/gcc.c-torture/compile/pr53886.c =================================================================== --- gcc/testsuite/gcc.c-torture/compile/pr53886.c (revision 0) +++ gcc/testsuite/gcc.c-torture/compile/pr53886.c (revision 0) @@ -0,0 +1,68 @@ +/* PR target/53886 */ +typedef struct asn1_string_st ASN1_BIT_STRING; +typedef struct bignum_st BIGNUM; +typedef struct ec_group_st EC_GROUP; +typedef struct ec_key_st EC_KEY; + +struct ec_key_st +{ + EC_GROUP *group; + BIGNUM *priv_key; + unsigned int enc_flag; +} +X9_62_PENTANOMIAL; +typedef struct ec_privatekey_st +{ + ASN1_BIT_STRING *publicKey; +} +EC_PRIVATEKEY; + +extern EC_PRIVATEKEY* EC_PRIVATEKEY_new (void); +extern void EC_PRIVATEKEY_free (EC_PRIVATEKEY*); +extern unsigned char* CRYPTO_realloc (char*,int,const char*,int); + +int +i2d_ECPrivateKey (EC_KEY * a, unsigned char **out) +{ + int ret = 0, ok = 0; + unsigned char *buffer = 0; + unsigned buf_len = 0, tmp_len; + EC_PRIVATEKEY *priv_key = 0; + if (a == 0 || a->group == 0 || a->priv_key == 0) + { + ERR_put_error (16, (192), ((3 | 64)), + "", + 1234); + goto err; + } + if ((priv_key = EC_PRIVATEKEY_new ()) == 0) + { + ERR_put_error (16, (192), ((1 | 64)), + "", + 1241); + goto err; + } + if (!(a->enc_flag & 0x002)) + { + if (priv_key->publicKey == 0) + { + goto err; + } + if (tmp_len > buf_len) + { + unsigned char *tmp_buffer = + CRYPTO_realloc ((char *) buffer, (int) tmp_len, "", 1293); + buffer = tmp_buffer; + } + } + if ((ret = i2d_EC_PRIVATEKEY (priv_key, out)) == 0) + { + } + ok = 1; +err: + if (buffer) + CRYPTO_free (buffer); + if (priv_key) + EC_PRIVATEKEY_free (priv_key); + return (ok ? ret : 0); +}