From patchwork Thu Jun 10 10:45:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 55199 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 9D28B1007D3 for ; Thu, 10 Jun 2010 20:46:23 +1000 (EST) Received: (qmail 9728 invoked by alias); 10 Jun 2010 10:46:22 -0000 Received: (qmail 9711 invoked by uid 22791); 10 Jun 2010 10:46:20 -0000 X-SWARE-Spam-Status: No, hits=-4.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 10 Jun 2010 10:46:15 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5AAk2MH023853 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 10 Jun 2010 06:46:02 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5AAk0YC011754 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 10 Jun 2010 06:46:01 -0400 Received: from livre.localdomain (livre.oliva.athome.lsd.ic.unicamp.br [172.31.160.2]) by localhost.localdomain (8.14.3/8.14.3) with ESMTP id o5AAk0Hu020913; Thu, 10 Jun 2010 07:46:00 -0300 Received: from livre.localdomain (aoliva@localhost [127.0.0.1]) by livre.localdomain (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id o5AAjwm0031980; Thu, 10 Jun 2010 07:45:59 -0300 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id o5AAjvXg031978; Thu, 10 Jun 2010 07:45:57 -0300 From: Alexandre Oliva To: Eric Botcazou Cc: gcc-patches@gcc.gnu.org Subject: Fix uninitialized error with BUILD_CONFIG=bootstrap-O1 Date: Thu, 10 Jun 2010 07:45:57 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 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 On both x86_64 and ia64, update_pointer_to in ada/gcc-interface/utils.c fails to compile at -O1 with a warning that last may be used uninitialized. I suppose -O2 infers that new_ptr can't be NULL because it's dereferenced before, so last will always be set before we exit the loop, but at -O1 it doesn't. This patch avoids the warning, but perhaps the loop should be turned into a do/while loop to avoid the unnecessary test. Regstrapped on x86_64-linux-gnu and ia64-linux-gnu. Ok? for gcc/ada/ChangeLog from Alexandre Oliva * gcc-interface/utils.c (update_pointer_to): Initialize last. Index: gcc/ada/gcc-interface/utils.c =================================================================== --- gcc/ada/gcc-interface/utils.c.orig 2010-06-09 07:10:50.000000000 -0300 +++ gcc/ada/gcc-interface/utils.c 2010-06-09 07:14:17.000000000 -0300 @@ -3497,7 +3497,7 @@ update_pointer_to (tree old_type, tree n /* Merge PTR in NEW_PTR. */ DECL_FIELD_CONTEXT (array_field) = new_ptr; DECL_FIELD_CONTEXT (bounds_field) = new_ptr; - for (t = new_ptr; t; last = t, t = TYPE_NEXT_VARIANT (t)) + for (last = NULL, t = new_ptr; t; last = t, t = TYPE_NEXT_VARIANT (t)) TYPE_FIELDS (t) = TYPE_FIELDS (ptr); /* Chain PTR and its variants at the end. */