User account creation filtered due to spam.

Bug 38918 - compile time error for DATA of NULL() to pointer structure component
Summary: compile time error for DATA of NULL() to pointer structure component
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: ---
Assignee: Paul Thomas
URL:
Keywords: rejects-valid
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2009-01-19 22:17 UTC by Dick Hendrickson
Modified: 2009-04-06 10:54 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-01-22 12:33:40


Attachments
Fix for the PR - (1.28 KB, patch)
2009-01-24 12:53 UTC, Paul Thomas
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dick Hendrickson 2009-01-19 22:17:32 UTC
The following program gives a compile time error for a DATA assignment of NULL() to a structure component.  Probably related to 38917

Dick Hendrickson

      SUBROUTINE PF0009

! fails on Windows XP
! gcc version 4.4.0 20081219 (experimental) [trunk revision 142842] (GCC)

      TYPE  :: HAS_POINTER
        INTEGER, POINTER            :: PTR_S
      END TYPE HAS_POINTER
      TYPE (HAS_POINTER)  ::  PTR_ARRAY(5)

      DATA PTR_ARRAY(1)%PTR_S  /NULL()/

      end subroutine pf0009


C:\gfortran>gfortran try_pf0009.f
try_pf0009.f:11.38:

      DATA PTR_ARRAY(1)%PTR_S  /NULL()/
                                      1
Error: NULL appears on right-hand side in assignment at (1)
Comment 1 Tobias Burnus 2009-01-20 07:26:13 UTC
Confirm. Thanks for the report.

R532 data-stmt-constant   is ...
                          or null-init

R507 null-init   is function-reference
C506 (R507) The function-reference shall be a reference to the NULL intrinsic
            function with no arguments

Probably a duplicate of PR 38917.
Comment 2 Paul Thomas 2009-01-22 12:33:40 UTC
This has a trivial fix:

expr.c: 2913 becomes
if (have_pointer && lvalue->symtree->n.sym->attr.data)

Sorry about the lack of a diff - I will remedy this on submission:-)

paul 


Comment 3 Paul Thomas 2009-01-24 12:53:11 UTC
Created attachment 17174 [details]
Fix for the PR -

OK'd http://gcc.gnu.org/ml/fortran/2009-01/msg00297.html

2009-01-22  Paul Thomas  <pault@gcc.gnu.org>

       PR fortran/38917
       * expr.c (gfc_check_assign): Allow pointer components when
       checking for NULL.

       PR fortran/38918
       * resolve.c (check_data_variable): Treat pointer arrays with
       scalars.

2009-01-22  Paul Thomas  <pault@gcc.gnu.org>

       PR fortran/38917
       PR fortran/38918
       * gfortran.dg/data_pointer_1.f90: New test.
Comment 4 Paul Thomas 2009-03-31 20:06:05 UTC
Subject: Bug 38918

Author: pault
Date: Tue Mar 31 20:05:44 2009
New Revision: 145371

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145371
Log:
2009-03-31  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/38917
	* expr.c (gfc_check_assign): Allow pointer components when
	checking for NULL.

	PR fortran/38918
	* resolve.c (check_data_variable): Treat pointer arrays with
	scalars.

2009-03-31  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/38917
	PR fortran/38918
	* gfortran.dg/data_pointer_1.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/data_pointer_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/expr.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog

Comment 5 Paul Thomas 2009-04-06 10:54:45 UTC
Fixed on trunk.  I am prepared to backport but the mood appears to be against it.

Thanks for the report.

Paul