From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 0CB98385E011; Thu, 2 Apr 2020 19:19:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0CB98385E011 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Avoid assertion failure due to complex type change X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: e7da7f8f71572e3ef71a22ad3fae2388a53bd84c X-Git-Newrev: 0830d301901d225403eaf6629c20a6c09f3ec8f6 Message-Id: <20200402191957.0CB98385E011@sourceware.org> Date: Thu, 2 Apr 2020 19:19:57 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Apr 2020 19:19:57 -0000 https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0830d301901d225403eaf6629c20a6c09f3ec8f6 commit 0830d301901d225403eaf6629c20a6c09f3ec8f6 Author: Tom Tromey Date: Thu Apr 2 13:13:02 2020 -0600 Avoid assertion failure due to complex type change Tankut Baris Aktemur pointed out that the recent series to change how complex types are handled introduced a regression. This assert in init_complex_type was firing: gdb_assert (TYPE_CODE (target_type) == TYPE_CODE_INT || TYPE_CODE (target_type) == TYPE_CODE_FLT); The problem was that f-lang.c could call init_complex_type with a type whose code was TYPE_CODE_ERROR. It seemed best to me to fix this in f-lang.c, rather than to change init_complex_type to accept error types. Tested on x86-64 Fedora 30. I'm checking this in. gdb/ChangeLog 2020-04-02 Tom Tromey * f-lang.c (build_fortran_types): Use arch_type to initialize builtin_complex_s32 in the TYPE_CODE_ERROR case. Diff: --- gdb/ChangeLog | 5 +++++ gdb/f-lang.c | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 993a358d345..3b58f2ee546 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-04-02 Tom Tromey + + * f-lang.c (build_fortran_types): Use arch_type to initialize + builtin_complex_s32 in the TYPE_CODE_ERROR case. + 2020-04-02 Tom Tromey * dwarf2/read.c (partial_die_info::read): Do not create a vector diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 2ce4ad43610..6b7a5fb7dba 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -744,8 +744,13 @@ build_fortran_types (struct gdbarch *gdbarch) = init_complex_type ("complex*8", builtin_f_type->builtin_real); builtin_f_type->builtin_complex_s16 = init_complex_type ("complex*16", builtin_f_type->builtin_real_s8); - builtin_f_type->builtin_complex_s32 - = init_complex_type ("complex*32", builtin_f_type->builtin_real_s16); + + if (TYPE_CODE (builtin_f_type->builtin_real_s16) == TYPE_CODE_ERROR) + builtin_f_type->builtin_complex_s32 + = arch_type (gdbarch, TYPE_CODE_ERROR, 256, "complex*32"); + else + builtin_f_type->builtin_complex_s32 + = init_complex_type ("complex*32", builtin_f_type->builtin_real_s16); return builtin_f_type; }