diff mbox

[fortran] PR77972 ICE on broken character continuation with -Wall etc.

Message ID 1a598dbd-e1c1-9596-016c-9ba5a1791d89@charter.net
State New
Headers show

Commit Message

Jerry DeLisle Oct. 14, 2016, 2:04 a.m. UTC
This patch is straight forward. We were sending bogus locus info to the 
diagnostics machinery and catch an assert in error,c.

The patch avoids doing this.

Regression tested on x86-64-linux.

OK for trunk?

Regards,

Jerry

2016-10-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	* scanner.c (gfc_next_char_literal): If nextc is null do not
	decrement the pointer and call the diagnostics.

Comments

Steve Kargl Oct. 14, 2016, 3:18 a.m. UTC | #1
On Thu, Oct 13, 2016 at 07:04:04PM -0700, Jerry DeLisle wrote:
> This patch is straight forward. We were sending bogus locus info to the 
> diagnostics machinery and catch an assert in error,c.
> 
> The patch avoids doing this.
> 
> Regression tested on x86-64-linux.
> 
> OK for trunk?
> 

Yes, but see below.

> Regards,
> 
> Jerry
> 
> 2016-10-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
> 
> 	* scanner.c (gfc_next_char_literal): If nextc is null do not
> 	decrement the pointer and call the diagnostics.
> 
> diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c
> index be9c5091..5e355359 100644
> --- a/gcc/fortran/scanner.c
> +++ b/gcc/fortran/scanner.c
> @@ -1414,10 +1414,9 @@ restart:
> 
>         if (c != '&')
>          {
> -         if (in_string)
> +         if (in_string && gfc_current_locus.nextc)
>              {
> -             if (gfc_current_locus.nextc)
> -               gfc_current_locus.nextc--;
> +             gfc_current_locus.nextc--;
>                if (warn_ampersand && in_string == INSTRING_WARN)
>                  gfc_warning (OPT_Wampersand,
>                               "Missing %<&%> in continued character "

If this is a "missing '&' in a continued..." and the '&' is 
required by the standard, then why is this just a warning?
diff mbox

Patch

diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c
index be9c5091..5e355359 100644
--- a/gcc/fortran/scanner.c
+++ b/gcc/fortran/scanner.c
@@ -1414,10 +1414,9 @@  restart:

        if (c != '&')
         {
-         if (in_string)
+         if (in_string && gfc_current_locus.nextc)
             {
-             if (gfc_current_locus.nextc)
-               gfc_current_locus.nextc--;
+             gfc_current_locus.nextc--;
               if (warn_ampersand && in_string == INSTRING_WARN)
                 gfc_warning (OPT_Wampersand,
                              "Missing %<&%> in continued character "