This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, fortran] Fix PR19101 missing & in character continuation not caught
:REVIEWPATCH:
The attached is a revised patch following example of Steve's evil tab. You will
see the tabs flag in there. I won't commit this until after Steve commits his
so we don't bump into each other. Whats nice about this is the compiler takes a
good approach when the ampersand is missing and continues the string at the
first non-whitespace character. If -pedantic is given, it does the same thing
but issues a warning allowing users to fix if they wish.
I think this is a good way to go. OK for trunk and 4.1.1? I will commit after
Steve's tab error patch.
2006-03-08 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/19101
* gfortran.h: Add flag_ampersand.
* options.c (gfc_init_options): Initialize flag_ampersand.
(gfc_post_options): Set the flag if pedantic.
* scanner.c (gfc_next_char_literal): Add test for missing '&' in
continued character constant and give warning if missing and
pedantic.
Index: gfortran.h
===================================================================
*** gfortran.h (revision 111731)
--- gfortran.h (working copy)
*************** typedef struct
*** 1628,1633 ****
--- 1628,1635 ----
int flag_cray_pointer;
int flag_d_lines;
int flag_openmp;
+ int flag_tabs;
+ int flag_ampersand;
int q_kind;
Index: scanner.c
===================================================================
*** scanner.c (revision 111731)
--- scanner.c (working copy)
*************** restart:
*** 680,686 ****
}
if (c != '&')
! gfc_current_locus = old_loc;
}
else
{
--- 680,691 ----
}
if (c != '&')
! {
! if (in_string && gfc_option.flag_ampersand)
! gfc_warning ("Missing '&' in continued character constant at %C");
!
! gfc_current_locus.nextc--;
! }
}
else
{
Index: options.c
===================================================================
*** options.c (revision 111731)
--- options.c (working copy)
*************** gfc_init_options (unsigned int argc ATTR
*** 78,83 ****
--- 78,85 ----
gfc_option.flag_cray_pointer = 0;
gfc_option.flag_d_lines = -1;
gfc_option.flag_openmp = 0;
+ gfc_option.flag_tabs = 1;
+ gfc_option.flag_ampersand = 0;
gfc_option.q_kind = gfc_default_double_kind;
*************** gfc_post_options (const char **pfilename
*** 270,275 ****
--- 272,280 ----
/* Implement -fno-automatic as -fmax-stack-var-size=0. */
if (!gfc_option.flag_automatic)
gfc_option.flag_max_stack_var_size = 0;
+
+ if (pedantic)
+ gfc_option.flag_ampersand = 1;
return false;
}