Skip to content

Commit

Permalink
[flang] Import preprocessing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
klausler committed Oct 4, 2019
1 parent c56e082 commit d6c8bd8
Show file tree
Hide file tree
Showing 74 changed files with 1,973 additions and 0 deletions.
23 changes: 23 additions & 0 deletions flang/test/preprocessing/pp001.F
@@ -0,0 +1,23 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.

* keyword macros
integer, parameter :: KWM = 666
#define KWM 777
if (KWM .eq. 777) then
print *, 'pp001.F pass'
else
print *, 'pp001.F FAIL: ', KWM
end if
end
24 changes: 24 additions & 0 deletions flang/test/preprocessing/pp002.F
@@ -0,0 +1,24 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.

* #undef
integer, parameter :: KWM = 777
#define KWM 666
#undef KWM
if (KWM .eq. 777) then
print *, 'pp002.F pass'
else
print *, 'pp002.F FAIL: ', KWM
end if
end
29 changes: 29 additions & 0 deletions flang/test/preprocessing/pp003.F
@@ -0,0 +1,29 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.

* function-like macros
integer function IFLM(x)
integer :: x
IFLM = x
end function IFLM
program main
#define IFLM(x) ((x)+111)
integer :: res
res = IFLM(666)
if (res .eq. 777) then
print *, 'pp003.F pass'
else
print *, 'pp003.F FAIL: ', res
end if
end
23 changes: 23 additions & 0 deletions flang/test/preprocessing/pp004.F
@@ -0,0 +1,23 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.

* KWMs case-sensitive
integer, parameter :: KWM = 777
#define KWM 666
if (kwm .eq. 777) then
print *, 'pp004.F pass'
else
print *, 'pp004.F FAIL: ', kwm
end if
end
26 changes: 26 additions & 0 deletions flang/test/preprocessing/pp005.F
@@ -0,0 +1,26 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.

* KWM split across continuation, implicit padding
integer, parameter :: KWM = 666
#define KWM 777
integer :: res
res = KW
+M
if (res .eq. 777) then
print *, 'pp005.F pass'
else
print *, 'pp005.F FAIL: ', res
end if
end
27 changes: 27 additions & 0 deletions flang/test/preprocessing/pp006.F
@@ -0,0 +1,27 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.

* ditto, but with intervening *comment line
integer, parameter :: KWM = 666
#define KWM 777
integer :: res
res = KW
*comment
+M
if (res .eq. 777) then
print *, 'pp006.F pass'
else
print *, 'pp006.F FAIL: ', res
end if
end
29 changes: 29 additions & 0 deletions flang/test/preprocessing/pp007.F
@@ -0,0 +1,29 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.

* KWM split across continuation, clipped after column 72
integer, parameter :: KWM = 666
#define KWM 777
integer :: res
* 'comment' is in column 73
* 1 2 3 4 5 6 7
*234567890123456789012345678901234567890123456789012345678901234567890123
res = KW comment
+M
if (res .eq. 777) then
print *, 'pp007.F pass'
else
print *, 'pp007.F FAIL: ', res
end if
end
25 changes: 25 additions & 0 deletions flang/test/preprocessing/pp008.F
@@ -0,0 +1,25 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.

* KWM with spaces in name at invocation NOT replaced
integer, parameter :: KWM = 777
#define KWM 666
integer :: res
res = K W M
if (res .eq. 777) then
print *, 'pp008.F pass'
else
print *, 'pp008.F FAIL: ', res
end if
end
30 changes: 30 additions & 0 deletions flang/test/preprocessing/pp009.F
@@ -0,0 +1,30 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.

* FLM call split across continuation, implicit padding
integer function IFLM(x)
integer :: x
IFLM = x
end function IFLM
program main
#define IFLM(x) ((x)+111)
integer :: res
res = IFL
+M(666)
if (res .eq. 777) then
print *, 'pp009.F pass'
else
print *, 'pp009.F FAIL: ', res
end if
end
31 changes: 31 additions & 0 deletions flang/test/preprocessing/pp010.F
@@ -0,0 +1,31 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.

* ditto, but with intervening *comment line
integer function IFLM(x)
integer :: x
IFLM = x
end function IFLM
program main
#define IFLM(x) ((x)+111)
integer :: res
res = IFL
*comment
+M(666)
if (res .eq. 777) then
print *, 'pp010.F pass'
else
print *, 'pp010.F FAIL: ', res
end if
end
33 changes: 33 additions & 0 deletions flang/test/preprocessing/pp011.F
@@ -0,0 +1,33 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.

* FLM call name split across continuation, clipped
integer function IFLM(x)
integer :: x
IFLM = x
end function IFLM
program main
#define IFLM(x) ((x)+111)
integer :: res
* 'comment' is in column 73
* 1 2 3 4 5 6 7
*234567890123456789012345678901234567890123456789012345678901234567890123
res = IFL comment
+M(666)
if (res .eq. 777) then
print *, 'pp011.F pass'
else
print *, 'pp011.F FAIL: ', res
end if
end
30 changes: 30 additions & 0 deletions flang/test/preprocessing/pp012.F
@@ -0,0 +1,30 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.

* FLM call name split across continuation
integer function IFLM(x)
integer :: x
IFLM = x
end function IFLM
program main
#define IFLM(x) ((x)+111)
integer :: res
res = IFL
+M(666)
if (res .eq. 777) then
print *, 'pp012.F pass'
else
print *, 'pp012.F FAIL: ', res
end if
end
30 changes: 30 additions & 0 deletions flang/test/preprocessing/pp013.F
@@ -0,0 +1,30 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.

* FLM call split between name and (
integer function IFLM(x)
integer :: x
IFLM = x
end function IFLM
program main
#define IFLM(x) ((x)+111)
integer :: res
res = IFLM
+(666)
if (res .eq. 777) then
print *, 'pp013.F pass'
else
print *, 'pp013.F FAIL: ', res
end if
end

0 comments on commit d6c8bd8

Please sign in to comment.