From patchwork Mon Jun 23 14:39:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 362949 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 389931400AB for ; Tue, 24 Jun 2014 00:40:11 +1000 (EST) 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:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=kvLWqW1GqCXiIO16tSLoVyZQR679GlA5dDDLQtfa5sJiJYxdzU fS59eBEhfDKeHdBEAUUjzTYgfyQUWyds2H1ZYSo8uyvJrwBFBA2d4ebL1yFewsDu DdiPenqU5J05EJ/Ztwn3ci9iYXpC0Eu180lPzvk6BGMtoeeb98g8eVfzE= 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:cc:subject:message-id:mime-version:content-type; s= default; bh=+ksLi5MOl4fCYxel3uQyTgqDRgo=; b=eNTnDT9qe46OfynXG9bn trH1SU6J6ZjvkARv5EaDqoB0z30il7kZfcECrtiuu5YgHs3xL7gRIPHrPaXdM2sf OIAl4Wm5qA2iSlIgA5X1EPiGApqZmIOU7x52vzq5XpIGHAobBoAJmt4/OG25IYp9 8QfJe6IQMbVOe4aufiBetWg= Received: (qmail 27389 invoked by alias); 23 Jun 2014 14:40:04 -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 27380 invoked by uid 89); 23 Jun 2014 14:40:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 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; Mon, 23 Jun 2014 14:40:02 +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 s5NEdxBv012742 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 23 Jun 2014 10:39:59 -0400 Received: from redhat.com (ovpn-116-31.ams2.redhat.com [10.36.116.31]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5NEdttP017035 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Mon, 23 Jun 2014 10:39:57 -0400 Date: Mon, 23 Jun 2014 16:39:55 +0200 From: Marek Polacek To: GCC Patches Cc: "Joseph S. Myers" , Andrew MacLeod Subject: [PATCH] Don't segv on __atomic_store (PR c/61553) Message-ID: <20140623143955.GK14420@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) We ICEd on the following testcase since the void type has a NULL TYPE_SIZE_UNIT. I took Andrew's patch from gcc@ ML and added a testcase. Regtested/bootstrapped on x86_64-linux, ok for trunk? 2014-06-23 Marek Polacek Andrew MacLeod PR c/61553 * c-common.c (get_atomic_generic_size): Don't segfault if the type doesn't have a size. * c-c++-common/pr61553.c: New test. Marek diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c index 077263e..087f036 100644 --- gcc/c-family/c-common.c +++ gcc/c-family/c-common.c @@ -10471,7 +10471,8 @@ get_atomic_generic_size (location_t loc, tree function, function); return 0; } - size = tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (type))); + tree type_size = TYPE_SIZE_UNIT (TREE_TYPE (type)); + size = type_size ? tree_to_uhwi (type_size) : 0; if (size != size_0) { error_at (loc, "size mismatch in argument %d of %qE", x + 1, diff --git gcc/testsuite/c-c++-common/pr61553.c gcc/testsuite/c-c++-common/pr61553.c index e69de29..fa97e94 100644 --- gcc/testsuite/c-c++-common/pr61553.c +++ gcc/testsuite/c-c++-common/pr61553.c @@ -0,0 +1,8 @@ +/* PR c/61553 */ +/* { dg-do compile } */ + +void +foo (char *s) +{ + __atomic_store (s, (void *) 0, __ATOMIC_SEQ_CST); +}