Bug 29828

Summary: [F2003] MIN and MAX with character variables
Product: gcc Reporter: Tobias Burnus <burnus>
Component: fortranAssignee: Francois-Xavier Coudert <fxcoudert>
Status: RESOLVED FIXED    
Severity: enhancement CC: gcc-bugs
Priority: P3 Keywords: patch
Version: 4.3.0   
Target Milestone: 4.3.0   
URL: http://gcc.gnu.org/ml/gcc-patches/2007-08/msg00269.html
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2007-08-05 12:02:03
Bug Depends on:    
Bug Blocks: 20585, 31393    

Description Tobias Burnus 2006-11-14 10:47:14 UTC
See:
"13.7.76 MIN (A1, A2 [, A3, ...])
For arguments of character type, the result is the value that would be selected by application of intrinsic relational operators; that is, the collating sequence for characters with the kind type parameter of the arguments is applied. If the selected argument is shorter than the longest argument, the 20 result is extended with blanks on the right to the length of the longest argument."

"Example. [...] MIN (”A”, ”YY”) has the value “A “, and
22 MIN ((/”Z”, ”A”/), (/”YY”, ”B “/)) has the value (/”YY”, ”A “/)."

Analogously for:
"13.7.71 MAX (A1, A2 [, A3, ...])"
Comment 1 Paul Thomas 2006-11-14 14:17:15 UTC
Confirmed.

Tobias,

What criterion are you chosing for the missing F2003 features?  The reason that I ask is that it is not clear to me when you stop; eg. should we have a PR for polymorphism or for sub-modules?  Maybe it would be better to have a meta-bug for F2003 and point to a Wiki page in which we try to joggle up a priority order?

Best regards

Paul 
Comment 2 Francois-Xavier Coudert 2007-08-05 12:02:03 UTC
Patch submitted for review: http://gcc.gnu.org/ml/gcc-patches/2007-08/msg00269.html
Comment 3 Francois-Xavier Coudert 2007-08-06 20:47:37 UTC
Subject: Bug 29828

Author: fxcoudert
Date: Mon Aug  6 20:47:17 2007
New Revision: 127252

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127252
Log:
	PR fortran/29828

	* trans.h (gfor_fndecl_string_minmax): New prototype.
	* trans-decl.c (gfor_fndecl_string_minmax): New variable.
	(gfc_build_intrinsic_function_decls): Create gfor_fndecl_string_minmax.
	* check.c (gfc_check_min_max): Allow for character arguments.
	* trans-intrinsic.c (gfc_conv_intrinsic_minmax_char): New function.
	(gfc_conv_intrinsic_function): Add special case for MIN and MAX
	intrinsics with character arguments.
	* simplify.c (simplify_min_max): Add simplification for character
	arguments.

	* intrinsics/string_intrinsics.c (string_minmax): New function
	and prototype.
	* gfortran.map (GFORTRAN_1.0): Add _gfortran_string_minmax

	* gfortran.dg/minmax_char_1.f90: New test.
	* gfortran.dg/minmax_char_2.f90: New test.
	* gfortran.dg/min_max_optional_4.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/min_max_optional_4.f90
    trunk/gcc/testsuite/gfortran.dg/minmax_char_1.f90
    trunk/gcc/testsuite/gfortran.dg/minmax_char_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/check.c
    trunk/gcc/fortran/simplify.c
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/gcc/fortran/trans.h
    trunk/gcc/testsuite/ChangeLog
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/gfortran.map
    trunk/libgfortran/intrinsics/string_intrinsics.c

Comment 4 Francois-Xavier Coudert 2007-08-06 20:49:07 UTC
Fixed.