| ! RUN: %python %S/test_errors.py %s %flang_fc1 | |
| ! !DIR$ ALIGN: placement, value and applicability checks. | |
| ! A directive before the first program unit, between two program units or | |
| ! after the last one is in no program unit. | |
| !WARNING: !DIR$ ALIGN directive is ignored because it is not in a program unit [-Wignored-directive] | |
| !dir$ align(64) :: x | |
| module other | |
| real :: used(4) | |
| end module | |
| !WARNING: !DIR$ ALIGN directive is ignored because it is not in a program unit [-Wignored-directive] | |
| !dir$ align(64) :: used | |
| module m | |
| !dir$ align(64) :: ok_module | |
| !WARNING: !DIR$ ALIGN on 'ok_module' is not yet implemented and was ignored [-Wignored-directive] | |
| real :: ok_module(10) | |
| !dir$ align(32) :: ok_before, ok_after | |
| !WARNING: !DIR$ ALIGN on 'ok_before' is not yet implemented and was ignored [-Wignored-directive] | |
| real :: ok_before | |
| !WARNING: !DIR$ ALIGN on 'ok_after' is not yet implemented and was ignored [-Wignored-directive] | |
| real :: ok_after | |
| !dir$ attributes align : 16 :: ok_intel | |
| !WARNING: !DIR$ ALIGN on 'ok_intel' is not yet implemented and was ignored [-Wignored-directive] | |
| real :: ok_intel(4) | |
| ! The value is a power of two no greater than 2**28. | |
| !dir$ align(1) :: smallest | |
| !WARNING: !DIR$ ALIGN on 'smallest' is not yet implemented and was ignored [-Wignored-directive] | |
| real :: smallest | |
| !dir$ align(268435456) :: largest | |
| !WARNING: !DIR$ ALIGN on 'largest' is not yet implemented and was ignored [-Wignored-directive] | |
| real :: largest | |
| !ERROR: The alignment in !DIR$ ALIGN must be a power of two no greater than 268435456 | |
| !dir$ align(0) :: zero_value | |
| !ERROR: The alignment in !DIR$ ALIGN must be a power of two no greater than 268435456 | |
| !dir$ align(24) :: bad_value | |
| !ERROR: The alignment in !DIR$ ALIGN must be a power of two no greater than 268435456 | |
| !dir$ align(536870912) :: too_big | |
| real :: zero_value, bad_value, too_big | |
| ! The directive does not apply to a named constant. An object that is | |
| ! ignored gets one warning, however many directives name it. | |
| !WARNING: !DIR$ ALIGN is ignored for 'p' because it is a named constant [-Wignored-directive] | |
| !dir$ align(16) :: p | |
| !dir$ align(16) :: p | |
| real, parameter :: p = 1.0 | |
| ! ALLOCATABLE and POINTER objects are not supported yet: the directive is | |
| ! ignored with a warning, whichever way the attribute is given. | |
| !WARNING: !DIR$ ALIGN is not yet implemented for ALLOCATABLE or POINTER 'alloc' and was ignored [-Wignored-directive] | |
| !dir$ align(16) :: alloc | |
| real, allocatable :: alloc(:) | |
| !WARNING: !DIR$ ALIGN is not yet implemented for ALLOCATABLE or POINTER 'ptr' and was ignored [-Wignored-directive] | |
| !dir$ align(16) :: ptr | |
| real, pointer :: ptr(:) | |
| !WARNING: !DIR$ ALIGN is not yet implemented for ALLOCATABLE or POINTER 'alloc_stmt' and was ignored [-Wignored-directive] | |
| !dir$ align(16) :: alloc_stmt | |
| real :: alloc_stmt(:) | |
| allocatable :: alloc_stmt | |
| ! Neither are BIND(C) variables. | |
| !WARNING: !DIR$ ALIGN is not yet implemented for BIND(C) variable 'bc' and was ignored [-Wignored-directive] | |
| !dir$ align(16) :: bc | |
| real, bind(c) :: bc | |
| !WARNING: !DIR$ ALIGN is not yet implemented for BIND(C) variable 'bc_stmt' and was ignored [-Wignored-directive] | |
| !dir$ align(16) :: bc_stmt | |
| real :: bc_stmt | |
| bind(c) :: bc_stmt | |
| ! A coarray is ignored as a coarray even when it is ALLOCATABLE. | |
| !WARNING: !DIR$ ALIGN is ignored for 'co' because it is a coarray [-Wignored-directive] | |
| !WARNING: !DIR$ ALIGN is ignored for 'alloc_co' because it is a coarray [-Wignored-directive] | |
| !dir$ align(16) :: co, alloc_co | |
| real :: co[*] | |
| real, allocatable :: alloc_co[:] | |
| !WARNING: !DIR$ ALIGN is ignored for 'pointee' because it is a Cray pointee [-Wignored-directive] | |
| !dir$ align(16) :: pointee | |
| real :: pointee(4) | |
| pointer (cray_pointer, pointee) | |
| !dir$ align(32) :: twice | |
| !ERROR: 'twice' already has a different !DIR$ ALIGN alignment | |
| !dir$ align(64) :: twice | |
| !WARNING: !DIR$ ALIGN on 'twice' is not yet implemented and was ignored [-Wignored-directive] | |
| real :: twice | |
| !dir$ align(64) :: same_twice | |
| !dir$ align(64) :: same_twice | |
| !WARNING: !DIR$ ALIGN on 'same_twice' is not yet implemented and was ignored [-Wignored-directive] | |
| real :: same_twice | |
| ! The directive does not declare a name. | |
| !WARNING: !DIR$ ALIGN is ignored for 'not_declared' because it is not declared in this specification part [-Wignored-directive] | |
| !dir$ align(64) :: not_declared | |
| ! Among the components of a derived type, the directive names a component | |
| ! of the type, declared before or after it. Components are not supported | |
| ! yet. | |
| type t | |
| real :: comp(8) | |
| !WARNING: !DIR$ ALIGN is not yet implemented for component 'comp' and was ignored [-Wignored-directive] | |
| !dir$ align(64) :: comp | |
| real, allocatable :: acomp(:) | |
| !WARNING: !DIR$ ALIGN is not yet implemented for ALLOCATABLE or POINTER 'acomp' and was ignored [-Wignored-directive] | |
| !dir$ align(64) :: acomp | |
| !ERROR: 'acomp' already has a different !DIR$ ALIGN alignment | |
| !dir$ align(32) :: acomp | |
| real, allocatable :: ccomp[:] | |
| !WARNING: !DIR$ ALIGN is ignored for 'ccomp' because it is a coarray [-Wignored-directive] | |
| !dir$ align(64) :: ccomp | |
| !WARNING: !DIR$ ALIGN is not yet implemented for component 'later' and was ignored [-Wignored-directive] | |
| !dir$ align(64) :: later | |
| real :: later | |
| !WARNING: !DIR$ ALIGN is not yet implemented for ALLOCATABLE or POINTER 'alater' and was ignored [-Wignored-directive] | |
| !dir$ align(64) :: alater | |
| real, allocatable :: alater(:) | |
| !WARNING: !DIR$ ALIGN is ignored for 'ok_module' because it is not a component declared in this derived type definition [-Wignored-directive] | |
| !dir$ align(64) :: ok_module | |
| procedure(), pointer, nopass :: pcomp | |
| !WARNING: !DIR$ ALIGN is ignored for 'pcomp' because it is not a variable [-Wignored-directive] | |
| !dir$ align(64) :: pcomp | |
| !WARNING: !DIR$ ALIGN is ignored for 'bound' because it is not a variable [-Wignored-directive] | |
| !dir$ align(64) :: bound | |
| !WARNING: !DIR$ ALIGN is ignored for 'gen' because it is not a variable [-Wignored-directive] | |
| !dir$ align(64) :: gen | |
| contains | |
| procedure, nopass :: bound => sub | |
| generic :: gen => bound | |
| end type | |
| ! A type that has no type-bound procedure part. A component of a later | |
| ! type does not count. | |
| type t2 | |
| !WARNING: !DIR$ ALIGN is ignored for 'ok_module' because it is not a component declared in this derived type definition [-Wignored-directive] | |
| !dir$ align(64) :: ok_module | |
| !WARNING: !DIR$ ALIGN is ignored for 'c3' because it is not a component declared in this derived type definition [-Wignored-directive] | |
| !dir$ align(64) :: c3 | |
| real :: c2 | |
| end type | |
| ! The parent component is declared by the extended type, an inherited | |
| ! component is not. | |
| type, extends(t2) :: t3 | |
| !WARNING: !DIR$ ALIGN is not yet implemented for component 't2' and was ignored [-Wignored-directive] | |
| !dir$ align(64) :: t2 | |
| !WARNING: !DIR$ ALIGN is ignored for 'c2' because it is not a component declared in this derived type definition [-Wignored-directive] | |
| !dir$ align(64) :: c2 | |
| real :: c3 | |
| end type | |
| type pdt(k, n) | |
| integer, kind :: k | |
| integer, len :: n | |
| !WARNING: !DIR$ ALIGN is ignored for 'k' because it is not a variable [-Wignored-directive] | |
| !WARNING: !DIR$ ALIGN is ignored for 'n' because it is not a variable [-Wignored-directive] | |
| !WARNING: !DIR$ ALIGN is not yet implemented for component 'pc' and was ignored [-Wignored-directive] | |
| !dir$ align(64) :: k, n, pc | |
| real(k) :: pc(n) | |
| end type | |
| type(pdt(4, 8)) :: instance | |
| ! The name of a derived type or of a procedure is not a variable. | |
| !WARNING: !DIR$ ALIGN is ignored for 't' because it is not a variable [-Wignored-directive] | |
| !WARNING: !DIR$ ALIGN is ignored for 'sub' because it is not a variable [-Wignored-directive] | |
| !dir$ align(64) :: t, sub | |
| ! Such a name gets one warning too, and a different alignment for it is | |
| ! still an error. | |
| !dir$ align(64) :: sub | |
| !ERROR: 't' already has a different !DIR$ ALIGN alignment | |
| !dir$ align(32) :: t | |
| contains | |
| subroutine sub(d, ad) | |
| !WARNING: !DIR$ ALIGN is ignored for 'd' because it is a dummy argument [-Wignored-directive] | |
| !dir$ align(64) :: d | |
| real :: d(10) | |
| !WARNING: !DIR$ ALIGN is ignored for 'ad' because it is a dummy argument [-Wignored-directive] | |
| !dir$ align(64) :: ad | |
| real, allocatable :: ad(:) | |
| ! A host variable cannot be named, but a local variable that hides one | |
| ! can, even when its declaration follows the directive. | |
| !WARNING: !DIR$ ALIGN is ignored for 'ok_module' because it is not declared in this specification part [-Wignored-directive] | |
| !dir$ align(64) :: ok_module | |
| !dir$ align(64) :: ok_before | |
| !WARNING: !DIR$ ALIGN on 'ok_before' is not yet implemented and was ignored [-Wignored-directive] | |
| real :: ok_before(4) | |
| !WARNING: !DIR$ ALIGN is ignored for 'c1' because it is in COMMON or EQUIVALENCE storage [-Wignored-directive] | |
| !dir$ align(64) :: c1 | |
| !WARNING: !DIR$ ALIGN is ignored for 'e1' because it is in COMMON or EQUIVALENCE storage [-Wignored-directive] | |
| !dir$ align(64) :: e1 | |
| real :: c1, e1, e2 | |
| common /blk/ c1 | |
| equivalence (e1, e2) | |
| ! A specification statement other than a type declaration declares the | |
| ! name too. | |
| !dir$ align(64) :: dim_only | |
| !WARNING: !DIR$ ALIGN on 'dim_only' is not yet implemented and was ignored [-Wignored-directive] | |
| dimension dim_only(4) | |
| ! The names of the directive are resolved at the end of the specification | |
| ! part. A name that first appears in the executable part is not declared | |
| ! by then. Neither is a name that appears only in a NAMELIST group, | |
| ! because the objects of a NAMELIST group are resolved after the | |
| ! executable part. | |
| !WARNING: !DIR$ ALIGN is ignored for 'exec_only' because it is not declared in this specification part [-Wignored-directive] | |
| !dir$ align(64) :: exec_only | |
| !WARNING: !DIR$ ALIGN is ignored for 'nml_only' because it is not declared in this specification part [-Wignored-directive] | |
| !dir$ align(64) :: nml_only | |
| namelist /group/ nml_only | |
| !dir$ align(64) :: h | |
| !WARNING: !DIR$ ALIGN on 'h' is not yet implemented and was ignored [-Wignored-directive] | |
| real :: h(10) | |
| h = 0.0 | |
| exec_only = 0.0 | |
| !WARNING: !DIR$ ALIGN directive is ignored because it is not in the specification part [-Wignored-directive] | |
| !dir$ align(64) :: h | |
| contains | |
| subroutine inner() | |
| !WARNING: !DIR$ ALIGN is ignored for 'h' because it is not declared in this specification part [-Wignored-directive] | |
| !dir$ align(64) :: h | |
| h = 1.0 | |
| end subroutine | |
| end subroutine | |
| subroutine in_block() | |
| real :: outer | |
| block | |
| !WARNING: !DIR$ ALIGN is not yet implemented for ALLOCATABLE or POINTER 'ba' and was ignored [-Wignored-directive] | |
| !dir$ align(64) :: ba | |
| real, allocatable :: ba(:) | |
| !WARNING: !DIR$ ALIGN is ignored for 'outer' because it is not declared in this specification part [-Wignored-directive] | |
| !dir$ align(64) :: outer | |
| outer = 1.0 | |
| end block | |
| end subroutine | |
| ! An implicitly typed name is declared by a statement of the specification | |
| ! part that mentions it, other than NAMELIST (see above). | |
| subroutine implicit_names() | |
| !dir$ align(64) :: save_only, data_only, volatile_only | |
| !WARNING: !DIR$ ALIGN on 'save_only' is not yet implemented and was ignored [-Wignored-directive] | |
| save save_only | |
| !WARNING: !DIR$ ALIGN on 'data_only' is not yet implemented and was ignored [-Wignored-directive] | |
| data data_only /1.0/ | |
| !WARNING: !DIR$ ALIGN on 'volatile_only' is not yet implemented and was ignored [-Wignored-directive] | |
| volatile volatile_only | |
| !WARNING: !DIR$ ALIGN is ignored for 'common_only' because it is in COMMON or EQUIVALENCE storage [-Wignored-directive] | |
| !dir$ align(64) :: common_only | |
| !WARNING: !DIR$ ALIGN is ignored for 'equivalence_only' because it is in COMMON or EQUIVALENCE storage [-Wignored-directive] | |
| !dir$ align(64) :: equivalence_only | |
| common /implicit_blk/ common_only | |
| equivalence (equivalence_only, other) | |
| end subroutine | |
| subroutine implicit_rule() | |
| implicit integer(a-z) | |
| !dir$ align(64) :: by_rule | |
| !WARNING: !DIR$ ALIGN on 'by_rule' is not yet implemented and was ignored [-Wignored-directive] | |
| dimension by_rule(4) | |
| end subroutine | |
| subroutine no_implicit() | |
| implicit none | |
| !WARNING: !DIR$ ALIGN is ignored for 'undeclared' because it is not declared in this specification part [-Wignored-directive] | |
| !dir$ align(64) :: undeclared | |
| end subroutine | |
| ! With a host variable of the same name, DIMENSION and SAVE declare a | |
| ! local variable, and VOLATILE refers to the host variable. | |
| subroutine host_names() | |
| !WARNING: !DIR$ ALIGN is ignored for 'ok_intel' because it is not declared in this specification part [-Wignored-directive] | |
| !dir$ align(64) :: ok_module, ok_after, ok_intel | |
| !WARNING: !DIR$ ALIGN on 'ok_module' is not yet implemented and was ignored [-Wignored-directive] | |
| dimension ok_module(4) | |
| !WARNING: !DIR$ ALIGN on 'ok_after' is not yet implemented and was ignored [-Wignored-directive] | |
| save ok_after | |
| volatile ok_intel | |
| end subroutine | |
| function f() | |
| !WARNING: !DIR$ ALIGN is ignored for 'f' because it is a function result [-Wignored-directive] | |
| !dir$ align(64) :: f | |
| real :: f(10) | |
| f = 0.0 | |
| end function | |
| function g() result(r) | |
| !WARNING: !DIR$ ALIGN is ignored for 'r' because it is a function result [-Wignored-directive] | |
| !dir$ align(64) :: r | |
| real :: r(10) | |
| r = 0.0 | |
| end function | |
| subroutine use_associated() | |
| use other, only: used | |
| !WARNING: !DIR$ ALIGN is ignored for 'used' because it is not declared in this specification part [-Wignored-directive] | |
| !dir$ align(64) :: used | |
| used = 0.0 | |
| end subroutine | |
| ! A dummy argument that has only a type may be a procedure. The ignored | |
| ! directive does not make it an object. | |
| subroutine dummy_procedure(fn, y) | |
| real :: y | |
| !WARNING: !DIR$ ALIGN is ignored for 'fn' because it is a dummy argument [-Wignored-directive] | |
| !dir$ align(64) :: fn | |
| real :: fn | |
| y = fn(1.0) | |
| end subroutine | |
| subroutine external_name() | |
| external ext | |
| !WARNING: !DIR$ ALIGN is ignored for 'ext' because it is not a variable [-Wignored-directive] | |
| !dir$ align(64) :: ext | |
| call ext | |
| end subroutine | |
| end module | |
| !WARNING: !DIR$ ALIGN directive is ignored because it is not in a program unit [-Wignored-directive] | |
| !dir$ align(64) :: y |