From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15405 invoked by alias); 6 Jan 2013 21:59:33 -0000 Received: (qmail 15364 invoked by uid 48); 6 Jan 2013 21:59:14 -0000 From: "tkoenig at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/55852] [4.6/4.7/4.8 regression] internal compiler error: in gfc_build_intrinsic_call, at fortran/expr.c:4647 Date: Sun, 06 Jan 2013 21:59:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: tkoenig at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.6.4 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg00427.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55852 --- Comment #6 from Thomas Koenig 2013-01-06 21:59:13 UTC --- This patch works (not regression-tested yet), but the method using the state variable seems hackish and error-prone. What do you think? Index: expr.c =================================================================== --- expr.c (Revision 194850) +++ expr.c (Arbeitskopie) @@ -4623,7 +4623,8 @@ want to add arguments but with a NULL-expression. */ gfc_expr* -gfc_build_intrinsic_call (const char* name, locus where, unsigned numarg, ...) +gfc_build_intrinsic_call (const char* name, const char *symtree_name, + locus where, unsigned numarg, ...) { gfc_expr* result; gfc_actual_arglist* atail; @@ -4641,11 +4642,17 @@ result->value.function.name = name; result->value.function.isym = isym; - result->symtree = gfc_find_symtree (gfc_current_ns->sym_root, name); - gcc_assert (result->symtree - && (result->symtree->n.sym->attr.flavor == FL_PROCEDURE - || result->symtree->n.sym->attr.flavor == FL_UNKNOWN)); + if (symtree_name == NULL) + { + result->symtree = gfc_find_symtree (gfc_current_ns->sym_root, name); + gcc_assert (result->symtree && + (result->symtree->n.sym->attr.flavor == FL_PROCEDURE + || result->symtree->n.sym->attr.flavor == FL_UNKNOWN)); + } + else + gfc_get_sym_tree (symtree_name, gfc_current_ns, &result->symtree, true); + va_start (ap, numarg); atail = NULL; for (i = 0; i < numarg; ++i) Index: simplify.c =================================================================== --- simplify.c (Revision 194850) +++ simplify.c (Arbeitskopie) @@ -33,6 +33,7 @@ gfc_expr gfc_bad_expr; +bool artificial_call = false; /* Note that 'simplification' is not just transforming expressions. For functions that are not simplified at compile time, range @@ -3248,7 +3249,10 @@ gfc_expr* dim = result; mpz_set_si (dim->value.integer, d); + artificial_call = true; result = gfc_simplify_size (array, dim, kind); + artificial_call = false; + gfc_free_expr (dim); if (!result) goto returnNull; @@ -5512,7 +5516,10 @@ { mpz_set_ui (e->value.integer, n + 1); + artificial_call = true; f = gfc_simplify_size (source, e, NULL); + artificial_call = false; + gfc_free_expr (e); if (f == NULL) { @@ -5584,11 +5591,18 @@ /* Otherwise, we build a new SIZE call. This is hopefully at least simpler than the original one. */ if (!simplified) - simplified = gfc_build_intrinsic_call ("size", array->where, 3, - gfc_copy_expr (replacement), - gfc_copy_expr (dim), - gfc_copy_expr (kind)); + { + const char *symtree_name; + if (artificial_call) + symtree_name = "__internal_size"; + else + symtree_name = NULL; + simplified = gfc_build_intrinsic_call ("size", symtree_name, array->where, 3, + gfc_copy_expr (replacement), + gfc_copy_expr (dim), + gfc_copy_expr (kind)); + } return simplified; } Index: gfortran.h =================================================================== --- gfortran.h (Revision 194850) +++ gfortran.h (Arbeitskopie) @@ -2797,7 +2797,8 @@ bool gfc_has_ultimate_allocatable (gfc_expr *); bool gfc_has_ultimate_pointer (gfc_expr *); -gfc_expr* gfc_build_intrinsic_call (const char*, locus, unsigned, ...); +gfc_expr* gfc_build_intrinsic_call (const char*, const char *, locus, + unsigned, ...); gfc_try gfc_check_vardef_context (gfc_expr*, bool, bool, bool, const char*);