1! { dg-do run } 2! 3! Check handling of errmsg. 4! 5implicit none 6integer, allocatable :: a[:], b(:)[:], c, d(:) 7integer :: stat 8character(len=300) :: str 9 10allocate(a[*], b(1)[*], c, d(2), stat=stat) 11 12str = repeat('X', len(str)) 13allocate(a[*], stat=stat, errmsg=str) 14!print *, stat, trim(str) 15if (stat == 0 .or. str /= "Attempt to allocate an allocated object") & 16 STOP 1 17 18str = repeat('Y', len(str)) 19allocate(b(2)[*], stat=stat, errmsg=str) 20!print *, stat, trim(str) 21if (stat == 0 .or. str /= "Attempt to allocate an allocated object") & 22 STOP 2 23 24str = repeat('Q', len(str)) 25allocate(c, stat=stat, errmsg=str) 26!print *, stat, trim(str) 27if (stat == 0 .or. str /= "Attempt to allocate an allocated object") & 28 STOP 3 29 30str = repeat('P', len(str)) 31allocate(d(3), stat=stat, errmsg=str) 32!print *, stat, trim(str) 33if (stat == 0 .or. str /= "Attempt to allocate an allocated object") & 34 STOP 4 35 36end 37