diff --git a/include/flang/Error/errmsg-in.n b/include/flang/Error/errmsg-in.n index b0589939b14..38c359ea963 100644 --- a/include/flang/Error/errmsg-in.n +++ b/include/flang/Error/errmsg-in.n @@ -1470,3 +1470,41 @@ Pragma operator errors. .MS S 1013 "Static Threadprivate variables are not supported - $" .MS S 1014 "Global Threadprivate variables are not supported - $" .MS S 1015 "Cannot access private intrinsic - $" +.MS S 1042 "$ mask expression must be scalar" +A DO CONCURRENT or FORALL mask expression must be scalar. +.MS S 1043 "DO CONCURRENT $ references construct variable $" +A DO CONCURRENT limit or step control expression may not reference an index +name or LOCAL name. A DO CONCURRENT mask expression may not reference a +LOCAL name. +.MS S 1044 "Invalid DO CONCURRENT locality spec variable $" +A name in a DO CONCURRENT locality spec must be a valid variable name in the containing scope. +.MS S 1045 "DO CONCURRENT index name $ may not appear in a locality spec" +.MS S 1046 "Variable $ has multiple DO CONCURRENT locality spec references" +.MS S 1047 "Multiple DO CONCURRENT DEFAULT(NONE) locality specs" +.MS S 1048 "LOCAL/LOCAL_INIT variable $ $" +A DO CONCURRENT LOCAL or LOCAL_INIT variable must not have the ALLOCATABLE, +INTENT (IN), or OPTIONAL attribute, must not be of finalizable type, must +not be a nonpointer polymorphic dummy argument, must not be a an assumed-size +array, and must be permitted to appear in a variable definition context. +.MS S 1049 "Variable $ is not in a DO CONCURRENT locality list" +When DEFAULT(NONE) is specified for a DO CONCURRENT loop, construct variables and variables from containing scopes must appear in a locality spec. +.MS S 1050 "$ DO CONCURRENT construct" +A DO CONCURRENT construct may not contain a RETURN, EXIT, GOTO, or other branch +out of the construct. A CYCLE statement is permitted. +.MS S 1051 "DO CONCURRENT polymorphic variable deallocation - $" +A DO CONCURRENT construct must not contain a statement that might result in +the deallocation of a polymorphic variable. +.MS S 1052 "$ call in DO CONCURRENT construct" +A DO CONCURRENT construct may not contain a call to IEEE_GET_FLAG, +IEEE_SET_HALTING_MODE, or IEEE_GET_HALTING_MODE from intrinsic module +IEEE_EXCEPTIONS. +.MS S 1053 "Duplicate $ index name" +A DO CONCURRENT or FORALL construct or statement may not specify an index name multiple times. +.MS W 1054 "Duplicate subprogram prefix $ is used" +.MS S 1055 "MODULE prefix cannot be inside an abstract interface" +.MS S 1056 "MODULE prefix is only allowed for subprograms that were declared as separate module procedures" +.MS S 1057 "Definition argument name $ does not match declaration argument name $" +.MS S 1058 "The type of definition argument $ does not match its declaration type" +.MS S 1059 "The definition of subprogram $ does not have the same number of arguments as its declaration" +.MS S 1060 "The $ of the definition and declaration of subprogram $ must match" +.MS S 1061 "The definition of function return type of $ does not match its declaration type" diff --git a/test/f90_correct/inc/fs23626.mk b/test/f90_correct/inc/fs23626.mk new file mode 100644 index 00000000000..87156b3509d --- /dev/null +++ b/test/f90_correct/inc/fs23626.mk @@ -0,0 +1,24 @@ +# Copyright (c) 2018, 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. + +build: + @echo ------------------------------------ building test $(TEST) + $(FC) $(FFLAGS) $(LDFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(EXE) + +run: + $(TEST).$(EXE) + +verify: ; + + diff --git a/test/f90_correct/inc/fs25878_a.mk b/test/f90_correct/inc/fs25878_a.mk new file mode 100644 index 00000000000..aa1c9b36bc2 --- /dev/null +++ b/test/f90_correct/inc/fs25878_a.mk @@ -0,0 +1,24 @@ +# Copyright (c) 2018, 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. + +build: + @echo ------------------------------------ building test $(TEST) + $(FC) $(FFLAGS) $(LDFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(EXESUFFIX) + +run: $(TEST).$(EXESUFFIX) + @echo ------------------------------------ executing test $(TEST) + $(TEST).$(EXESUFFIX) + +verify: + @echo PASS diff --git a/test/f90_correct/inc/fs25878_b.mk b/test/f90_correct/inc/fs25878_b.mk new file mode 100644 index 00000000000..aa1c9b36bc2 --- /dev/null +++ b/test/f90_correct/inc/fs25878_b.mk @@ -0,0 +1,24 @@ +# Copyright (c) 2018, 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. + +build: + @echo ------------------------------------ building test $(TEST) + $(FC) $(FFLAGS) $(LDFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(EXESUFFIX) + +run: $(TEST).$(EXESUFFIX) + @echo ------------------------------------ executing test $(TEST) + $(TEST).$(EXESUFFIX) + +verify: + @echo PASS diff --git a/test/f90_correct/inc/fs26026.mk b/test/f90_correct/inc/fs26026.mk new file mode 100644 index 00000000000..c03a110d26f --- /dev/null +++ b/test/f90_correct/inc/fs26026.mk @@ -0,0 +1,26 @@ +# Copyright (c) 2018, 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. + +build: + @echo ------------------------------------- building test $@ + $(FC) $(FFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(EXE) + +run: + @echo ------------------------------------ executing test $@ + ./$(TEST).$(EXE) + +verify: + @echo ------------------------------------ verifying + @echo test should have printed verification above + diff --git a/test/f90_correct/inc/submod01.mk b/test/f90_correct/inc/submod01.mk new file mode 100644 index 00000000000..11b59a9171c --- /dev/null +++ b/test/f90_correct/inc/submod01.mk @@ -0,0 +1,23 @@ +# Copyright (c) 2018, 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. + +build: + @echo ------------------------------------- building test $@ + $(FC) $(FFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(EXE) + +run: + @echo ------------------------------------ executing test $@ + ./$(TEST).$(EXE) + +verify: ; diff --git a/test/f90_correct/inc/submod02.mk b/test/f90_correct/inc/submod02.mk new file mode 100644 index 00000000000..11b59a9171c --- /dev/null +++ b/test/f90_correct/inc/submod02.mk @@ -0,0 +1,23 @@ +# Copyright (c) 2018, 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. + +build: + @echo ------------------------------------- building test $@ + $(FC) $(FFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(EXE) + +run: + @echo ------------------------------------ executing test $@ + ./$(TEST).$(EXE) + +verify: ; diff --git a/test/f90_correct/inc/submod03_a.mk b/test/f90_correct/inc/submod03_a.mk new file mode 100644 index 00000000000..11b59a9171c --- /dev/null +++ b/test/f90_correct/inc/submod03_a.mk @@ -0,0 +1,23 @@ +# Copyright (c) 2018, 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. + +build: + @echo ------------------------------------- building test $@ + $(FC) $(FFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(EXE) + +run: + @echo ------------------------------------ executing test $@ + ./$(TEST).$(EXE) + +verify: ; diff --git a/test/f90_correct/inc/submod03_b.mk b/test/f90_correct/inc/submod03_b.mk new file mode 100644 index 00000000000..11b59a9171c --- /dev/null +++ b/test/f90_correct/inc/submod03_b.mk @@ -0,0 +1,23 @@ +# Copyright (c) 2018, 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. + +build: + @echo ------------------------------------- building test $@ + $(FC) $(FFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(EXE) + +run: + @echo ------------------------------------ executing test $@ + ./$(TEST).$(EXE) + +verify: ; diff --git a/test/f90_correct/inc/submod04.mk b/test/f90_correct/inc/submod04.mk new file mode 100644 index 00000000000..11b59a9171c --- /dev/null +++ b/test/f90_correct/inc/submod04.mk @@ -0,0 +1,23 @@ +# Copyright (c) 2018, 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. + +build: + @echo ------------------------------------- building test $@ + $(FC) $(FFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(EXE) + +run: + @echo ------------------------------------ executing test $@ + ./$(TEST).$(EXE) + +verify: ; diff --git a/test/f90_correct/inc/submod05_a.mk b/test/f90_correct/inc/submod05_a.mk new file mode 100644 index 00000000000..11b59a9171c --- /dev/null +++ b/test/f90_correct/inc/submod05_a.mk @@ -0,0 +1,23 @@ +# Copyright (c) 2018, 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. + +build: + @echo ------------------------------------- building test $@ + $(FC) $(FFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(EXE) + +run: + @echo ------------------------------------ executing test $@ + ./$(TEST).$(EXE) + +verify: ; diff --git a/test/f90_correct/inc/submod05_b.mk b/test/f90_correct/inc/submod05_b.mk new file mode 100644 index 00000000000..11b59a9171c --- /dev/null +++ b/test/f90_correct/inc/submod05_b.mk @@ -0,0 +1,23 @@ +# Copyright (c) 2018, 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. + +build: + @echo ------------------------------------- building test $@ + $(FC) $(FFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(EXE) + +run: + @echo ------------------------------------ executing test $@ + ./$(TEST).$(EXE) + +verify: ; diff --git a/test/f90_correct/inc/submod06.mk b/test/f90_correct/inc/submod06.mk new file mode 100644 index 00000000000..11b59a9171c --- /dev/null +++ b/test/f90_correct/inc/submod06.mk @@ -0,0 +1,23 @@ +# Copyright (c) 2018, 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. + +build: + @echo ------------------------------------- building test $@ + $(FC) $(FFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(EXE) + +run: + @echo ------------------------------------ executing test $@ + ./$(TEST).$(EXE) + +verify: ; diff --git a/test/f90_correct/inc/submod12.mk b/test/f90_correct/inc/submod12.mk new file mode 100644 index 00000000000..11b59a9171c --- /dev/null +++ b/test/f90_correct/inc/submod12.mk @@ -0,0 +1,23 @@ +# Copyright (c) 2018, 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. + +build: + @echo ------------------------------------- building test $@ + $(FC) $(FFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(EXE) + +run: + @echo ------------------------------------ executing test $@ + ./$(TEST).$(EXE) + +verify: ; diff --git a/test/f90_correct/inc/submod20.mk b/test/f90_correct/inc/submod20.mk new file mode 100644 index 00000000000..c03a110d26f --- /dev/null +++ b/test/f90_correct/inc/submod20.mk @@ -0,0 +1,26 @@ +# Copyright (c) 2018, 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. + +build: + @echo ------------------------------------- building test $@ + $(FC) $(FFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(EXE) + +run: + @echo ------------------------------------ executing test $@ + ./$(TEST).$(EXE) + +verify: + @echo ------------------------------------ verifying + @echo test should have printed verification above + diff --git a/test/f90_correct/inc/submod21.mk b/test/f90_correct/inc/submod21.mk new file mode 100644 index 00000000000..c03a110d26f --- /dev/null +++ b/test/f90_correct/inc/submod21.mk @@ -0,0 +1,26 @@ +# Copyright (c) 2018, 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. + +build: + @echo ------------------------------------- building test $@ + $(FC) $(FFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(EXE) + +run: + @echo ------------------------------------ executing test $@ + ./$(TEST).$(EXE) + +verify: + @echo ------------------------------------ verifying + @echo test should have printed verification above + diff --git a/test/f90_correct/inc/submod23.mk b/test/f90_correct/inc/submod23.mk new file mode 100644 index 00000000000..359db2553f9 --- /dev/null +++ b/test/f90_correct/inc/submod23.mk @@ -0,0 +1,15 @@ +# Copyright (c) 2018, 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. + +include $(SRC)/inc/submod_neg.mk diff --git a/test/f90_correct/inc/submod24.mk b/test/f90_correct/inc/submod24.mk new file mode 100644 index 00000000000..359db2553f9 --- /dev/null +++ b/test/f90_correct/inc/submod24.mk @@ -0,0 +1,15 @@ +# Copyright (c) 2018, 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. + +include $(SRC)/inc/submod_neg.mk diff --git a/test/f90_correct/inc/submod27.mk b/test/f90_correct/inc/submod27.mk new file mode 100644 index 00000000000..359db2553f9 --- /dev/null +++ b/test/f90_correct/inc/submod27.mk @@ -0,0 +1,15 @@ +# Copyright (c) 2018, 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. + +include $(SRC)/inc/submod_neg.mk diff --git a/test/f90_correct/inc/submod28.mk b/test/f90_correct/inc/submod28.mk new file mode 100644 index 00000000000..c03a110d26f --- /dev/null +++ b/test/f90_correct/inc/submod28.mk @@ -0,0 +1,26 @@ +# Copyright (c) 2018, 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. + +build: + @echo ------------------------------------- building test $@ + $(FC) $(FFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(EXE) + +run: + @echo ------------------------------------ executing test $@ + ./$(TEST).$(EXE) + +verify: + @echo ------------------------------------ verifying + @echo test should have printed verification above + diff --git a/test/f90_correct/inc/submod29.mk b/test/f90_correct/inc/submod29.mk new file mode 100644 index 00000000000..63256a1c894 --- /dev/null +++ b/test/f90_correct/inc/submod29.mk @@ -0,0 +1,15 @@ +# Copyright (c) 2018, 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. + +include $(SRC)/inc/submod_pos.mk diff --git a/test/f90_correct/inc/submod32.mk b/test/f90_correct/inc/submod32.mk new file mode 100644 index 00000000000..63256a1c894 --- /dev/null +++ b/test/f90_correct/inc/submod32.mk @@ -0,0 +1,15 @@ +# Copyright (c) 2018, 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. + +include $(SRC)/inc/submod_pos.mk diff --git a/test/f90_correct/inc/submod33.mk b/test/f90_correct/inc/submod33.mk new file mode 100644 index 00000000000..63256a1c894 --- /dev/null +++ b/test/f90_correct/inc/submod33.mk @@ -0,0 +1,15 @@ +# Copyright (c) 2018, 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. + +include $(SRC)/inc/submod_pos.mk diff --git a/test/f90_correct/inc/submod34.mk b/test/f90_correct/inc/submod34.mk new file mode 100644 index 00000000000..63256a1c894 --- /dev/null +++ b/test/f90_correct/inc/submod34.mk @@ -0,0 +1,15 @@ +# Copyright (c) 2018, 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. + +include $(SRC)/inc/submod_pos.mk diff --git a/test/f90_correct/inc/submod35.mk b/test/f90_correct/inc/submod35.mk new file mode 100644 index 00000000000..63256a1c894 --- /dev/null +++ b/test/f90_correct/inc/submod35.mk @@ -0,0 +1,15 @@ +# Copyright (c) 2018, 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. + +include $(SRC)/inc/submod_pos.mk diff --git a/test/f90_correct/inc/submod39.mk b/test/f90_correct/inc/submod39.mk new file mode 100644 index 00000000000..ace51b6766b --- /dev/null +++ b/test/f90_correct/inc/submod39.mk @@ -0,0 +1,29 @@ +# Copyright (c) 2018, 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. + +build: clean + @echo ------------------------------------ building test $(TEST) +# -@$(CP) $(SRC)/$(TEST).f90 . + -$(FC) -c $(FCFLAGS) $(SRC)/$(TEST).f90 > $(TEST).rslt 2>&1 + +run: + @echo ------------------------------------ test $(TEST) not expected to execute + +verify: + @echo ------------------------------------ verifying test $(TEST) + $(COMP_CHECK) $(SRC)/$(TEST).f90 $(TEST).rslt $(FC) + +clean: + -@$(RM) $(TEST).rslt $(TEST).$(OBJX) *.mod $(TEST).$(EXE) + diff --git a/test/f90_correct/inc/submod40.mk b/test/f90_correct/inc/submod40.mk new file mode 100644 index 00000000000..ace51b6766b --- /dev/null +++ b/test/f90_correct/inc/submod40.mk @@ -0,0 +1,29 @@ +# Copyright (c) 2018, 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. + +build: clean + @echo ------------------------------------ building test $(TEST) +# -@$(CP) $(SRC)/$(TEST).f90 . + -$(FC) -c $(FCFLAGS) $(SRC)/$(TEST).f90 > $(TEST).rslt 2>&1 + +run: + @echo ------------------------------------ test $(TEST) not expected to execute + +verify: + @echo ------------------------------------ verifying test $(TEST) + $(COMP_CHECK) $(SRC)/$(TEST).f90 $(TEST).rslt $(FC) + +clean: + -@$(RM) $(TEST).rslt $(TEST).$(OBJX) *.mod $(TEST).$(EXE) + diff --git a/test/f90_correct/inc/submod41.mk b/test/f90_correct/inc/submod41.mk new file mode 100644 index 00000000000..ace51b6766b --- /dev/null +++ b/test/f90_correct/inc/submod41.mk @@ -0,0 +1,29 @@ +# Copyright (c) 2018, 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. + +build: clean + @echo ------------------------------------ building test $(TEST) +# -@$(CP) $(SRC)/$(TEST).f90 . + -$(FC) -c $(FCFLAGS) $(SRC)/$(TEST).f90 > $(TEST).rslt 2>&1 + +run: + @echo ------------------------------------ test $(TEST) not expected to execute + +verify: + @echo ------------------------------------ verifying test $(TEST) + $(COMP_CHECK) $(SRC)/$(TEST).f90 $(TEST).rslt $(FC) + +clean: + -@$(RM) $(TEST).rslt $(TEST).$(OBJX) *.mod $(TEST).$(EXE) + diff --git a/test/f90_correct/lit/fs23626.sh b/test/f90_correct/lit/fs23626.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/fs23626.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/fs25878_a.sh b/test/f90_correct/lit/fs25878_a.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/fs25878_a.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/fs25878_b.sh b/test/f90_correct/lit/fs25878_b.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/fs25878_b.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/fs26026.sh b/test/f90_correct/lit/fs26026.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/fs26026.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod01.sh b/test/f90_correct/lit/submod01.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod01.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod02.sh b/test/f90_correct/lit/submod02.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod02.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod03_a.sh b/test/f90_correct/lit/submod03_a.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod03_a.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod03_b.sh b/test/f90_correct/lit/submod03_b.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod03_b.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod04.sh b/test/f90_correct/lit/submod04.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod04.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod05_a.sh b/test/f90_correct/lit/submod05_a.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod05_a.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod05_b.sh b/test/f90_correct/lit/submod05_b.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod05_b.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod06.sh b/test/f90_correct/lit/submod06.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod06.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod12.sh b/test/f90_correct/lit/submod12.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod12.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod20.sh b/test/f90_correct/lit/submod20.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod20.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod21.sh b/test/f90_correct/lit/submod21.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod21.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod23.sh b/test/f90_correct/lit/submod23.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod23.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod24.sh b/test/f90_correct/lit/submod24.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod24.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod27.sh b/test/f90_correct/lit/submod27.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod27.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod28.sh b/test/f90_correct/lit/submod28.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod28.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod29.sh b/test/f90_correct/lit/submod29.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod29.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod32.sh b/test/f90_correct/lit/submod32.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod32.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod33.sh b/test/f90_correct/lit/submod33.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod33.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod34.sh b/test/f90_correct/lit/submod34.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod34.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod35.sh b/test/f90_correct/lit/submod35.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod35.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod39.sh b/test/f90_correct/lit/submod39.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod39.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod40.sh b/test/f90_correct/lit/submod40.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod40.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/lit/submod41.sh b/test/f90_correct/lit/submod41.sh new file mode 100644 index 00000000000..a9dfc621160 --- /dev/null +++ b/test/f90_correct/lit/submod41.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017, 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. + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/makefile b/test/f90_correct/makefile index 5abfaa20231..87bac3cfd1b 100644 --- a/test/f90_correct/makefile +++ b/test/f90_correct/makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. +# Copyright (c) 2017-2018, 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. @@ -30,6 +30,7 @@ LDFLAGS=$(EXTRA_LDFLAGS) LIBS=$(EXTRA_LIBS) CFLAGS=$(EXTRA_CFLAGS) TEST= +COMP_CHECK=python $(HOMEQA)/../tools/check_compilation.py RM=rm -f CP=cp -f diff --git a/test/f90_correct/src/fs23626.f90 b/test/f90_correct/src/fs23626.f90 new file mode 100644 index 00000000000..e3fed047587 --- /dev/null +++ b/test/f90_correct/src/fs23626.f90 @@ -0,0 +1,38 @@ +! Copyright (c) 2018, 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. +! +program a + implicit none + + type :: t1 + integer, dimension(:), allocatable :: mem1 + end type + type :: t2 + type(t1), dimension(:), allocatable :: mem2 + end type + + integer, dimension(2) :: i = (/2, 3/) + type(t2) :: x + type(t2) :: y + allocate(x%mem2(8)) + + x%mem2(1)%mem1 = (/11, 12, 13, 14/) + x%mem2(2)%mem1 = (/21, 22, 23, 24/) + x%mem2(3)%mem1 = (/31, 32, 33, 34/) + + y%mem2 = x%mem2(i) + if (y%mem2(1)%mem1(1) /= 21) stop "FAIL" + stop "PASS" + +end program diff --git a/test/f90_correct/src/fs25878_a.f90 b/test/f90_correct/src/fs25878_a.f90 new file mode 100644 index 00000000000..0cb27112c7b --- /dev/null +++ b/test/f90_correct/src/fs25878_a.f90 @@ -0,0 +1,19 @@ +! Copyright (c) 2018, 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. + +type t +end type + +print *, (/t()/) +end diff --git a/test/f90_correct/src/fs25878_b.f90 b/test/f90_correct/src/fs25878_b.f90 new file mode 100644 index 00000000000..a8a297fa1d2 --- /dev/null +++ b/test/f90_correct/src/fs25878_b.f90 @@ -0,0 +1,22 @@ +! Copyright (c) 2018, 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. + +type t +end type + +type(t) :: z(1) +z = t() + +print *, z +end diff --git a/test/f90_correct/src/fs26026.f90 b/test/f90_correct/src/fs26026.f90 new file mode 100644 index 00000000000..bbffc08ff5a --- /dev/null +++ b/test/f90_correct/src/fs26026.f90 @@ -0,0 +1,42 @@ +! Copyright (c) 2018, 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. + +module m +implicit none +integer :: i = 0 +contains + subroutine p() + i = 1 + end subroutine p + + subroutine foo(fun_ptr) + procedure(p), pointer, intent(out) :: fun_ptr + fun_ptr => p + end subroutine +end module m + +program test +use m +implicit none +procedure(), pointer :: x +call foo(x) +call x() +if (i == 1) then + write(*,*) 'PASS' +else + write(*,*) 'FAIL' + STOP 1 +end if +end program test + diff --git a/test/f90_correct/src/inc/submod_neg.mk b/test/f90_correct/src/inc/submod_neg.mk new file mode 100644 index 00000000000..ace51b6766b --- /dev/null +++ b/test/f90_correct/src/inc/submod_neg.mk @@ -0,0 +1,29 @@ +# Copyright (c) 2018, 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. + +build: clean + @echo ------------------------------------ building test $(TEST) +# -@$(CP) $(SRC)/$(TEST).f90 . + -$(FC) -c $(FCFLAGS) $(SRC)/$(TEST).f90 > $(TEST).rslt 2>&1 + +run: + @echo ------------------------------------ test $(TEST) not expected to execute + +verify: + @echo ------------------------------------ verifying test $(TEST) + $(COMP_CHECK) $(SRC)/$(TEST).f90 $(TEST).rslt $(FC) + +clean: + -@$(RM) $(TEST).rslt $(TEST).$(OBJX) *.mod $(TEST).$(EXE) + diff --git a/test/f90_correct/src/inc/submod_pos.mk b/test/f90_correct/src/inc/submod_pos.mk new file mode 100644 index 00000000000..c03a110d26f --- /dev/null +++ b/test/f90_correct/src/inc/submod_pos.mk @@ -0,0 +1,26 @@ +# Copyright (c) 2018, 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. + +build: + @echo ------------------------------------- building test $@ + $(FC) $(FFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(EXE) + +run: + @echo ------------------------------------ executing test $@ + ./$(TEST).$(EXE) + +verify: + @echo ------------------------------------ verifying + @echo test should have printed verification above + diff --git a/test/f90_correct/src/submod01.f90 b/test/f90_correct/src/submod01.f90 new file mode 100644 index 00000000000..6fb8e945066 --- /dev/null +++ b/test/f90_correct/src/submod01.f90 @@ -0,0 +1,45 @@ +! Copyright (c) 1990-2018, 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. + +! Submodule test with only one suroutine test inside a submodule +! +MODULE m + INTEGER :: res ! The ancestor module m + INTERFACE + MODULE SUBROUTINE sub1(arg1) ! Module procedure interface body for sub1 + INTEGER, intent(inout) :: arg1 + END SUBROUTINE + END INTERFACE +END MODULE + +SUBMODULE (m) n ! The descendant submodule n + CONTAINS ! Module subprogram part + MODULE SUBROUTINE sub1(arg1) ! Definition of sub1 by subroutine subprogram + INTEGER, intent(inout) :: arg1 + arg1 = arg1 + 1 + END SUBROUTINE sub1 +END SUBMODULE + +program test +use m +implicit none + integer :: k, h + k = 99 + call sub1(k) + if (k .ne. 100) then + print *, "FAIL" + else + print *, "PASS" + end if +end program test diff --git a/test/f90_correct/src/submod02.f90 b/test/f90_correct/src/submod02.f90 new file mode 100644 index 00000000000..d1eaf2a74fb --- /dev/null +++ b/test/f90_correct/src/submod02.f90 @@ -0,0 +1,47 @@ +! Copyright (c) 1990-2018, 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. + +! Test with only one function inside a submodule. +! +MODULE m ! The ancestor module m + INTERFACE + MODULE FUNCTION sub2(arg2) result (res) ! Module procedure interface body for sub2 + INTEGER, intent(in) :: arg2 + INTEGER :: res + END FUNCTION + END INTERFACE +END MODULE + +SUBMODULE (m) n ! The descendant submodule n + CONTAINS ! Module subprogram part + MODULE FUNCTION sub2(arg2) result (res) ! Definition of sub2 by separate module subprogram + INTEGER, intent(in) :: arg2 + INTEGER :: res + res = arg2 + 1 + END FUNCTION sub2 +END SUBMODULE + +program test +use m +implicit none + integer :: h + integer :: haha + h = 99 + haha = sub2(h) + if (haha .ne. 100) then + print *, "FAIL" + else + print *, "PASS" + end if +end program test diff --git a/test/f90_correct/src/submod03_a.f90 b/test/f90_correct/src/submod03_a.f90 new file mode 100644 index 00000000000..bdf21d9cfdb --- /dev/null +++ b/test/f90_correct/src/submod03_a.f90 @@ -0,0 +1,47 @@ +! Copyright (c) 1990-2018, 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. + +! Test of using derived type inside subroutines of a sudmodule +! +MODULE m1 + TYPE Base + INTEGER :: a + END TYPE + + INTERFACE + MODULE SUBROUTINE sub1(b) ! Module procedure interface body for sub1 + TYPE(Base), INTENT(IN) :: b + END SUBROUTINE + END INTERFACE +END MODULE + +SUBMODULE (m1) m1sub + CONTAINS + MODULE SUBROUTINE sub1(b) ! Implementation of sub1 declared in m1 + TYPE(Base), INTENT(IN) :: b + !PRINT *, "sub1", b + if (b%a .ne. 11) then + print *, "FAIL" + else + print *, "PASS" + end if + END SUBROUTINE +END SUBMODULE + +PROGRAM example + USE m1 + implicit none + CALL sub1(Base(11)) + +END PROGRAM diff --git a/test/f90_correct/src/submod03_b.f90 b/test/f90_correct/src/submod03_b.f90 new file mode 100644 index 00000000000..28e1e1bed4e --- /dev/null +++ b/test/f90_correct/src/submod03_b.f90 @@ -0,0 +1,46 @@ +! Copyright (c) 1990-2018, 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. + +! Test of using derived type inside procedures of a sudmodule +! + +MODULE m1 + TYPE Base + INTEGER :: a + END TYPE + + INTERFACE + MODULE SUBROUTINE sub1(b) ! Module procedure interface body for sub1 + TYPE(Base), INTENT(IN) :: b + END SUBROUTINE + END INTERFACE +END MODULE + +SUBMODULE (m1) m1sub + CONTAINS + MODULE PROCEDURE sub1 ! Implementation of sub1 declared in m1 + !PRINT *, "sub1", b + if (b%a .ne. 11) then + print *, "FAIL" + else + print *, "PASS" + end if + END PROCEDURE +END SUBMODULE + +PROGRAM example + USE m1 + implicit none + CALL sub1(Base(11)) +END PROGRAM diff --git a/test/f90_correct/src/submod04.f90 b/test/f90_correct/src/submod04.f90 new file mode 100644 index 00000000000..c8a64486ee9 --- /dev/null +++ b/test/f90_correct/src/submod04.f90 @@ -0,0 +1,44 @@ +! Copyright (c) 1990-2018, 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. + +! Test with only one procedure inside a submodule + +MODULE m ! The ancestor module m + INTEGER :: res + INTERFACE + MODULE SUBROUTINE sub2(arg2) + INTEGER, intent(inout) :: arg2 + END SUBROUTINE + END INTERFACE +END MODULE + +SUBMODULE (m) n ! The descendant submodule n + CONTAINS ! Module subprogram part + MODULE procedure sub2 ! Definition of sub2 by separate module subprogram + res = arg2 + 1 + if (res .ne. 100) then + print *, "FAIL" + else + print *, "PASS" + end if + END procedure sub2 +END SUBMODULE + +program test +use m +implicit none + integer :: h + h = 99 + call sub2(h) +end program diff --git a/test/f90_correct/src/submod05_a.f90 b/test/f90_correct/src/submod05_a.f90 new file mode 100644 index 00000000000..2106f2151d8 --- /dev/null +++ b/test/f90_correct/src/submod05_a.f90 @@ -0,0 +1,60 @@ +! Copyright (c) 1990-2018, 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. + +! Test of using with two procedures inside a submodule. +! + +MODULE m ! The ancestor module m + INTERFACE + MODULE SUBROUTINE sub1(arg1) ! Module procedure interface body for sub2 + INTEGER, intent(inout) :: arg1 + END SUBROUTINE + + MODULE SUBROUTINE sub2(arg2) ! Module procedure interface body for sub2 + INTEGER, intent(inout) :: arg2 + END SUBROUTINE + + END INTERFACE +END MODULE + +SUBMODULE (m) n ! The descendant submodule n + CONTAINS ! Module subprogram part + MODULE PROCEDURE sub1 ! Definition of sub2 by separate module subprogram + arg1 = arg1 + 1 + if (arg1 .ne. 100) then + print *, "FAIL" + else + print *, "PASS" + end if + END PROCEDURE sub1 + + MODULE PROCEDURE sub2 ! Definition of sub2 by separate module subprogram + if (arg2 .ne. 100) then + print *, "FAIL" + else + print *, "PASS" + end if + + END PROCEDURE sub2 + +END SUBMODULE + +program test +use m +implicit none + integer :: h + h = 99 + call sub1(h) + call sub2(h) +end program diff --git a/test/f90_correct/src/submod05_b.f90 b/test/f90_correct/src/submod05_b.f90 new file mode 100644 index 00000000000..caeb1bc73e6 --- /dev/null +++ b/test/f90_correct/src/submod05_b.f90 @@ -0,0 +1,58 @@ +! Copyright (c) 1990-2018, 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. + +! Second test of using with two procedures inside a submodule. +! + +MODULE m ! The ancestor module m + INTEGER :: res1 + INTEGER :: res2 + INTERFACE + MODULE SUBROUTINE sub1(arg1) ! Module procedure interface body for sub1 + INTEGER, intent(inout) :: arg1 + END SUBROUTINE + + MODULE SUBROUTINE sub2(arg2) ! Module procedure interface body for sub2 + INTEGER, intent(inout) :: arg2 + END SUBROUTINE + END INTERFACE +END MODULE + +SUBMODULE (m) n ! The descendant submodule n + CONTAINS ! Module subprogram part + MODULE SUBROUTINE sub1(arg1) ! Definition of sub1 by subroutine subprogram + INTEGER, intent(inout) :: arg1 + res1 = arg1 + 1 + END SUBROUTINE sub1 + + MODULE SUBROUTINE sub2(arg2) ! Definition of sub2 by separate module subprogram + INTEGER, intent(inout) :: arg2 + res2 = arg2 + 2 + END SUBROUTINE sub2 +END SUBMODULE + +program test + use m + implicit none + integer :: k + k = 99 + call sub1(k) + call sub2(k) + if (res1 .ne. 100 .OR. res2 .ne.101) then + print *,"FAIL" + else + print *, "PASS" + end if +end program test + diff --git a/test/f90_correct/src/submod06.f90 b/test/f90_correct/src/submod06.f90 new file mode 100644 index 00000000000..a39d7cf80b1 --- /dev/null +++ b/test/f90_correct/src/submod06.f90 @@ -0,0 +1,64 @@ +! Copyright (c) 1990-2018, 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. + +! Test with 3 levels of inheritance of submodules +! + +MODULE m + INTEGER :: res ! The ancestor module m + INTERFACE + MODULE SUBROUTINE sub1(arg1) ! Module procedure interface body for sub1 + INTEGER, intent(inout) :: arg1 + END SUBROUTINE + + MODULE SUBROUTINE sub2(arg2) ! Module procedure interface body for sub1 + INTEGER, intent(inout) :: arg2 + END SUBROUTINE + END INTERFACE +END MODULE + +SUBMODULE (m) n ! The descendant submodule n + CONTAINS ! Module subprogram part + MODULE SUBROUTINE sub1(arg1) ! Definition of sub1 by subroutine subprogram + INTEGER, intent(inout) :: arg1 + res = arg1 + 1 + END SUBROUTINE sub1 +END SUBMODULE + +SUBMODULE (m:n) k ! The descendant submodule k + CONTAINS ! Module subprogram part + MODULE SUBROUTINE sub2(arg2) ! Definition of sub1 by subroutine subprogram + INTEGER, intent(inout) :: arg2 + res = arg2 + 1 + END SUBROUTINE sub2 +END SUBMODULE + +program test +use m +implicit none + integer :: k, h + k = 99 + call sub1(k) + if (res .ne. 100) then + print *, "FAIL" + else + print *, "PASS" + end if + call sub2(k) + if (res .ne. 100) then + print *, "FAIL" + else + print *, "PASS" + end if +end program test diff --git a/test/f90_correct/src/submod12.f90 b/test/f90_correct/src/submod12.f90 new file mode 100644 index 00000000000..605a4694671 --- /dev/null +++ b/test/f90_correct/src/submod12.f90 @@ -0,0 +1,71 @@ +! Copyright (c) 1990-2018, 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. + + +! Test use-associated (same variable and function names)from two modules n and +! m. + +module m + integer, parameter :: i = -1 + interface + module subroutine show_i + end subroutine show_i + end interface +contains + integer function times_two (arg) + integer :: arg + times_two = -2*arg + end function +end module m + +module n + integer, parameter :: i = 2 +contains + integer function times_two (arg) + integer :: arg + times_two = 2*arg + end function +end module n + +submodule (m) sm + use n +contains + module subroutine show_i + if (i .ne. 2) then + print *, "FAIL" + else + print *, "PASS" + endif + if (times_two (i) .ne. 4) then + print *, "FAIL" + else + print *, "PASS" + endif + end subroutine show_i +end submodule sm + +program p + use m + call show_i + if (i .ne. -1) then + print *, "FAIL" + else + print *, "PASS" + endif + if (times_two (i) .ne. 2) then + print *, "FAIL" + else + print *, "PASS" + endif +end program diff --git a/test/f90_correct/src/submod20.f90 b/test/f90_correct/src/submod20.f90 new file mode 100644 index 00000000000..13c5cd5c43f --- /dev/null +++ b/test/f90_correct/src/submod20.f90 @@ -0,0 +1,66 @@ +! +! Copyright (c) 2018, 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. +! + +! C1413 (R1416) If a submodule-name appears in the end-submodule-stmt, it shall +! be identical to the one in the submodule-stmt. + +! C1412 (R1418) The ancestor-module-name shall be the name of a nonintrinsic +! module that declares a separate module procedure; the parent-submodule-name +! shall be the name of a descendant of that module. + +! C1411 (R1416) A submodule specification-part shall not contain a format-stmt + + +!C1412 ancestor-module is nonintrinsic, declares a module procedure +module ancestor + interface + module subroutine hello + end subroutine + module subroutine hello2 + end subroutine + end interface +end module ancestor + +! C1411 - submodule specification-part does not contain a format-stmt +! C1413 - test that matching submodule-name is accepted +submodule (ancestor) descendant + contains + module procedure hello +! print *, "hello world" + write(*,"(a)",advance="no")" PA" + end procedure +end submodule descendant + +! C1411 - submodule specification-part does not contain a format-stmt +! C1412 - parent-submodule-name (descendant) is a descendant of ancestor +! C1413 - test that end-submodule-stmt without submodule-name is accepted +submodule (ancestor:descendant) descendant2 + contains + module procedure hello2 + write(*,"(a)",advance="no") "SS " + print *, "" +! print *, "hello again, world" + end procedure +end submodule + + +program main + use ancestor + call hello + call hello2 +end program main + + diff --git a/test/f90_correct/src/submod21.f90 b/test/f90_correct/src/submod21.f90 new file mode 100644 index 00000000000..81d4d621ace --- /dev/null +++ b/test/f90_correct/src/submod21.f90 @@ -0,0 +1,82 @@ +! +! Copyright (c) 2018, 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. +! +! test weird naming, such as a submodule named "submodule" + +module module + integer :: x = 0; + interface + module subroutine tick + end subroutine + module subroutine tick2 + end subroutine + end interface +end module module + +submodule (module) submodule +contains + module procedure tick + x = x + 1 + end procedure tick +end submodule submodule + +submodule (module:submodule) module +contains + module procedure tick2 + call tick + call tick + end procedure tick2 +end submodule module + +module submodule + integer :: y = 0 + interface + module subroutine add2 + end subroutine + module subroutine add4 + end subroutine + end interface +end module submodule + +submodule (submodule) module +contains + module procedure add2 + y = y + 2 + end procedure add2 +end submodule + +submodule (submodule) submodule +contains + module procedure add4 + y = y + 4 + end procedure add4 +end submodule + + +program checkxy +use module +use submodule +call tick +call tick2 +call add2 +call add4 +print *, "x is ", x, " and y is ", y +if ( x .EQ. 3 .AND. y .EQ. 6) then + print *, " PASS " +else + print *, "TEST FAILED" +end if +end program checkxy + diff --git a/test/f90_correct/src/submod23.f90 b/test/f90_correct/src/submod23.f90 new file mode 100644 index 00000000000..3f4e016c6c2 --- /dev/null +++ b/test/f90_correct/src/submod23.f90 @@ -0,0 +1,66 @@ +! +! Copyright (c) 2018, 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. +! + +! C1412 (R1418) The ancestor-module-name shall be the name of a nonintrinsic +! module that declares a separate module procedure; the parent-submodule-name +! shall be the name of a descendant of that module. + +!C1412 ancestor-module is nonintrinsic, declares a module procedure +module ancestor + interface + module subroutine hello + end subroutine + module subroutine hello2 + end subroutine + end interface +end module ancestor + +module ancestor2 + interface + module subroutine hello + end subroutine + module subroutine hello2 + end subroutine + end interface +end module ancestor2 + +submodule (ancestor) descendant23a + contains + module procedure hello + print *, "hello world" + end procedure +end submodule descendant23a + +submodule (ancestor2) descendant23b + contains + module procedure hello + print *, "hello world" + end procedure +end submodule descendant23b + +! C1412 - negative - parent-submodule-name (descendant23b) is not a descendant of ancestor +submodule (ancestor:descendant23b) grand_descendant !{error "PGF90-F-0004-Unable to open MODULE file ancestor-descendant23b.mod"} + contains + module procedure hello2 + print *, "hello again, world" + end procedure +end submodule + +program main + use ancestor + call hello + call hello2 +end program main diff --git a/test/f90_correct/src/submod24.f90 b/test/f90_correct/src/submod24.f90 new file mode 100644 index 00000000000..89df504cc24 --- /dev/null +++ b/test/f90_correct/src/submod24.f90 @@ -0,0 +1,41 @@ +! +! Copyright (c) 2018, 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. +! + +! C1413 (R1416) If a submodule-name appears in the end-submodule-stmt, it shall +! be identical to the one in the submodule-stmt. +module ancestor + interface + module subroutine hello + end subroutine + end interface +end module ancestor + +! C1413 - negative - submodule-name in the end-submodule-stmt does not match +! the name in the submodule-stmt. (compilation failure must report this) +submodule (ancestor) descendant + contains + module procedure hello + print *, "hello world" + end procedure +end submodule ancestor !{error "PGF90-S-0309-Incorrect name, ancestor, specified in END statement"} + + +program main + use ancestor + call hello +end program main + + diff --git a/test/f90_correct/src/submod27.f90 b/test/f90_correct/src/submod27.f90 new file mode 100644 index 00000000000..9f140d3f165 --- /dev/null +++ b/test/f90_correct/src/submod27.f90 @@ -0,0 +1,55 @@ +! +! Copyright (c) 2018, 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. +! + +! C1411 submodule specification-part must not contain format-stmt + +module prettyprint + double precision A, B, C + interface + module subroutine niceprint(e,f,g) + double precision, intent(in) :: e,f,g + end subroutine niceprint + end interface + contains + +end module prettyprint + +submodule (prettyprint) niceprint + 400 FORMAT('|','|',3(F8.3,'|'),'|') !{error "PGF90-S-0310-Illegal statement in the specification part of a MODULE"} +contains + module procedure niceprint + ! 400 FORMAT('|','|',3(F8.3,'|'),'|') + 500 FORMAT(6H PASS ) + write(*,400)e,f,g + write(*,500) + end procedure +end submodule niceprint + +program foo +use prettyprint +200 FORMAT(' ',3F7.2) +300 FORMAT('|',3(F8.3,'|')) + A = 3.141592 + B = -11.2 + C = 12.34567E-02 +write(*,200)A,B,C +write(*,300)A,B,C +write(*,300)B,C,A +write(*,300)C,A,B +call niceprint(A,B,C) + +end program foo + diff --git a/test/f90_correct/src/submod28.f90 b/test/f90_correct/src/submod28.f90 new file mode 100644 index 00000000000..ad993cac83a --- /dev/null +++ b/test/f90_correct/src/submod28.f90 @@ -0,0 +1,58 @@ +! +! Copyright (c) 2018, 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. +! + +! related to C1411 submodule specification-part must not contain format-stmt +! however, specification-part of a module procedure in a submodule may contain a +! format-stmt + +module prettyprint + double precision A, B, C + interface + module subroutine niceprint(e,f,g) + double precision, intent(in) :: e,f,g + end subroutine niceprint + end interface + contains + +end module prettyprint + +submodule (prettyprint) niceprint +! 400 FORMAT('|','|',3(F8.3,'|'),'|') +contains + module procedure niceprint + 400 FORMAT('|','|',3(F8.3,'|'),'|') + 500 FORMAT(6H PASS ) + write(*,400)e,f,g + write(*,500) + + end procedure +end submodule niceprint + +program foo +use prettyprint +200 FORMAT(' ',3F7.2) +300 FORMAT('|',3(F8.3,'|')) + A = 3.141592 + B = -11.2 + C = 12.34567E-02 +write(*,200)A,B,C +write(*,300)A,B,C +write(*,300)B,C,A +write(*,300)C,A,B +call niceprint(A,B,C) + +end program foo + diff --git a/test/f90_correct/src/submod29.f90 b/test/f90_correct/src/submod29.f90 new file mode 100644 index 00000000000..70aa9379627 --- /dev/null +++ b/test/f90_correct/src/submod29.f90 @@ -0,0 +1,50 @@ +! +! Copyright (c) 2018, 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. +! +module foo_submod29 +integer, allocatable :: arr +interface + module subroutine check_alloc + end subroutine + module subroutine check_not_alloc + end subroutine +end interface +end module + +submodule (foo_submod29) bar +contains + module procedure check_alloc + if ( allocated(arr) ) then + print *, " PASS " + else + print *, "FAIL" + endif + end procedure + module procedure check_not_alloc + if ( .not. allocated(arr) ) then + print *, "PASS" + else + print *, "FAIL" + endif + end procedure +end submodule + +program foobar +use foo_submod29 +implicit none +call check_not_alloc +allocate (arr) +call check_alloc +end program foobar diff --git a/test/f90_correct/src/submod32.f90 b/test/f90_correct/src/submod32.f90 new file mode 100644 index 00000000000..a6d03f10cbb --- /dev/null +++ b/test/f90_correct/src/submod32.f90 @@ -0,0 +1,52 @@ +! +! Copyright (c) 2018, 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. +! +module mod_submod32 +integer a, b, m +interface + module subroutine check_arr(arr) + integer, intent(in) :: arr(:) + end subroutine +end interface +end module mod_submod32 + + +submodule (mod_submod32) submod_submod32 +contains + module procedure check_arr + a = lbound(arr, DIM=1) + b = size(arr) + m = maxval(arr) + end procedure +end submodule submod_submod32 + +program prog + use mod_submod32 + integer x(7:15) + x(7:15) = 0 + x(9:10) = 1 + x(15) = 10 + print *, "lbound: ", lbound(x) + print *, "kind: ", kind(x) + print *, "maxval: ", maxval(x) + call check_arr(x) + if ( a .EQ. lbound(x, DIM=1) .AND. b .EQ. size(x) .AND. maxval(x) .EQ. m) then + print *, " PASS " + else + print *, "FAILED: lbound of arr in submod is ", a, " and lbound of x is ", lbound(x, DIM=1) + print *, "FAILED: size of arr in submod is ", b, " and size of x is ", size(x) + print *, "FAILED: maxval of arr in submod is", m, " and maxval of x is", maxval(x) + end if +end program prog diff --git a/test/f90_correct/src/submod33.f90 b/test/f90_correct/src/submod33.f90 new file mode 100644 index 00000000000..696892598f0 --- /dev/null +++ b/test/f90_correct/src/submod33.f90 @@ -0,0 +1,73 @@ +! +! Copyright (c) 2018, 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. +! +! Length of assumed-length CHARACTER function results (B.3.6) + +module mod_set_foo_submod33 + Character*8,external :: FOO + Character*26 :: BAR +interface +module subroutine call_foo +end subroutine +end interface +end module + +submodule (mod_set_foo_submod33) submod_set_foo_submod33 + character*3 :: abc +interface + module subroutine check_abc + end subroutine +end interface +contains + module procedure call_foo + print *, FOO(BAR) + end procedure + module procedure check_abc + if (LEN(abc) .EQ. 3 ) then + print *, "length of abc: " + print *, " PASS " + else + print *, "FAIL, length of abc is wrong" + endif + end procedure +end submodule + +program do_foo + use mod_set_foo_submod33 + implicit none + BAR = 'abcdefghijklmnopqrstuvwxyz' + call call_foo + if ( LEN(BAR) .EQ. 26 ) then + print *, "length of bar " + print *, " PASS " + else + print *, "FAIL, length of BAR is wrong" + end if + + if ( LEN(FOO(BAR)) .EQ. 8 ) then + print *, "length of foo" + print *, " PASS " + else + print *, "FAIL, length of FOO is wrong" + end if + call check_abc +end program do_foo + + Character*(*) FUNCTION FOO(STR) + CHARACTER*26 STR + FOO = STR + RETURN + END function + diff --git a/test/f90_correct/src/submod34.f90 b/test/f90_correct/src/submod34.f90 new file mode 100644 index 00000000000..1a6b8ea49d2 --- /dev/null +++ b/test/f90_correct/src/submod34.f90 @@ -0,0 +1,65 @@ +! +! Copyright (c) 2018, 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. +! + +! This test checks for proper handling of module name conflicts +! aliasing can be used to prevent name conflicts (x from mod2 called x2) +! name conflicts are ignored if not referenced (y from mod and mod2) +! ONLY can be used to avoid including conflicting names (z from mod) +module mod_submod34 + integer x, y, z +interface + module subroutine set_z(foo) + integer, intent (in) :: foo + end subroutine +end interface +end module mod_submod34 + +module mod2_submod34 + integer, x, y, z, a, b, c +end module mod2_submod34 + +submodule (mod_submod34) submod_submod34 + integer a, b, c +contains + module procedure set_z + c = foo + z = 2 * c +! print *, "c is ", c, " and z is ", z + end procedure set_z +end submodule submod_submod34 + +program prog + use mod_submod34, ONLY : x, y, set_z + use mod2_submod34, x2 => x + implicit none + a = 1 + b = 2 + c = a + b + z = 2 * c + x = 4 + x2 = 42 + call set_z(5) + if ( z .EQ. 6 ) then + print *, " PASS " + else + print *, "FAILED. z should be 6, is ", z + end if + if (x2 .GT. x ) then + print *, "PASSED" + else + print *, "TEST FAILED. x2 (", x2, ") should be greater than x (", x, ")" + end if +end program prog diff --git a/test/f90_correct/src/submod35.f90 b/test/f90_correct/src/submod35.f90 new file mode 100644 index 00000000000..8eb7d992503 --- /dev/null +++ b/test/f90_correct/src/submod35.f90 @@ -0,0 +1,119 @@ +! +! Copyright (c) 2018, 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. +! +module first_submod35 +character (len = 10) :: word +integer :: arr(2:7, 3:18) +integer :: arr2(4:17) +interface + module subroutine printWord2 + end subroutine + module subroutine printWord3 + end subroutine + module subroutine printWord4 + end subroutine + module subroutine printWord5 + end subroutine +end interface +contains + subroutine printWord1 + print *, word; + end subroutine +end module first_submod35 + +submodule (first_submod35) second_submod35 +character (len = 10) word2 +contains + module procedure printWord2 + call set + print *, word, word2 + print *, "shape of arr is ", shape(arr) + end procedure + subroutine set + word2 = "second" + end subroutine +end submodule second_submod35 + +submodule (first_submod35:second_submod35) third_submod35 +character (len = 10) word3 +contains + module procedure printWord3 + call set + print *, word, word2, word3 + print *, "lbounds of arr are: ", lbound(arr) + end procedure + subroutine set + word3 = "third" + end subroutine + +end submodule third_submod35 + +submodule (first_submod35:third_submod35) fourth_submod35 +character (len = 10) word4 +contains + module procedure printWord4 + call set + print *, word, word2, word3, word4 + print *, "ubounds of arr are: ", ubound(arr) + ! check the upper bounds of arr in the fourth submodule + if ( .NOT. ((ubound(arr, dim=1) .EQ. 7) .AND. (ubound(arr, dim=2) .EQ. 18) )) then + print *, "TEST FAILED upper bounds incorrect" + end if + end procedure + subroutine set + word4 = "fourth" + end subroutine + +end submodule fourth_submod35 + +submodule (first_submod35:fourth_submod35) fifth_submod35 +character (len = 10) word5 +contains + module procedure printWord5 + call set + print *, word, word2, word3, word4, word5 + print *, "shape of result of shape of arr is: ", shape(shape(arr)) + if ( (word .EQ. "first") .AND. (word2 .EQ. "second") .AND. (word3 .EQ. "third") .AND. (word4 .EQ. "fourth") .AND. (word5 .EQ. "fifth") ) then + print *, " PASS" + else + print *, "TEST FAILED submodule host association not working" + end if + ! check the upper bounds of arr in the fifth submodule + if ( .NOT. ((ubound(arr, dim=1) .EQ. 7) .AND. (ubound(arr, dim=2) .EQ. 18) )) then + print *, "TEST FAILED upper bounds incorrect" + end if + + end procedure + subroutine set + word5 = "fifth" + end subroutine +end submodule fifth_submod35 + +program dothis +use first_submod35 +implicit none +word = 'first' + +call printWord1 +call printWord2 +call printWord3 +call printWord4 +call printWord5 + ! check the upper bounds of arr in the main program + if ( .NOT. ((ubound(arr, dim=1) .EQ. 7) .AND. (ubound(arr, dim=2) .EQ. 18) )) then + print *, "TEST FAILED upper bounds incorrect" + end if + +end program dothis diff --git a/test/f90_correct/src/submod39.f90 b/test/f90_correct/src/submod39.f90 new file mode 100644 index 00000000000..0fb8e8c441e --- /dev/null +++ b/test/f90_correct/src/submod39.f90 @@ -0,0 +1,30 @@ +! Copyright (c) 2018, 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. +! + +! C1547 (R1526) MODULE shall appear only in the function-stmt or subroutine-stmt +! of a module subprogram or of a nonabstract interface body that is declared in +! the scoping unit of a module or submodule. + +MODULE mod_test + IMPLICIT NONE + +ABSTRACT INTERFACE + + PURE INTEGER MODULE FUNCTION f1(i) !{error "PGF90-S-1055-MODULE prefix cannot be inside an abstract interface"} + INTEGER, INTENT(IN) :: i + END FUNCTION f1 +END INTERFACE + +END module mod_test diff --git a/test/f90_correct/src/submod40.f90 b/test/f90_correct/src/submod40.f90 new file mode 100644 index 00000000000..158444a1cfd --- /dev/null +++ b/test/f90_correct/src/submod40.f90 @@ -0,0 +1,70 @@ +! Copyright (c) 2018, 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. +! + +! C1548 (R1526) If MODULE appears in the prefix of a module subprogram, it shall +! have been declared to be a separate module procedure in the containing program +! unit or an ancestor of that program unit. +! + +MODULE mod_test + IMPLICIT NONE + + INTERFACE + + PURE INTEGER MODULE FUNCTION f1(i) + INTEGER, INTENT(IN) :: i + END FUNCTION f1 + + PURE MODULE subroutine s1(i) + INTEGER, INTENT(IN) :: i + END subroutine s1 + + MODULE SUBROUTINE sub1(arg1) + INTEGER, intent(inout) :: arg1 + END SUBROUTINE + + MODULE SUBROUTINE sub2(arg2) + INTEGER, intent(inout) :: arg2 + END SUBROUTINE + + END INTERFACE + +END MODULE + +SUBMODULE(mod_test) sub_mod + IMPLICIT NONE + + CONTAINS + + PURE INTEGER MODULE FUNCTION f2(i) !{error "PGF90-S-1056-MODULE prefix is only allowed for subprograms that were declared as separate module procedures"} + INTEGER, INTENT(IN) :: i + f2 = i + END FUNCTION f2 + + PURE MODULE subroutine s1(i) + INTEGER, INTENT(IN) :: i + END subroutine s1 + + MODULE PROCEDURE sub1 + arg1 = arg1 + 1 + END PROCEDURE sub1 + + MODULE PROCEDURE sub3 !{error "PGF90-S-1056-MODULE prefix is only allowed for subprograms that were declared as separate module procedures"} + + END PROCEDURE sub3 + + +END SUBMODULE sub_mod + diff --git a/test/f90_correct/src/submod41.f90 b/test/f90_correct/src/submod41.f90 new file mode 100644 index 00000000000..3cd4f97f781 --- /dev/null +++ b/test/f90_correct/src/submod41.f90 @@ -0,0 +1,29 @@ +! Copyright (c) 2018, 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. +! + +! C1547 (R1526) MODULE shall appear only in the function-stmt or subroutine-stmt +! of a module subprogram or of a nonabstract interface body that is declared in +! the scoping unit of a module or submodule. + +PROGRAM test + IMPLICIT NONE + +INTERFACE + PURE INTEGER MODULE FUNCTION f1(i) !{error "PGF90-S-0310-MODULE prefix allowed only within a module or submodule"} + INTEGER, INTENT(IN) :: i + END FUNCTION f1 +END INTERFACE + +END PROGRAM test diff --git a/tools/flang1/flang1exe/dtypeutl.c b/tools/flang1/flang1exe/dtypeutl.c index 74fc6a1fbac..c4d38d642fb 100644 --- a/tools/flang1/flang1exe/dtypeutl.c +++ b/tools/flang1/flang1exe/dtypeutl.c @@ -573,7 +573,13 @@ size_ast(int sptr, DTYPE dtype) if (dtype == DT_ASSCHAR || dtype == DT_DEFERCHAR || dtype == DT_ASSNCHAR || dtype == DT_DEFERNCHAR ) { - clen = ast_intr(I_LEN, astb.bnd.dtype, 1, mk_id(sptr)); + if (dtype == DT_ASSCHAR || dtype == DT_DEFERCHAR + || dtype == DT_ASSNCHAR || dtype == DT_DEFERNCHAR + ) { + clen = ast_intr(I_LEN, astb.bnd.dtype, 1, mk_id(sptr)); + } else { + clen = DTY(dtype+1); + } } else if (ADJLENG(sptr) && !F90POINTERG(sptr)) { /* don't add CVLEN for local automatic character */ clen = CVLENG(sptr); @@ -2387,6 +2393,86 @@ getast(int ast, char *string) } /* switch */ } /* getast */ +/** \brief Check if ast is deferred-length character */ +bool +is_deferlenchar_ast(int ast) +{ + DTYPE dt; + SPTR sym = 0; + + dt = DDTG(A_DTYPEG(ast)); + if (DTY(dt) != TY_CHAR && DTY(dt) != TY_NCHAR) { + return false; + } + + if (dt == DT_ASSCHAR || dt == DT_ASSNCHAR) { + return false; + } else if (dt == DT_DEFERCHAR || dt == DT_DEFERNCHAR) { + return true; + } + + if (ast_is_sym(ast)) { + sym = memsym_of_ast(ast); + } + + /* adjustable length character */ + if ((sym > NOSYM) && ADJLENG(sym)) { + return false; + } + + if (DTY(A_DTYPEG(ast)) == TY_ARRAY) { + if (ADD_DEFER(A_DTYPEG(ast))) { + dt = DTY(DDTG(A_DTYPEG(ast)) + 1); + if (A_TYPEG(dt) != A_CNST) { + return true; + } + } + } + return false; +} + +/** \brief Check if dtype is deferred-length character */ +bool +is_deferlenchar_dtype(DTYPE dtype) +{ + DTYPE dt; + + dt = DDTG(dtype); + if (DTY(dt) != TY_CHAR && DTY(dt) != TY_NCHAR) { + return false; + } + + if (dt == DT_DEFERCHAR || dt == DT_DEFERNCHAR) { + return true; + } + dt = DTY(dt+1); + if (DTY(dtype) == TY_ARRAY) { + if (!ADD_DEFER(dtype)) { + return false; + } + } + + if (A_TYPEG(dt) == A_ID) { + /* i.e. character(len=newlen) */ + if (ASSNG(A_SPTRG(dt))) { + return true; + } + } else if (A_TYPEG(dt) == A_SUBSCR) { + /* i.e. character(len=newlen(1)) */ + if (ASSNG(memsym_of_ast(dt))) { + return true; + } + } + + /* i.e. character(len=len(a)) */ + if ((A_TYPEG(dt) == A_FUNC || A_TYPEG(dt) == A_INTR) + && is_deferlenchar_ast(ARGT_ARG(A_ARGSG(dt), 0))) { + return true; + } + return false; +} + + /** \brief Put into the character array pointed to by ptr, the print representation of dtype. diff --git a/tools/flang1/flang1exe/dtypeutl.h b/tools/flang1/flang1exe/dtypeutl.h index cdf9eb6ab0c..4a381973091 100644 --- a/tools/flang1/flang1exe/dtypeutl.h +++ b/tools/flang1/flang1exe/dtypeutl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2016-2018, 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. @@ -111,3 +111,5 @@ SPTR get_struct_members(DTYPE dtype); SPTR get_struct_initialization_tree(DTYPE dtype); LOGICAL is_unresolved_parameterized_dtype(DTYPE dtype); DTYPE change_assumed_char_to_deferred(DTYPE); +bool is_deferlenchar_ast(int); +bool is_deferlenchar_dtype(DTYPE); diff --git a/tools/flang1/flang1exe/lowerexp.c b/tools/flang1/flang1exe/lowerexp.c index 1ae8785c014..48d6e1844c1 100644 --- a/tools/flang1/flang1exe/lowerexp.c +++ b/tools/flang1/flang1exe/lowerexp.c @@ -3023,7 +3023,7 @@ f90_value_function_I2(char *name, int dtype, int args, int nargs) int ast = ARGT_ARG(args, i); ilm = lower_ilm(ast); if (i == 1) { - ilm = lower_conv_ilm(ast, ilm, DT_INT, A_NDTYPEG(ast)); + ilm = lower_conv_ilm(ast, ilm, A_NDTYPEG(ast), DT_INT); } ilm = plower("oi", "DPVAL", ilm); intrinsic_args[i] = ilm; diff --git a/tools/flang1/flang1exe/lowersym.c b/tools/flang1/flang1exe/lowersym.c index 93a3361ddf7..f680668e5e0 100644 --- a/tools/flang1/flang1exe/lowersym.c +++ b/tools/flang1/flang1exe/lowersym.c @@ -101,6 +101,12 @@ static void lower_fileinfo_llvm(); static LOGICAL llvm_iface_flag = FALSE; static void stb_lower_sym_header(); +/** \brief + * ASSCHAR = -1 assumed size character + * ADJCHAR = -2 backend maps to DT_ASSCHAR + * DEFERCHAR = -3 deferred-length character */ +enum LEN {ASSCHAR = -1, ADJCHAR = -2, DEFERCHAR = -3}; + /** \brief Returns true if the procedure (sptr) has optional arguments. */ static bool @@ -2433,7 +2439,7 @@ eval_con_expr(int ast, int *val, int *dtyp) static void lower_put_datatype(int dtype, int usage) { - int ndim, i, sptr, zbase, numelm; + int ndim, i, zbase, numelm; int dty, iface; /* if this was a 'stashed' old datatype */ if (DTY(dtype) < 0) @@ -2586,9 +2592,9 @@ lower_put_datatype(int dtype, int usage) case TY_CHAR: putwhich("character", "c"); if (dtype == DT_ASSCHAR) { - putval("len", -1); + putval("len", ASSCHAR); } else if (dtype == DT_DEFERCHAR) { - putval("len", -3); + putval("len", DEFERCHAR); } else { int clen = DTY(dtype + 1); if (A_ALIASG(clen)) { @@ -2597,16 +2603,20 @@ lower_put_datatype(int dtype, int usage) clen = CONVAL2G(clen); putval("len", clen); } else { - putval("len", -2 /* which backend maps to DT_ASSCHAR */); + if (sem.gcvlen && is_deferlenchar_dtype(dtype)) { + putval("len", DEFERCHAR); + } else { + putval("len", ADJCHAR); + } } } break; case TY_NCHAR: putwhich("kcharacter", "k"); if (dtype == DT_ASSNCHAR) { - putval("len", -1); + putval("len", ASSCHAR); } else if (dtype == DT_DEFERNCHAR) { - putval("len", -3); + putval("len", DEFERCHAR); } else { int clen = DTY(dtype + 1); if (A_ALIASG(clen)) { @@ -2615,7 +2625,7 @@ lower_put_datatype(int dtype, int usage) clen = CONVAL2G(clen); putval("len", clen); } else { - putval("len", -1); + putval("len", ASSCHAR); } } break; diff --git a/tools/flang1/flang1exe/semutil2.c b/tools/flang1/flang1exe/semutil2.c index ed88aba7bc5..6c428f29f4f 100644 --- a/tools/flang1/flang1exe/semutil2.c +++ b/tools/flang1/flang1exe/semutil2.c @@ -751,19 +751,6 @@ add_p_dealloc_item(int sptr) sem.p_dealloc = itemp; } -/** \brief Given an allocatable array and an explicit shape list which has been - deposited in the semant 'bounds' structure, generate assignments to - the arrays bounds temporaries, and allocate the array. Save the id - ast - of the array for an ensuing deallocate of the array. - */ -void -gen_allocate_array(int arr) -{ - int alloc_obj = gen_defer_shape(arr, 0, arr); - (void)gen_alloc_dealloc(TK_ALLOCATE, alloc_obj, 0); - add_p_dealloc_item(arr); -} /** \brief Generate deallocates for the temporary arrays in the sem.p_delloc * list. @@ -1011,7 +998,6 @@ typedef struct { } _ACS; static _ACS acs; - static LOGICAL _can_fold(int); static void constructf90(int, ACL *); static void _dinit_acl(ACL *, LOGICAL); @@ -1033,6 +1019,24 @@ iexpr_op(int op) return "?N?"; } +/** \brief Given an allocatable array and an explicit shape list which has been + deposited in the semant 'bounds' structure, generate assignments to + the arrays bounds temporaries, and allocate the array. Save the id + ast + of the array for an ensuing deallocate of the array. + */ +void +gen_allocate_array(int arr) +{ + int alloc_obj = gen_defer_shape(arr, 0, arr); + if (is_deferlenchar_dtype(acs.arrtype)) { + get_static_descriptor(arr); + get_all_descriptors(arr); + } + gen_alloc_dealloc(TK_ALLOCATE, alloc_obj, 0); + add_p_dealloc_item(arr); +} + #if DEBUG static void _printacl(int in_array, ACL *aclp, FILE *f) @@ -1491,6 +1495,9 @@ chk_constructor(ACL *aclp, DTYPE dtype) sem.arrdim.ndefer = 1; acs.is_const = FALSE; } + if (sem.gcvlen && is_deferlenchar_dtype(acs.eltype)) { + sem.arrdim.ndefer = 1; + } aclp->size = sem.bounds[0].upast; acs.arrtype = mk_arrdsc(); @@ -1669,6 +1676,7 @@ init_sptr_w_acl(int in_sptr, ACL *aclp) if (sem.arrdim.ndefer) { ALLOCATE_ARRAYS = 0; /* allocate for these array temps is done here */ } + sptr = acs.tmp = get_arr_temp(acs.arrtype, FALSE, FALSE, FALSE); ALLOCATE_ARRAYS = 1; if (sem.arrdim.ndefer) { @@ -1767,13 +1775,17 @@ compute_size_ast(bool add_flag, ACL *aclp, DTYPE dtype) static DTYPE compute_size_expr(bool add_flag, ACL *aclp, DTYPE dtype) { + DTYPE dt2, dtype2; SST *stkp = aclp->u1.stkp; LOGICAL specified_dtype = dtype != 0; - DTYPE dt = dtype; + DTYPE dt = DDTG(dtype); + dtype2 = SST_DTYPEG(stkp); + dt2 = DDTG(SST_DTYPEG(stkp)); if (!specified_dtype) { - dtype = SST_DTYPEG(stkp); - dt = DDTG(dtype); + dtype = dtype2; + dt = dt2; } + if (acs.eltype == 0 || acs.zln) { int id = SST_IDG(stkp); if (acs.eltype != 0) { @@ -1786,15 +1798,21 @@ compute_size_expr(bool add_flag, ACL *aclp, DTYPE dtype) || dtype == DT_ASSNCHAR || dtype == DT_DEFERNCHAR ) { dt = adjust_ch_length(dt, SST_ASTG(stkp)); + } else if (dt == DT_ASSCHAR || dt == DT_DEFERCHAR + || dt == DT_ASSNCHAR || dt == DT_DEFERNCHAR + ) { + dt = fix_dtype(SST_SYMG(stkp), dt); } } /* need to change the type for the first element too */ if (specified_dtype && acs.eltype == 0 && add_flag) { /* if we're in a struct, don't do */ if (DTY(dt) == TY_CHAR && DTY(dtype) == TY_CHAR) - ; + if (dtype2 != DT_DEFERCHAR && dtype2 != DT_DEFERNCHAR) + dtype = SST_DTYPEG(stkp); else if (DTY(dt) == TY_NCHAR && DTY(dtype) == TY_NCHAR) - ; + if (dtype2 != DT_DEFERCHAR && dtype2 != DT_DEFERNCHAR) + dtype = SST_DTYPEG(stkp); else if (DTY(dtype) == TY_ARRAY) { if (DDTG(dtype) != dt) { errsev(95); @@ -1818,10 +1836,12 @@ compute_size_expr(bool add_flag, ACL *aclp, DTYPE dtype) * causes S_CONST to become S_EXPR. */ if (add_flag) { /* if we're in a struct, don't do */ - if (DTY(acs.eltype) == TY_CHAR && DTY(dtype) == TY_CHAR) - ; - else if (DTY(acs.eltype) == TY_NCHAR && DTY(dtype) == TY_NCHAR) - ; + if (DTY(dt) == TY_CHAR && DTY(dtype) == TY_CHAR) + if (dtype2 != DT_DEFERCHAR && dtype2 != DT_DEFERNCHAR) + dtype = SST_DTYPEG(stkp); + else if (DTY(dt) == TY_NCHAR && DTY(dtype) == TY_NCHAR) + if (dtype2 != DT_DEFERCHAR && dtype2 != DT_DEFERNCHAR) + dtype = SST_DTYPEG(stkp); else if (DTY(dtype) == TY_ARRAY) { if (!eq_dtype(DDTG(dtype), acs.eltype)) { errsev(95); @@ -2328,6 +2348,9 @@ get_shape_arraydtype(int shape, int eltype) } } + if (is_deferlenchar_dtype(acs.arrtype)) + sem.arrdim.ndefer = 1; + arrtype = mk_arrdsc(); DTY(arrtype + 1) = eltype; return arrtype; @@ -2364,7 +2387,11 @@ mkexpr_assign_temp(SST *stkptr) /* if we have an array expression, we need to assign it to a temporary so that we can subscript it. */ if (DTY(dtype = SST_DTYPEG(stkptr)) == TY_ARRAY && !simple) { - dtype = get_shape_arraydtype(A_SHAPEG(ast), DTY(dtype + 1)); + if (is_deferlenchar_ast(ast)) { + dtype = get_shape_arraydtype(A_SHAPEG(ast), DTY(acs.arrtype + 1)); + } else { + dtype = get_shape_arraydtype(A_SHAPEG(ast), DTY(dtype + 1)); + } id = get_arr_temp(dtype, FALSE, FALSE, FALSE); if (sem.arrdim.ndefer) gen_allocate_array(id); @@ -7605,13 +7632,15 @@ get_ch_temp(DTYPE dtype) } while (dt != dtype); if (needalloc) { + int clen; ALLOCP(sptr, 1); /* if the length is not a constant, make it 'adjustable' */ - if (A_ALIASG(len) == 0) { + if (sem.gcvlen && is_deferlenchar_dtype(dtype)) { + clen = ast_intr(I_LEN, astb.bnd.dtype, 1, mk_id(sptr)); + } else if (A_ALIASG(len) == 0) { /* fill in CVLEN field */ ADJLENP(sptr, 1); if (CVLENG(sptr) == 0) { - int clen; clen = sym_get_scalar(SYMNAME(sptr), "len", astb.bnd.dtype); CVLENP(sptr, clen); } @@ -7626,7 +7655,8 @@ get_ch_temp(DTYPE dtype) if (ADD_LWBD(dtype, d) == 0) ADD_LWBD(dtype, d) = astb.bnd.one; } - allocate_temp(sptr); + if (!ADD_DEFER(DTYPEG(sptr)) || ADJLENG(sptr)) + allocate_temp(sptr); } } else { allocate_temp(sptr); @@ -11408,8 +11438,7 @@ gen_alloc_dealloc(int stmtyp, int object, ITEM *spec) /* This is for allocate statement, must set length before allocate * sem.gcvlen supposedly gets set only when it is character */ - if ((DDTG(A_DTYPEG(object)) == DT_DEFERCHAR || - DDTG(A_DTYPEG(object)) == DT_DEFERCHAR) && + if (is_deferlenchar_ast(object) && stmtyp == TK_ALLOCATE) { if (sem.gcvlen) { len_stmt = diff --git a/tools/flang1/flang1exe/transfrm.c b/tools/flang1/flang1exe/transfrm.c index 1c408137d45..dd8690f5a16 100644 --- a/tools/flang1/flang1exe/transfrm.c +++ b/tools/flang1/flang1exe/transfrm.c @@ -3426,8 +3426,13 @@ gen_bounds_assignments(int astdestparent, int astdestmem, int astsrcparent, } if (DDTG(A_DTYPEG(A_DESTG(STD_AST(std)))) == DT_DEFERCHAR) { int lhs_len = get_len_of_deferchar_ast(A_DESTG(STD_AST(std))); - int rhs_len = string_expr_length(A_SRCG(STD_AST(std))); - int ast = mk_assn_stmt(lhs_len, rhs_len, DT_INT); + int rhs_len, ast; + if (is_deferlenchar_ast(A_SRCG(STD_AST(std)))) { + rhs_len = get_len_of_deferchar_ast(A_SRCG(STD_AST(std))); + } else { + rhs_len = string_expr_length(A_SRCG(STD_AST(std))); + } + ast = mk_assn_stmt(lhs_len, rhs_len, DT_INT); add_stmt_before(ast, std); } } else { @@ -4255,9 +4260,14 @@ rewrite_allocatable_assignment(int astasgn, const int std, LOGICAL non_conformab if (DDTG(dtypedest) == DT_DEFERCHAR || DDTG(dtypedest) == DT_DEFERNCHAR) { /* Add length check for deferred char to the IF expr as well */ int lhs_len = size_ast_of(astdest, DDTG(dtypedest)); - int rhs_len = string_expr_length(astsrc); - int binopast = mk_binop(OP_NE, lhs_len, rhs_len, DT_LOG); - int ifexpr = mk_binop(OP_LOR, binopast, A_IFEXPRG(astif), DT_LOG); + int rhs_len, binopast, ifexpr; + if (is_deferlenchar_ast(astsrc)) { + rhs_len = get_len_of_deferchar_ast(astsrc); + } else { + rhs_len = string_expr_length(astsrc); + } + binopast = mk_binop(OP_NE, lhs_len, rhs_len, DT_LOG); + ifexpr = mk_binop(OP_LOR, binopast, A_IFEXPRG(astif), DT_LOG); A_IFEXPRP(astif, ifexpr); } }