From patchwork Mon Jul 14 17:19:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 369735 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 9809C140096 for ; Tue, 15 Jul 2014 03:20:07 +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 :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=WG68T2kRmqau15nMLaye+yPOCBlUao0CVr4H4Hag4BrjAC 9NbL7PDhJjJwK18YdcnQ/K8eoPBnOX5jOymg0NnFA08aVnMksomjshm95JZXj+kH kKBJ024sonyYtL85uqn4Hg37xSw6ds+EA/cknO1fw6i67ZyfwxQqZSXG/Q3gI= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=5EThIPYA+fqvnzzNbhJpuQ6ekuU=; b=tlQNReQ4JiVZL342q2b9 5URumE3cHF8QJsMlL+y9fpnmkytWEOInTL7VrkzkeoUZ+WJ7l/qZ0X4r0mWba/CB th6uNFZVC+Xw7/Q3TFCYuu4ct53jegllPsXyqTBECo+4LTaC5RNwTbVgU8W40UQF r/ZBOK9oBkkP2HWszrCrtms= Received: (qmail 16917 invoked by alias); 14 Jul 2014 17:19:57 -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 16843 invoked by uid 89); 14 Jul 2014 17:19:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx02.qsc.de Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 14 Jul 2014 17:19:46 +0000 Received: from tux.net-b.de (port-92-194-213-151.dynamic.qsc.de [92.194.213.151]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx02.qsc.de (Postfix) with ESMTPSA id 587FD27642; Mon, 14 Jul 2014 19:19:42 +0200 (CEST) Message-ID: <53C4112D.9020309@net-b.de> Date: Mon, 14 Jul 2014 19:19:41 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: gcc-patches , gfortran Subject: [Patch, Fortran] Fix atomic_ref with -fcoarray=lib If the atomic_ref VALUE argument is of a different kind than the ATOM argument, the result was wrong with -fcoarray=lib. That showed up with gfortran.dg/coarray/atomic_1.f90 - but for some reasons only with -m32. The fix is to create a temporary variable in this case, what the patch does. OK for the trunk? Tobias 2014-06-14 Tobias Burnus * trans-intrinsic.c (conv_intrinsic_atomic_ref): Fix handling for kind mismatch with -fcoarray=lib. diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index 57b7f4d..3de0b09 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -8563,7 +8563,8 @@ conv_intrinsic_atomic_ref (gfc_code *code) atom = argse.expr; gfc_init_se (&argse, NULL); - if (gfc_option.coarray == GFC_FCOARRAY_LIB) + if (gfc_option.coarray == GFC_FCOARRAY_LIB + && code->ext.actual->expr->ts.kind == atom_expr->ts.kind) argse.want_pointer = 1; gfc_conv_expr (&argse, code->ext.actual->expr); gfc_add_block_to_block (&block, &argse.pre); @@ -8589,6 +8590,7 @@ conv_intrinsic_atomic_ref (gfc_code *code) if (gfc_option.coarray == GFC_FCOARRAY_LIB) { tree image_index, caf_decl, offset, token; + tree orig_value = NULL_TREE, vardecl = NULL_TREE; caf_decl = gfc_get_tree_for_caf_expr (atom_expr); if (TREE_CODE (TREE_TYPE (caf_decl)) == REFERENCE_TYPE) @@ -8601,6 +8603,14 @@ conv_intrinsic_atomic_ref (gfc_code *code) get_caf_token_offset (&token, &offset, caf_decl, atom, atom_expr); + /* Different type, need type conversion. */ + if (!POINTER_TYPE_P (TREE_TYPE (value))) + { + vardecl = gfc_create_var (TREE_TYPE (TREE_TYPE (atom)), "value"); + orig_value = value; + value = gfc_build_addr_expr (NULL_TREE, vardecl); + } + tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_atomic_ref, 7, token, offset, image_index, value, stat, build_int_cst (integer_type_node, @@ -8608,6 +8618,9 @@ conv_intrinsic_atomic_ref (gfc_code *code) build_int_cst (integer_type_node, (int) atom_expr->ts.kind)); gfc_add_expr_to_block (&block, tmp); + if (vardecl != NULL_TREE) + gfc_add_modify (&block, orig_value, + fold_convert (TREE_TYPE (orig_value), vardecl)); gfc_add_block_to_block (&block, &post_block); return gfc_finish_block (&block); }