public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran] PR 47023: [4.6/4.7 regression] C_Sizeof: Rejects valid code
@ 2011-10-16 13:40 Janus Weil
  2011-10-16 19:21 ` Paul Richard Thomas
  0 siblings, 1 reply; 6+ messages in thread
From: Janus Weil @ 2011-10-16 13:40 UTC (permalink / raw)
  To: gfortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 712 bytes --]

Hi all,

here is a patch which fixes the regression in comment #2 of the PR in
the subject line. What it does is setting the 'ts.is_c_interop' flag
correctly for constants with kind-parameter specification (such as
'0.0_c_double'), as is already being done for variables.

Regtested on x86_64-unknown-linux-gnu. Ok for trunk and 4.6?

Cheers,
Janus


2011-10-16  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/47023
	* primary.c (match_kind_param): Detect ISO_C_BINDING kinds.
	(get_kind): Pass on 'is_iso_c' flag.
	(match_integer_constant,match_real_constant,match_logical_constant):
	Set 'ts.is_c_interop'.


2011-10-16  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/47023
	* gfortran.dg/c_kind_tests_3.f03: New.

[-- Attachment #2: pr47023_v2.diff --]
[-- Type: text/x-diff, Size: 3763 bytes --]

Index: gcc/fortran/primary.c
===================================================================
--- gcc/fortran/primary.c	(revision 180052)
+++ gcc/fortran/primary.c	(working copy)
@@ -32,16 +32,20 @@ int matching_actual_arglist = 0;
 
 /* Matches a kind-parameter expression, which is either a named
    symbolic constant or a nonnegative integer constant.  If
-   successful, sets the kind value to the correct integer.  */
+   successful, sets the kind value to the correct integer.
+   The argument 'is_iso_c' signals whether the kind is an ISO_C_BINDING
+   symbol like e.g. 'c_int'.  */
 
 static match
-match_kind_param (int *kind)
+match_kind_param (int *kind, int *is_iso_c)
 {
   char name[GFC_MAX_SYMBOL_LEN + 1];
   gfc_symbol *sym;
   const char *p;
   match m;
 
+  *is_iso_c = 0;
+
   m = gfc_match_small_literal_int (kind, NULL);
   if (m != MATCH_NO)
     return m;
@@ -53,6 +57,8 @@ static match
   if (gfc_find_symbol (name, NULL, 1, &sym))
     return MATCH_ERROR;
 
+  *is_iso_c = sym->attr.is_iso_c;
+
   if (sym == NULL)
     return MATCH_NO;
 
@@ -77,20 +83,24 @@ static match
 
 /* Get a trailing kind-specification for non-character variables.
    Returns:
-      the integer kind value or:
-      -1 if an error was generated
-      -2 if no kind was found */
+     * the integer kind value or
+     * -1 if an error was generated,
+     * -2 if no kind was found.
+   The argument 'is_iso_c' signals whether the kind is an ISO_C_BINDING
+   symbol like e.g. 'c_int'.  */
 
 static int
-get_kind (void)
+get_kind (int *is_iso_c)
 {
   int kind;
   match m;
 
+  *is_iso_c = 0;
+
   if (gfc_match_char ('_') != MATCH_YES)
     return -2;
 
-  m = match_kind_param (&kind);
+  m = match_kind_param (&kind, is_iso_c);
   if (m == MATCH_NO)
     gfc_error ("Missing kind-parameter at %C");
 
@@ -188,7 +198,7 @@ match_digits (int signflag, int radix, char *buffe
 static match
 match_integer_constant (gfc_expr **result, int signflag)
 {
-  int length, kind;
+  int length, kind, is_iso_c;
   locus old_loc;
   char *buffer;
   gfc_expr *e;
@@ -208,7 +218,7 @@ match_integer_constant (gfc_expr **result, int sig
 
   match_digits (signflag, 10, buffer);
 
-  kind = get_kind ();
+  kind = get_kind (&is_iso_c);
   if (kind == -2)
     kind = gfc_default_integer_kind;
   if (kind == -1)
@@ -221,6 +231,7 @@ match_integer_constant (gfc_expr **result, int sig
     }
 
   e = gfc_convert_integer (buffer, kind, 10, &gfc_current_locus);
+  e->ts.is_c_interop = is_iso_c;
 
   if (gfc_range_check (e) != ARITH_OK)
     {
@@ -473,7 +484,7 @@ backup:
 static match
 match_real_constant (gfc_expr **result, int signflag)
 {
-  int kind, count, seen_dp, seen_digits;
+  int kind, count, seen_dp, seen_digits, is_iso_c;
   locus old_loc, temp_loc;
   char *p, *buffer, c, exp_char;
   gfc_expr *e;
@@ -611,7 +622,7 @@ done:
       c = gfc_next_ascii_char ();
     }
 
-  kind = get_kind ();
+  kind = get_kind (&is_iso_c);
   if (kind == -1)
     goto cleanup;
 
@@ -665,6 +676,7 @@ done:
   e = gfc_convert_real (buffer, kind, &gfc_current_locus);
   if (negate)
     mpfr_neg (e->value.real, e->value.real, GFC_RND_MODE);
+  e->ts.is_c_interop = is_iso_c;
 
   switch (gfc_range_check (e))
     {
@@ -1099,13 +1111,13 @@ static match
 match_logical_constant (gfc_expr **result)
 {
   gfc_expr *e;
-  int i, kind;
+  int i, kind, is_iso_c;
 
   i = match_logical_constant_string ();
   if (i == -1)
     return MATCH_NO;
 
-  kind = get_kind ();
+  kind = get_kind (&is_iso_c);
   if (kind == -1)
     return MATCH_ERROR;
   if (kind == -2)
@@ -1118,6 +1130,7 @@ match_logical_constant (gfc_expr **result)
     }
 
   e = gfc_get_logical_expr (kind, &gfc_current_locus, i);
+  e->ts.is_c_interop = is_iso_c;
 
   *result = e;
   return MATCH_YES;

[-- Attachment #3: c_kind_tests_3.f03 --]
[-- Type: application/octet-stream, Size: 235 bytes --]

! { dg-do compile }
!
! PR 47023: [4.6/4.7 regression] C_Sizeof: Rejects valid code
!
! Contributed by <florian.rathgeber@gmail.com>

  use iso_c_binding
  real(c_double) x
  print *, c_sizeof(x)
  print *, c_sizeof(0.0_c_double)
end 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Patch, Fortran] PR 47023: [4.6/4.7 regression] C_Sizeof: Rejects valid code
  2011-10-16 13:40 [Patch, Fortran] PR 47023: [4.6/4.7 regression] C_Sizeof: Rejects valid code Janus Weil
@ 2011-10-16 19:21 ` Paul Richard Thomas
  2011-10-16 21:01   ` Janus Weil
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Richard Thomas @ 2011-10-16 19:21 UTC (permalink / raw)
  To: Janus Weil; +Cc: gfortran, gcc-patches

Dear Janus,

This is OK for trunk.  Thanks fo rthe patch.

Cheers

Paul

On Sun, Oct 16, 2011 at 2:58 PM, Janus Weil <janus@gcc.gnu.org> wrote:
> Hi all,
>
> here is a patch which fixes the regression in comment #2 of the PR in
> the subject line. What it does is setting the 'ts.is_c_interop' flag
> correctly for constants with kind-parameter specification (such as
> '0.0_c_double'), as is already being done for variables.
>
> Regtested on x86_64-unknown-linux-gnu. Ok for trunk and 4.6?
>
> Cheers,
> Janus
>
>
> 2011-10-16  Janus Weil  <janus@gcc.gnu.org>
>
>        PR fortran/47023
>        * primary.c (match_kind_param): Detect ISO_C_BINDING kinds.
>        (get_kind): Pass on 'is_iso_c' flag.
>        (match_integer_constant,match_real_constant,match_logical_constant):
>        Set 'ts.is_c_interop'.
>
>
> 2011-10-16  Janus Weil  <janus@gcc.gnu.org>
>
>        PR fortran/47023
>        * gfortran.dg/c_kind_tests_3.f03: New.
>



-- 
The knack of flying is learning how to throw yourself at the ground and miss.
       --Hitchhikers Guide to the Galaxy

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Patch, Fortran] PR 47023: [4.6/4.7 regression] C_Sizeof: Rejects valid code
  2011-10-16 19:21 ` Paul Richard Thomas
@ 2011-10-16 21:01   ` Janus Weil
  2011-10-17  6:53     ` Paul Richard Thomas
  0 siblings, 1 reply; 6+ messages in thread
From: Janus Weil @ 2011-10-16 21:01 UTC (permalink / raw)
  To: Paul Richard Thomas; +Cc: gfortran, gcc-patches

Hi Paul,

> This is OK for trunk.  Thanks fo rthe patch.

Thanks. Committed to trunk as r180062. What about 4.6?

Cheers,
Janus



> On Sun, Oct 16, 2011 at 2:58 PM, Janus Weil <janus@gcc.gnu.org> wrote:
>> Hi all,
>>
>> here is a patch which fixes the regression in comment #2 of the PR in
>> the subject line. What it does is setting the 'ts.is_c_interop' flag
>> correctly for constants with kind-parameter specification (such as
>> '0.0_c_double'), as is already being done for variables.
>>
>> Regtested on x86_64-unknown-linux-gnu. Ok for trunk and 4.6?
>>
>> Cheers,
>> Janus
>>
>>
>> 2011-10-16  Janus Weil  <janus@gcc.gnu.org>
>>
>>        PR fortran/47023
>>        * primary.c (match_kind_param): Detect ISO_C_BINDING kinds.
>>        (get_kind): Pass on 'is_iso_c' flag.
>>        (match_integer_constant,match_real_constant,match_logical_constant):
>>        Set 'ts.is_c_interop'.
>>
>>
>> 2011-10-16  Janus Weil  <janus@gcc.gnu.org>
>>
>>        PR fortran/47023
>>        * gfortran.dg/c_kind_tests_3.f03: New.
>>
>
>
>
> --
> The knack of flying is learning how to throw yourself at the ground and miss.
>        --Hitchhikers Guide to the Galaxy
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Patch, Fortran] PR 47023: [4.6/4.7 regression] C_Sizeof: Rejects valid code
  2011-10-16 21:01   ` Janus Weil
@ 2011-10-17  6:53     ` Paul Richard Thomas
  2011-10-17 10:52       ` Janus Weil
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Richard Thomas @ 2011-10-17  6:53 UTC (permalink / raw)
  To: Janus Weil; +Cc: gfortran, gcc-patches

Dear Janus,

Of course you can commit to 4.6.  Be quick, though; 4.6.2 was due for
release now-ish -
"GCC 4.6 branch remains open under normal release branch rules,
accepting regression and documentation fixes.  GCC 4.6.2 is
tentatively planned for late September or early October."

Thanks

Paul

On Sun, Oct 16, 2011 at 9:45 PM, Janus Weil <janus@gcc.gnu.org> wrote:
> Hi Paul,
>
>> This is OK for trunk.  Thanks fo rthe patch.
>
> Thanks. Committed to trunk as r180062. What about 4.6?
>
> Cheers,
> Janus
>
>
>
>> On Sun, Oct 16, 2011 at 2:58 PM, Janus Weil <janus@gcc.gnu.org> wrote:
>>> Hi all,
>>>
>>> here is a patch which fixes the regression in comment #2 of the PR in
>>> the subject line. What it does is setting the 'ts.is_c_interop' flag
>>> correctly for constants with kind-parameter specification (such as
>>> '0.0_c_double'), as is already being done for variables.
>>>
>>> Regtested on x86_64-unknown-linux-gnu. Ok for trunk and 4.6?
>>>
>>> Cheers,
>>> Janus
>>>
>>>
>>> 2011-10-16  Janus Weil  <janus@gcc.gnu.org>
>>>
>>>        PR fortran/47023
>>>        * primary.c (match_kind_param): Detect ISO_C_BINDING kinds.
>>>        (get_kind): Pass on 'is_iso_c' flag.
>>>        (match_integer_constant,match_real_constant,match_logical_constant):
>>>        Set 'ts.is_c_interop'.
>>>
>>>
>>> 2011-10-16  Janus Weil  <janus@gcc.gnu.org>
>>>
>>>        PR fortran/47023
>>>        * gfortran.dg/c_kind_tests_3.f03: New.
>>>
>>
>>
>>
>> --
>> The knack of flying is learning how to throw yourself at the ground and miss.
>>        --Hitchhikers Guide to the Galaxy
>>
>



-- 
The knack of flying is learning how to throw yourself at the ground and miss.
       --Hitchhikers Guide to the Galaxy

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Patch, Fortran] PR 47023: [4.6/4.7 regression] C_Sizeof: Rejects valid code
  2011-10-17  6:53     ` Paul Richard Thomas
@ 2011-10-17 10:52       ` Janus Weil
  2011-10-17 17:30         ` Janus Weil
  0 siblings, 1 reply; 6+ messages in thread
From: Janus Weil @ 2011-10-17 10:52 UTC (permalink / raw)
  To: Paul Richard Thomas; +Cc: gfortran, gcc-patches

> Of course you can commit to 4.6.

Ok. Btw, my patch had a small regression (PR50752), which was very
quickly reported by Joost. I have just committed the obvious fix as
r180079.


> Be quick, though; 4.6.2 was due for release now-ish -

I know. I'll try to do it today.

Cheers,
Janus



> On Sun, Oct 16, 2011 at 9:45 PM, Janus Weil <janus@gcc.gnu.org> wrote:
>> Hi Paul,
>>
>>> This is OK for trunk.  Thanks fo rthe patch.
>>
>> Thanks. Committed to trunk as r180062. What about 4.6?
>>
>> Cheers,
>> Janus
>>
>>
>>
>>> On Sun, Oct 16, 2011 at 2:58 PM, Janus Weil <janus@gcc.gnu.org> wrote:
>>>> Hi all,
>>>>
>>>> here is a patch which fixes the regression in comment #2 of the PR in
>>>> the subject line. What it does is setting the 'ts.is_c_interop' flag
>>>> correctly for constants with kind-parameter specification (such as
>>>> '0.0_c_double'), as is already being done for variables.
>>>>
>>>> Regtested on x86_64-unknown-linux-gnu. Ok for trunk and 4.6?
>>>>
>>>> Cheers,
>>>> Janus
>>>>
>>>>
>>>> 2011-10-16  Janus Weil  <janus@gcc.gnu.org>
>>>>
>>>>        PR fortran/47023
>>>>        * primary.c (match_kind_param): Detect ISO_C_BINDING kinds.
>>>>        (get_kind): Pass on 'is_iso_c' flag.
>>>>        (match_integer_constant,match_real_constant,match_logical_constant):
>>>>        Set 'ts.is_c_interop'.
>>>>
>>>>
>>>> 2011-10-16  Janus Weil  <janus@gcc.gnu.org>
>>>>
>>>>        PR fortran/47023
>>>>        * gfortran.dg/c_kind_tests_3.f03: New.
>>>>
>>>
>>>
>>>
>>> --
>>> The knack of flying is learning how to throw yourself at the ground and miss.
>>>        --Hitchhikers Guide to the Galaxy
>>>
>>
>
>
>
> --
> The knack of flying is learning how to throw yourself at the ground and miss.
>        --Hitchhikers Guide to the Galaxy
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Patch, Fortran] PR 47023: [4.6/4.7 regression] C_Sizeof: Rejects valid code
  2011-10-17 10:52       ` Janus Weil
@ 2011-10-17 17:30         ` Janus Weil
  0 siblings, 0 replies; 6+ messages in thread
From: Janus Weil @ 2011-10-17 17:30 UTC (permalink / raw)
  To: Paul Richard Thomas; +Cc: gfortran, gcc-patches

>> Be quick, though; 4.6.2 was due for release now-ish -
>
> I know. I'll try to do it today.

Alrighty. Just committed the patch to the 4.6 branch as r180099.


Seems we're down to three open Fortran front-end regressions for the
upcoming 4.6.2 release:

 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42954
(TARGET_*_CPP_BUILDINS issues with gfortran)
 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50410 (ICE in record_reference)
 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50684 (Incorrect error
for move_alloc on element inside intent(in) pointer)

I had started on the third one, but I'm not sure if I can finish it in
time for 4.6.2. Anyone up to looking at the second one?

Cheers,
Janus



>> On Sun, Oct 16, 2011 at 9:45 PM, Janus Weil <janus@gcc.gnu.org> wrote:
>>> Hi Paul,
>>>
>>>> This is OK for trunk.  Thanks fo rthe patch.
>>>
>>> Thanks. Committed to trunk as r180062. What about 4.6?
>>>
>>> Cheers,
>>> Janus
>>>
>>>
>>>
>>>> On Sun, Oct 16, 2011 at 2:58 PM, Janus Weil <janus@gcc.gnu.org> wrote:
>>>>> Hi all,
>>>>>
>>>>> here is a patch which fixes the regression in comment #2 of the PR in
>>>>> the subject line. What it does is setting the 'ts.is_c_interop' flag
>>>>> correctly for constants with kind-parameter specification (such as
>>>>> '0.0_c_double'), as is already being done for variables.
>>>>>
>>>>> Regtested on x86_64-unknown-linux-gnu. Ok for trunk and 4.6?
>>>>>
>>>>> Cheers,
>>>>> Janus
>>>>>
>>>>>
>>>>> 2011-10-16  Janus Weil  <janus@gcc.gnu.org>
>>>>>
>>>>>        PR fortran/47023
>>>>>        * primary.c (match_kind_param): Detect ISO_C_BINDING kinds.
>>>>>        (get_kind): Pass on 'is_iso_c' flag.
>>>>>        (match_integer_constant,match_real_constant,match_logical_constant):
>>>>>        Set 'ts.is_c_interop'.
>>>>>
>>>>>
>>>>> 2011-10-16  Janus Weil  <janus@gcc.gnu.org>
>>>>>
>>>>>        PR fortran/47023
>>>>>        * gfortran.dg/c_kind_tests_3.f03: New.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> The knack of flying is learning how to throw yourself at the ground and miss.
>>>>        --Hitchhikers Guide to the Galaxy
>>>>
>>>
>>
>>
>>
>> --
>> The knack of flying is learning how to throw yourself at the ground and miss.
>>        --Hitchhikers Guide to the Galaxy
>>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-10-17 16:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-16 13:40 [Patch, Fortran] PR 47023: [4.6/4.7 regression] C_Sizeof: Rejects valid code Janus Weil
2011-10-16 19:21 ` Paul Richard Thomas
2011-10-16 21:01   ` Janus Weil
2011-10-17  6:53     ` Paul Richard Thomas
2011-10-17 10:52       ` Janus Weil
2011-10-17 17:30         ` Janus Weil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).