[flang] Finish up
authorpeter klausler <pklausler@nvidia.com>
Fri, 12 Apr 2019 17:20:42 +0000 (10:20 -0700)
committerpeter klausler <pklausler@nvidia.com>
Mon, 15 Apr 2019 16:41:48 +0000 (09:41 -0700)
Original-commit: flang-compiler/f18@8c8242e6f441377ec2d209d5c178787d64f6398e
Reviewed-on: https://github.com/flang-compiler/f18/pull/406
Tree-same-pre-rewrite: false

flang/lib/semantics/resolve-names.cc
flang/test/semantics/CMakeLists.txt
flang/test/semantics/deallocate04.f90
flang/test/semantics/deallocate05.f90 [new file with mode: 0644]
flang/test/semantics/doconcurrent04.f90

index 27e7e89..aaf603e 100644 (file)
@@ -2526,7 +2526,7 @@ void DeclarationVisitor::CheckScalarIntegerType(const parser::Name &name) {
     }
     if (auto *type{symbol.GetType()}) {
       if (!type->IsNumeric(TypeCategory::Integer)) {
-        Say(name, "Variable '%s' is not integer"_err_en_US);
+        Say(name, "Variable '%s' is not INTEGER"_err_en_US);
         return;
       }
     }
index ea6e7d1..a1bb925 100644 (file)
@@ -93,6 +93,7 @@ set(ERROR_TESTS
   nullify02.f90
   deallocate01.f90
   deallocate04.f90
+  deallocate05.f90
 )
 
 # These test files have expected symbols in the source
index 68649cf..a76ab6c 100644 (file)
@@ -12,7 +12,7 @@
 ! See the License for the specific language governing permissions and
 ! limitations under the License.
 
-! Check for semantic errors in DEALLOCATE statements
+! Check for type errors in DEALLOCATE statements
 
 INTEGER, PARAMETER :: maxvalue=1024
 
@@ -23,7 +23,7 @@ Type t
   Type(dt) :: p
 End Type
 
-Type(t),Allocatable :: x(:)
+Type(t),Allocatable :: x
 
 Real :: r
 Integer :: s
@@ -32,47 +32,13 @@ Integer :: pi
 Character(256) :: ee
 Procedure(Real) :: prp
 
-Allocate(x(3))
+Allocate(x)
 
-!ERROR: component in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
-Deallocate(x(2)%p)
+!ERROR: Must have CHARACTER type, but is INTEGER(4)
+Deallocate(x, stat=s, errmsg=e)
 
-!ERROR: name in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
-Deallocate(pi)
-
-!ERROR: component in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
-!ERROR: name in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
-Deallocate(x(2)%p, pi)
-
-!ERROR: name in DEALLOCATE statement must be a variable name
-Deallocate(prp)
-
-!ERROR: name in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
-!ERROR: name in DEALLOCATE statement must be a variable name
-Deallocate(pi, prp)
-
-!ERROR: name in DEALLOCATE statement must be a variable name
-Deallocate(maxvalue)
-
-!ERROR: component in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
-Deallocate(x%p)
-
-!ERROR: component in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
-!ERROR: Must have default CHARACTER type
-Deallocate(x%p, stat=s, errmsg=e)
-
-!ERROR: component in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
-!ERROR: Must have INTEGER type
-!ERROR: Must have default CHARACTER type
-Deallocate(x%p, stat=r, errmsg=e)
-
-!ERROR: STAT may not be duplicated in a DEALLOCATE statement
-Deallocate(x, stat=s, stat=s)
-!ERROR: ERRMSG may not be duplicated in a DEALLOCATE statement
-Deallocate(x, errmsg=ee, errmsg=ee)
-!ERROR: STAT may not be duplicated in a DEALLOCATE statement
-Deallocate(x, stat=s, errmsg=ee, stat=s)
-!ERROR: ERRMSG may not be duplicated in a DEALLOCATE statement
-Deallocate(x, stat=s, errmsg=ee, errmsg=ee)
+!ERROR: Must have INTEGER type, but is REAL(4)
+!ERROR: Must have CHARACTER type, but is INTEGER(4)
+Deallocate(x, stat=r, errmsg=e)
 
 End Program
diff --git a/flang/test/semantics/deallocate05.f90 b/flang/test/semantics/deallocate05.f90
new file mode 100644 (file)
index 0000000..d3b64e3
--- /dev/null
@@ -0,0 +1,69 @@
+! Copyright (c) 2019, NVIDIA CORPORATION.  All rights reserved.
+!
+! Licensed under the Apache License, Version 2.0 (the "License");
+! you may not use this file except in compliance with the License.
+! You may obtain a copy of the License at
+!
+!     http://www.apache.org/licenses/LICENSE-2.0
+!
+! Unless required by applicable law or agreed to in writing, software
+! distributed under the License is distributed on an "AS IS" BASIS,
+! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+! See the License for the specific language governing permissions and
+! limitations under the License.
+
+! Check for semantic errors in DEALLOCATE statements
+
+INTEGER, PARAMETER :: maxvalue=1024
+
+Type dt
+  Integer :: l = 3
+End Type
+Type t
+  Type(dt) :: p
+End Type
+
+Type(t),Allocatable :: x(:)
+
+Real :: r
+Integer :: s
+Integer :: e
+Integer :: pi
+Character(256) :: ee
+Procedure(Real) :: prp
+
+Allocate(x(3))
+
+!ERROR: component in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
+Deallocate(x(2)%p)
+
+!ERROR: name in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
+Deallocate(pi)
+
+!ERROR: component in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
+!ERROR: name in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
+Deallocate(x(2)%p, pi)
+
+!ERROR: name in DEALLOCATE statement must be a variable name
+Deallocate(prp)
+
+!ERROR: name in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
+!ERROR: name in DEALLOCATE statement must be a variable name
+Deallocate(pi, prp)
+
+!ERROR: name in DEALLOCATE statement must be a variable name
+Deallocate(maxvalue)
+
+!ERROR: component in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
+Deallocate(x%p)
+
+!ERROR: STAT may not be duplicated in a DEALLOCATE statement
+Deallocate(x, stat=s, stat=s)
+!ERROR: ERRMSG may not be duplicated in a DEALLOCATE statement
+Deallocate(x, errmsg=ee, errmsg=ee)
+!ERROR: STAT may not be duplicated in a DEALLOCATE statement
+Deallocate(x, stat=s, errmsg=ee, stat=s)
+!ERROR: ERRMSG may not be duplicated in a DEALLOCATE statement
+Deallocate(x, stat=s, errmsg=ee, errmsg=ee)
+
+End Program
index f6b8fa7..ac03d94 100644 (file)
 ! limitations under the License.
 
 ! RUN: ${F18} -funparse-with-symbols %s 2>&1 | ${FileCheck} %s
-! CHECK: must have INTEGER type, but is REAL(4)
+! CHECK: Variable 'j' is not INTEGER
 
-subroutine do_concurrent_test1(i,n)
+subroutine do_concurrent_test1(n)
   implicit none
+  integer :: n
   real :: j
   do 20 concurrent (j = 1:n)
 20 enddo