On Thu, Dec 06, 2018 at 02:08:54PM -0500, Fritz Reese wrote: > On Wed, Dec 5, 2018 at 7:03 PM Steve Kargl > <s...@troutmask.apl.washington.edu> wrote: > > > > On Wed, Dec 05, 2018 at 04:48:28PM -0500, Fritz Reese wrote: > [...] > > > RE: > > > > PR fortran/88228 > > > > * expr.c (check_null, check_elemental): Work around -fdec and > > > > initialization with logical operators operating on integers. > > > > > > I plan to review this section of the patch later today -- though the > > > patch hides the segfault from the PR, I need more time to determine > > > whether it is correct and complete. > > > > By the time the gfc_expr is given to check_check and check_elemental, > > it has been reduced to a EXPR_CONSTANT, which neither routine expected. > > I simply return early in that case. > > It appears the correct solution is simply the following patch: > > diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c > index b2090218d48..775a5c52c65 100644 > --- a/gcc/fortran/resolve.c > +++ b/gcc/fortran/resolve.c > @@ -4004,7 +4004,7 @@ resolve_operator (gfc_expr *e) > if (op2->ts.type != e->ts.type || op2->ts.kind != e->ts.kind) > gfc_convert_type (op2, &e->ts, 1); > e = logical_to_bitwise (e); > - return resolve_function (e); > + break; > } > > sprintf (msg, _("Operands of logical operator %%<%s%%> at %%L > are %s/%s"), > @@ -4020,7 +4020,7 @@ resolve_operator (gfc_expr *e) > e->ts.type = BT_INTEGER; > e->ts.kind = op1->ts.kind; > e = logical_to_bitwise (e); > - return resolve_function (e); > + break; > }
Intersting. I wonder why resolve_function() appears here. Hmmm, 'svn annotate' points to r241535 with the committer being foreese. :-) Log message says you are trying to convert logical op on integers for DEC. Were trying to catch the logical functions like NOT()? I'll include the above in my patch Saturday activities. > > > > PR fortran/88139 > > > > * dump-parse-tree.c (write_proc): Alternate return. > > > I dissent with this patch. The introduced error is meaningless and, as > > > mentioned by comment #3 in the PR, avoiding the ICE in dump-parse-tree > > > is not directly the issue. The code should be rejected in parsing. In > > > gcc-8.1 the invalid code is accepted (without an ICE) even without the > > > -fc-prototypes flag: I haven't finished building the compiler with > > > your changes yet to see whether that is still true afterwards, but at > > > least the test case doesn't try this, so I strongly suspect the patch > > > is incomplete to fix the PR. > > > > Comment #3 does not contain a patch to fix the problem elsewhere. > > > > In F2003, 15.2.6 "Interoperability of procedures and procedure interfaces", > > I cannot find a prohibition on an alternate return in a subroutine > > interface with BIND(C). > > > > I'm disinclined to let a patch fester in bugzilla to only attain > > the same fate as my patch to PR68544. > > According to F2008 ยง15.3.7.2(5): > > > any dummy argument without the VALUE attribute [...] is interoperable with > > an entity of the > > referenced type (ISO/IEC 9899:1999, 6.2.5, 7.17, and 7.18.1) of the formal > > parameter Yep. > Regardless of whether or not we accept alternate returns in BIND(C) > procedures, the compiler must be at least consistent: if we accept > them (which gfortran currently does), then we should be able to dump > the C prototype (with -fc-prototypes), providing a formal parameter > interoperable with the type of the alternate return dummy argument; if > we reject them, then we should issue the error in parsing (before > handling by -fc-prototypes). In either case, the error message should > not be obscure or meaningless. Even so, the patch here is inconsistent > since we accept the code, but issue an error when attempting to dump I think we should determine what other compilers do with BIND(C) and alternate return dummy arguments, and follow suit. > > > > PR fortran/88205 > > > > * io.c (gfc_match_open): STATUS must be CHARACTER type. > [...] > > If I used e->where one gets > > > > a.f90:2:32: > > > > 2 | character(3), parameter :: a(0) = [character(3)::] > > | 1 > > Error: FORMAT tag at (1) cannot be a zero-sized array > > > > Now, imagine a few hundred lines separating the two statements. > > I think the latter error locus is preferable. > > Yes, I agree. > > Swapping gfc_current_locus definitely works, but is possibly less > readable(+maintainable) than my other suggestion of passing loc down > as an argument... But that suggestion touches more code, so there are > merits to either approach. In either case I have no real issue with > this part of the patch regardless of implementation of the locus > workaround. I agree that this could get messy, but I'm hoping only format strings need this special handling. A Fortran string must contain '(' and ')', so zero-sized arrays can never appear as a fmt=array. -- Steve