From patchwork Tue Feb 12 16:10:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 31416 Received: (qmail 68128 invoked by alias); 12 Feb 2019 16:11:23 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 68030 invoked by uid 89); 12 Feb 2019 16:11:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr1-f42.google.com Received: from mail-wr1-f42.google.com (HELO mail-wr1-f42.google.com) (209.85.221.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 12 Feb 2019 16:11:19 +0000 Received: by mail-wr1-f42.google.com with SMTP id q1so3294213wrp.7 for ; Tue, 12 Feb 2019 08:11:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=XVc0UzypJsdCy7OL18wZ36hg/ZoDSp6ykfHjtNkQZek=; b=VnLto+xmoBxgY/FPLWKRmM0C+WTt7Ir5wJkwe6z9yXwyD80LcGORMqt/og1waUkna3 srlZPAVDq+u8FHqL6ei2rRJjFQUFXEFUOpY4MOmTBENQSaMsF6q2VsmAPf3EULvDZQth Qsfh1vOCAiKZxlrShFBMfvixL8HmGkypNBhc8aXf9CkoNzE135Di5lItWgiJSVu8tRe1 DBLD8W+fOvf5QB4nNDrklgsvRKx1fj/Bgp6sOb+4N2SqUVbaN/fS4bKRtWwAsO93pn7X xfl3vWF7JRhbkSyFxWPK56L+5CmHIu0rSkELqF8LBCZTBs+6xXJk0yPI42WwNtxQdx8m RQVA== Return-Path: Received: from localhost (host81-151-161-9.range81-151.btcentralplus.com. [81.151.161.9]) by smtp.gmail.com with ESMTPSA id l20sm24298690wrb.93.2019.02.12.08.11.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Feb 2019 08:11:16 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Richard Bunt , Andrew Burgess Subject: [PATCH 07/11] gdb/fortran: Expand the set of types that support (kind=N) Date: Tue, 12 Feb 2019 16:10:58 +0000 Message-Id: In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes Expand the number of types that can be adjusted with a (kind=N) type extension. gdb/ChangeLog: * f-exp.y (convert_to_kind_type): Handle more type kinds. gdb/testsuite/ChangeLog: * gdb.fortran/type-kinds.exp (test_basic_parsing_of_type_kinds): Expand types tested. (test_parsing_invalid_type_kinds): New function. --- gdb/ChangeLog | 4 ++++ gdb/f-exp.y | 36 ++++++++++++++++++++++++++++++++ gdb/testsuite/ChangeLog | 6 ++++++ gdb/testsuite/gdb.fortran/type-kinds.exp | 24 +++++++++++++++++++++ 4 files changed, 70 insertions(+) diff --git a/gdb/f-exp.y b/gdb/f-exp.y index 327f13736bd..980ee4b4adb 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -830,6 +830,42 @@ convert_to_kind_type (struct type *basetype, int kind) if (kind == 1) return parse_f_type (pstate)->builtin_character; } + else if (basetype == parse_f_type (pstate)->builtin_complex_s8) + { + if (kind == 4) + return parse_f_type (pstate)->builtin_complex_s8; + else if (kind == 8) + return parse_f_type (pstate)->builtin_complex_s16; + else if (kind == 16) + return parse_f_type (pstate)->builtin_complex_s32; + } + else if (basetype == parse_f_type (pstate)->builtin_real) + { + if (kind == 4) + return parse_f_type (pstate)->builtin_real; + else if (kind == 8) + return parse_f_type (pstate)->builtin_real_s8; + else if (kind == 16) + return parse_f_type (pstate)->builtin_real_s16; + } + else if (basetype == parse_f_type (pstate)->builtin_logical) + { + if (kind == 1) + return parse_f_type (pstate)->builtin_logical_s1; + else if (kind == 2) + return parse_f_type (pstate)->builtin_logical_s2; + else if (kind == 4) + return parse_f_type (pstate)->builtin_logical; + else if (kind == 8) + return parse_f_type (pstate)->builtin_logical_s8; + } + else if (basetype == parse_f_type (pstate)->builtin_integer) + { + if (kind == 2) + return parse_f_type (pstate)->builtin_integer_s2; + else if (kind == 4) + return parse_f_type (pstate)->builtin_integer; + } error (_("unsupported kind %d for type %s"), kind, TYPE_SAFE_NAME (basetype)); diff --git a/gdb/testsuite/gdb.fortran/type-kinds.exp b/gdb/testsuite/gdb.fortran/type-kinds.exp index b60b8044110..b2e64d77081 100644 --- a/gdb/testsuite/gdb.fortran/type-kinds.exp +++ b/gdb/testsuite/gdb.fortran/type-kinds.exp @@ -24,12 +24,36 @@ if { [skip_fortran_tests] } { continue } # Test parsing of `(kind=N)` type modifiers. proc test_basic_parsing_of_type_kinds {} { gdb_test "p ((character (kind=1)) 1)" " = 1" + + gdb_test "p ((complex (kind=4)) 1)" " = \\(1,0\\)" + gdb_test "p ((complex (kind=8)) 1)" " = \\(1,0\\)" + gdb_test "p ((complex (kind=16)) 1)" " = \\(1,0\\)" + + gdb_test "p ((real (kind=4)) 1)" " = 1" + gdb_test "p ((real (kind=8)) 1)" " = 1" + gdb_test "p ((real (kind=16)) 1)" " = 1" + + gdb_test "p ((logical (kind=1)) 1)" " = \\.TRUE\\." + gdb_test "p ((logical (kind=4)) 1)" " = \\.TRUE\\." + gdb_test "p ((logical (kind=8)) 1)" " = \\.TRUE\\." + + gdb_test "p ((integer (kind=2)) 1)" " = 1" + gdb_test "p ((integer (kind=4)) 1)" " = 1" +} + +proc test_parsing_invalid_type_kinds {} { + foreach typename {complex real logical integer} { + foreach typesize {3 5 7 9} { + gdb_test "p (($typename (kind=$typesize)) 1)" "unsupported kind $typesize for type $typename.*" + } + } } clean_restart if [set_lang_fortran] then { test_basic_parsing_of_type_kinds + test_parsing_invalid_type_kinds } else { warning "$test_name tests suppressed." 0 }