xref: /llvm-project/flang/test/Semantics/assign01.f90 (revision 2472b6869a6eeb198a4e982fd7c3ffc89dd4f6f5)
16c1ac141SIvan Zhechev! RUN: %python %S/test_errors.py %s %flang_fc1
264ab3302SCarolineConcatto! 10.2.3.1(2) All masks and LHS of assignments in a WHERE must conform
364ab3302SCarolineConcatto
464ab3302SCarolineConcattosubroutine s1
564ab3302SCarolineConcatto  integer :: a1(10), a2(10)
664ab3302SCarolineConcatto  logical :: m1(10), m2(5,5)
764ab3302SCarolineConcatto  m1 = .true.
864ab3302SCarolineConcatto  m2 = .false.
964ab3302SCarolineConcatto  a1 = [((i),i=1,10)]
1064ab3302SCarolineConcatto  where (m1)
1164ab3302SCarolineConcatto    a2 = 1
1264ab3302SCarolineConcatto  !ERROR: Must have rank 1 to match prior mask or assignment of WHERE construct
1364ab3302SCarolineConcatto  elsewhere (m2)
1464ab3302SCarolineConcatto    a2 = 2
1564ab3302SCarolineConcatto  elsewhere
1664ab3302SCarolineConcatto    a2 = 3
1764ab3302SCarolineConcatto  end where
1864ab3302SCarolineConcattoend
1964ab3302SCarolineConcatto
2064ab3302SCarolineConcattosubroutine s2
2164ab3302SCarolineConcatto  logical, allocatable :: m1(:), m4(:,:)
2264ab3302SCarolineConcatto  logical :: m2(2), m3(3)
2364ab3302SCarolineConcatto  where(m1)
2464ab3302SCarolineConcatto    where(m2)
2564ab3302SCarolineConcatto    end where
2664ab3302SCarolineConcatto    !ERROR: Dimension 1 must have extent 2 to match prior mask or assignment of WHERE construct
2764ab3302SCarolineConcatto    where(m3)
2864ab3302SCarolineConcatto    end where
2964ab3302SCarolineConcatto    !ERROR: Must have rank 1 to match prior mask or assignment of WHERE construct
3064ab3302SCarolineConcatto    where(m4)
3164ab3302SCarolineConcatto    end where
3264ab3302SCarolineConcatto  endwhere
3364ab3302SCarolineConcatto  where(m1)
3464ab3302SCarolineConcatto    where(m3)
3564ab3302SCarolineConcatto    end where
3664ab3302SCarolineConcatto  !ERROR: Dimension 1 must have extent 3 to match prior mask or assignment of WHERE construct
3764ab3302SCarolineConcatto  elsewhere(m2)
3864ab3302SCarolineConcatto  end where
3964ab3302SCarolineConcattoend
4064ab3302SCarolineConcatto
4164ab3302SCarolineConcattosubroutine s3
4264ab3302SCarolineConcatto  logical, allocatable :: m1(:,:)
4364ab3302SCarolineConcatto  logical :: m2(4,2)
4464ab3302SCarolineConcatto  real :: x(4,4), y(4,4)
4564ab3302SCarolineConcatto  real :: a(4,5), b(4,5)
4664ab3302SCarolineConcatto  where(m1)
4764ab3302SCarolineConcatto    x = y
4864ab3302SCarolineConcatto    !ERROR: Dimension 2 must have extent 4 to match prior mask or assignment of WHERE construct
4964ab3302SCarolineConcatto    a = b
5064ab3302SCarolineConcatto    !ERROR: Dimension 2 must have extent 4 to match prior mask or assignment of WHERE construct
5164ab3302SCarolineConcatto    where(m2)
5264ab3302SCarolineConcatto    end where
5364ab3302SCarolineConcatto  end where
5464ab3302SCarolineConcattoend
55*2472b686SPeixinQiao
56*2472b686SPeixinQiaosubroutine s4
57*2472b686SPeixinQiao  integer :: x1 = 0, x2(2) = 0
58*2472b686SPeixinQiao  logical :: l1 = .false., l2(2) = (/.true., .false./), l3 = .false.
59*2472b686SPeixinQiao  !ERROR: The mask or variable must not be scalar
60*2472b686SPeixinQiao  where (l1)
61*2472b686SPeixinQiao    !ERROR: The mask or variable must not be scalar
62*2472b686SPeixinQiao    x1 = 1
63*2472b686SPeixinQiao  end where
64*2472b686SPeixinQiao  !ERROR: The mask or variable must not be scalar
65*2472b686SPeixinQiao  where (l1)
66*2472b686SPeixinQiao    !ERROR: The mask or variable must not be scalar
67*2472b686SPeixinQiao    where (l3)
68*2472b686SPeixinQiao      !ERROR: The mask or variable must not be scalar
69*2472b686SPeixinQiao      x1 = 1
70*2472b686SPeixinQiao    end where
71*2472b686SPeixinQiao  end where
72*2472b686SPeixinQiao  !ERROR: The mask or variable must not be scalar
73*2472b686SPeixinQiao  where (l2(2))
74*2472b686SPeixinQiao    !ERROR: The mask or variable must not be scalar
75*2472b686SPeixinQiao    x2(2) = 1
76*2472b686SPeixinQiao  end where
77*2472b686SPeixinQiaoend
78