https://bugs.llvm.org/show_bug.cgi?id=46830

            Bug ID: 46830
           Summary: Semantic error is not coming for duplicate type
                    specification in type guard statement
           Product: flang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedb...@nondot.org
          Reporter: inderjeet_ka...@hcl.com
                CC: david.tr...@arm.com, jper...@nvidia.com,
                    kirankuma...@gmail.com, llvm-bugs@lists.llvm.org,
                    sscalp...@nvidia.com

Issue: 
-----
If selector is unlimited polymorphic object and type guard statement has
integer type specification which is already specified by previous type guard
statement then semantic error is not coming.

Fortran 2018 spec:
-----------------
C1163 (R1152) For a given select-type-construct, the same type and kind type
parameter values shall not be specified in more than one TYPE IS
type-guard-stmt and shall not be specified in more than one CLASS IS
type-guard-stmt.


Kindly refer following 2 test cases. selecttype_intrinsic.f90 has issue and
selecttype.f90 returns expected error.

[root@localhost Base_compiler]# f18 selecttype_intrinsic.f90 
/tmp/f18-56ab.f90:10:11:

   TYPE IS (INTEGER)
           2
   TYPE IS (INTEGER)
           1
Error: TYPE IS at (1) overlaps with TYPE IS at (2)
[root@localhost Base_compiler]# cat -n selecttype_intrinsic.f90 
     1  type ty
     2   integer :: ii
     3  end type
     4  class(*),allocatable :: cptr_unlim
     5  
     6  call sub1()
     7  contains 
     8  subroutine sub1()
     9  select type(cptr_unlim)
    10   !ERROR: Type specification 'integer' conflicts with previous type
specification
    11   type is(integer) 
    12   type is(integer) 
    13  end select
    14  end 
    15  end 
[root@localhost Base_compiler]# 


- Following case returns expected error:

[root@localhost Base_compiler]# f18 selecttype.f90 
selecttype.f90:12:2: error: Type specification 'ty' conflicts with previous
type specification
   type is(ty) 
   ^^^^^^^^^^^
selecttype.f90:11:2: Conflicting type specification 'ty'
   type is(ty) 
   ^^^^^^^^^^^
f18: semantic errors in selecttype.f90
[root@localhost Base_compiler]# cat -n selecttype.f90 
     1  type ty
     2   integer :: ii
     3  end type
     4  class(ty),allocatable :: cptr
     5  
     6  call sub2()
     7  contains 
     8  subroutine sub2()
     9  select type(cptr)
    10   !ERROR: Type specification 'ty' conflicts with previous type
specification
    11   type is(ty) 
    12   type is(ty) 
    13  end select
    14  end
    15  end

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to