http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49638
Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikael at gcc dot gnu.org

--- Comment #8 from Mikael Morin <mikael at gcc dot gnu.org> 2011-08-03 
21:35:49 UTC ---
(In reply to comment #7)
> I wonder whether the right thing to do would be to add a general expression
> comparison routine like the one below (just a rough sketch so far).
> 
> a) Do we have something like this already? I found gfc_compare_expr in 
> arith.c,
> but this does not seem to do quite what we need here (e.g. it only handles
> constant expressions, etc).
> 
> b) Is it overkill and things can be done in a simpler way?
> 

4.5.7.3 (type-bound procedure overriding) has:
• Either both shall be subroutines or both shall be functions having the same
result characteristics (12.3.3).

12.3.3 (Characteristics of function results):
If a type parameter of a function result or a bound of a function result array
is not a constant expression, the
exact dependence on the entities in the expression is a characteristic


So the standards asks for same-expression-ness.
Whether a compiler should diagnose it is another question.
I understand reversed operands (for commutative operators) as having an equal
"exact dependence on the entities". And same for associative operators. 
Thus it is bound to be very complicated in the general case. 

However one could use an exact expression comparison (like what you proposed)
and emit a warning only. 
This should take care of the most common cases without being too complicated.

About the functions to reuse there is also gfc_dep_compare_expr and its
sub-functions (they should handle functions, variables and arithmetic
operators). I don't know however how you will have two corresponding dummy
arguments (from different procedures) compare equal. It's possibly not that
simple after all, if you need to rewrite the functions. As far as I'm
concerned, constants are enough then.

Reply via email to