diff mbox

[Fortran] PR58658 - add missing pointer-assign check for CLASS(*)

Message ID 5253283C.2030808@net-b.de
State New
Headers show

Commit Message

Tobias Burnus Oct. 7, 2013, 9:31 p.m. UTC
The patch is rather obvious. The question is just why was the check 
there at the first place.

Build and regtested on x86-64-gnu-linux.
OK for the trunk?

Tobias

Comments

Tobias Burnus Oct. 13, 2013, 7:51 a.m. UTC | #1
*PING*: http://gcc.gnu.org/ml/fortran/2013-10/msg00018.html

Additionally, I'd like to early ping for the do concurrent patch: 
http://gcc.gnu.org/ml/fortran/2013-10/msg00022.html , even if the ME 
review is still pending.

Tobias Burnus wrote:
> The patch is rather obvious. The question is just why was the check 
> there at the first place.
>
> Build and regtested on x86-64-gnu-linux.
> OK for the trunk?
>
> Tobias
Mikael Morin Oct. 14, 2013, 10:24 a.m. UTC | #2
Le 07/10/2013 23:31, Tobias Burnus a écrit :
> The patch is rather obvious. The question is just why was the check
> there at the first place.
> 
> Build and regtested on x86-64-gnu-linux.
> OK for the trunk?
> 
OK. Thanks.

Mikael
Paul Richard Thomas Oct. 15, 2013, 3:30 p.m. UTC | #3
Hi Tobias,

Have you checked that:

subroutine sub(a)
  class(*),pointer :: a
  a => null()
end subroutine

does not give an error?  I think that it is why the check was introduced.

Cheers

Paul


On 13 October 2013 09:51, Tobias Burnus <burnus@net-b.de> wrote:
> *PING*: http://gcc.gnu.org/ml/fortran/2013-10/msg00018.html
>
> Additionally, I'd like to early ping for the do concurrent patch:
> http://gcc.gnu.org/ml/fortran/2013-10/msg00022.html , even if the ME review
> is still pending.
>
> Tobias Burnus wrote:
>>
>> The patch is rather obvious. The question is just why was the check there
>> at the first place.
>>
>> Build and regtested on x86-64-gnu-linux.
>> OK for the trunk?
>>
>> Tobias
>
>
Tobias Burnus Oct. 15, 2013, 8:20 p.m. UTC | #4
Hi Paul,

Paul Richard Thomas wrote:
> Have you checked that:
>
> subroutine sub(a)
>    class(*),pointer :: a
>    a => null()
> end subroutine
>
> does not give an error?  I think that it is why the check was introduced.

I haven't checked it in particular, but was relying that some test in 
the library would test for it. Additionally, gfc_expr_attr() takes care 
to set for BT_CLASS "pointer" only for class_pointer - which I also 
checked before submittal.

In any case, your test case compiles and "grep '=>'" finds the following 
NULL initializations:

unlimited_polymorphic_1.f03:  u2 => NULL()
unlimited_polymorphic_1.f03:  u2 => NULL(aptr)

Tobias
Paul Richard Thomas Oct. 15, 2013, 9:04 p.m. UTC | #5
Then, the patch is OK for trunk :-)

Thanks for putting this right - it's obviously my cock-up!

Cheers

Paul



On 15 October 2013 22:20, Tobias Burnus <burnus@net-b.de> wrote:
> Hi Paul,
>
>
> Paul Richard Thomas wrote:
>>
>> Have you checked that:
>>
>> subroutine sub(a)
>>    class(*),pointer :: a
>>    a => null()
>> end subroutine
>>
>> does not give an error?  I think that it is why the check was introduced.
>
>
> I haven't checked it in particular, but was relying that some test in the
> library would test for it. Additionally, gfc_expr_attr() takes care to set
> for BT_CLASS "pointer" only for class_pointer - which I also checked before
> submittal.
>
> In any case, your test case compiles and "grep '=>'" finds the following
> NULL initializations:
>
> unlimited_polymorphic_1.f03:  u2 => NULL()
> unlimited_polymorphic_1.f03:  u2 => NULL(aptr)
>
> Tobias
diff mbox

Patch

2013-10-07  Tobias Burnus  <burnus@net-b.de>

	PR fortran/58658
	* expr.c (gfc_check_vardef_context): Fix pointer diagnostic
	for CLASS(*).

2013-10-07  Tobias Burnus  <burnus@net-b.de>

	PR fortran/58658
	* gfortran.dg/unlimited_polymorphic_10.f90: New.

diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index b2af328..df96e5b 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -4693,7 +4693,6 @@  gfc_check_vardef_context (gfc_expr* e, bool pointer, bool alloc_obj,
   bool is_pointer;
   bool check_intentin;
   bool ptr_component;
-  bool unlimited;
   symbol_attribute attr;
   gfc_ref* ref;
   int i;
@@ -4709,8 +4708,6 @@  gfc_check_vardef_context (gfc_expr* e, bool pointer, bool alloc_obj,
       sym = e->value.function.esym ? e->value.function.esym : e->symtree->n.sym;
     }
 
-  unlimited = e->ts.type == BT_CLASS && UNLIMITED_POLY (sym);
-
   attr = gfc_expr_attr (e);
   if (!pointer && e->expr_type == EXPR_FUNCTION && attr.pointer)
     {
@@ -4750,7 +4747,7 @@  gfc_check_vardef_context (gfc_expr* e, bool pointer, bool alloc_obj,
   /* Find out whether the expr is a pointer; this also means following
      component references to the last one.  */
   is_pointer = (attr.pointer || attr.proc_pointer);
-  if (pointer && !is_pointer && !unlimited)
+  if (pointer && !is_pointer)
     {
       if (context)
 	gfc_error ("Non-POINTER in pointer association context (%s)"
diff --git a/gcc/testsuite/gfortran.dg/unlimited_polymorphic_10.f90 b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_10.f90
new file mode 100644
index 0000000..c4c3879
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_10.f90
@@ -0,0 +1,10 @@ 
+! { dg-do compile }
+!
+! PR fortran/58658
+!
+! Contributed by Vladimír Fuka
+!
+subroutine sub(a)
+  class(*),allocatable :: a
+  a => null() ! { dg-error "Non-POINTER in pointer association context \\(pointer assignment\\)" }
+end subroutine