[flang-commits] [flang] 8830f11 - [flang]Verify C7107, C7108, C7109 from - Clause 7 constraint checks for f18.
Sameeran joshi via flang-commits
flang-commits at lists.llvm.org
Fri Jul 31 11:15:36 PDT 2020
Author: sameeran joshi
Date: 2020-07-31T23:45:20+05:30
New Revision: 8830f1170dae898d7a0d6a95897e1c23e316ec1e
URL: https://github.com/llvm/llvm-project/commit/8830f1170dae898d7a0d6a95897e1c23e316ec1e
DIFF: https://github.com/llvm/llvm-project/commit/8830f1170dae898d7a0d6a95897e1c23e316ec1e.diff
LOG: [flang]Verify C7107, C7108, C7109 from - Clause 7 constraint checks for f18.
1. Annotate the sources with constraint numbers.
2. Add tests for
*C7107 (R765) digit shall have one of the values 0 or 1.
*C7108 (R766) digit shall have one of the values 0 through 7.
*C7109 (R764) A boz-literal-constant shall appear only as a data-stmt-constant in a DATA statement, or where explicitly allowed in 16.9 as an actual argument of an intrinsic procedure.
Reviewed By: PeteSteinfeld
Differential Revision: https://reviews.llvm.org/D84504
Added:
flang/test/Semantics/boz-literal-constants.f90
Modified:
flang/lib/Evaluate/intrinsics.cpp
flang/lib/Semantics/expression.cpp
Removed:
################################################################################
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index 35a69e4e9b93..ca9a91c98daf 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -1129,9 +1129,10 @@ std::optional<SpecificCall> IntrinsicInterface::Match(
d.rank == Rank::elementalOrBOZ) {
continue;
} else {
+ const IntrinsicDummyArgument &nextParam{dummy[j + 1]};
messages.Say(
- "Typeless (BOZ) not allowed for '%s=' argument"_err_en_US,
- d.keyword);
+ "Typeless (BOZ) not allowed for both '%s=' & '%s=' arguments"_err_en_US, // C7109
+ d.keyword, nextParam.keyword);
}
} else {
// NULL(), procedure, or procedure pointer
diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index 3ec2af5d70fa..0a6e448e98a2 100644
--- a/flang/lib/Semantics/expression.cpp
+++ b/flang/lib/Semantics/expression.cpp
@@ -633,7 +633,8 @@ MaybeExpr ExpressionAnalyzer::Analyze(const parser::BOZLiteralConstant &x) {
++p;
auto value{BOZLiteralConstant::Read(p, base, false /*unsigned*/)};
if (*p != '"') {
- Say("Invalid digit ('%c') in BOZ literal '%s'"_err_en_US, *p, x.v);
+ Say("Invalid digit ('%c') in BOZ literal '%s'"_err_en_US, *p,
+ x.v); // C7107, C7108
return std::nullopt;
}
if (value.overflow) {
diff --git a/flang/test/Semantics/boz-literal-constants.f90 b/flang/test/Semantics/boz-literal-constants.f90
new file mode 100644
index 000000000000..23155cc29cb7
--- /dev/null
+++ b/flang/test/Semantics/boz-literal-constants.f90
@@ -0,0 +1,79 @@
+! RUN: %S/test_errors.sh %s %t %f18
+! Confirm enforcement of constraints and restrictions in 7.7
+! C7107, C7108, C7109
+
+subroutine bozchecks
+ ! Type declaration statements
+ integer :: f, realpart = B"0101", img = B"1111", resint
+ logical :: resbit
+ complex :: rescmplx
+ real :: dbl, e
+ ! C7107
+ !ERROR: Invalid digit ('a') in BOZ literal 'b"110a"'
+ integer, parameter :: a = B"110A"
+ !ERROR: Invalid digit ('2') in BOZ literal 'b"1232"'
+ integer, parameter :: b = B"1232"
+ !ERROR: BOZ literal 'b"010101010101010101010101011111111111111111111111111111111111111111111111111111111111111111111111111111111111000000000000000000000000000000000000"' too large
+ integer, parameter :: b1 = B"010101010101010101010101011111111111111111111&
+ &111111111111111111111111111111111111111111111&
+ &111111111111111111000000000000000000000000000&
+ &000000000"
+ ! C7108
+ !ERROR: Invalid digit ('8') in BOZ literal 'o"8"'
+ integer :: c = O"8"
+ !ERROR: Invalid digit ('a') in BOZ literal 'o"a"'
+ integer :: d = O"A"
+
+ ! C7109
+ ! A) can appear only in data statement
+ ! B) Argument to intrinsics listed from 16.9 below
+ ! BGE, BGT, BLE, BLT, CMPLX, DBLE, DSHIFTL,
+ ! DSHIFTR, IAND, IEOR, INT, IOR, MERGE_BITS, REAL
+
+ ! part A
+ data f / Z"AA" / ! OK
+ !ERROR: DATA statement value could not be converted to the type 'COMPLEX(4)' of the object 'rescmplx'
+ data rescmplx / B"010101" /
+ ! part B
+ resbit = BGE(B"0101", B"1111")
+ resbit = BGT(Z"0101", B"1111")
+ resbit = BLE(B"0101", B"1111")
+ resbit = BLT(B"0101", B"1111")
+
+ res = CMPLX (realpart, img, 4)
+ res = CMPLX (B"0101", B"1111", 4)
+
+ dbl = DBLE(B"1111")
+ dbl = DBLE(realpart)
+
+ !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments
+ dbl = DSHIFTL(B"0101",B"0101",2)
+ !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments
+ dbl = DSHIFTR(B"1010",B"1010",2)
+ dbl = DSHIFTL(B"0101",5,2) ! OK
+ dbl = DSHIFTR(B"1010",5,2) ! OK
+
+ !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments
+ resint = IAND(B"0001", B"0011")
+ resint = IAND(B"0001", 3)
+
+ !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments
+ resint = IEOR(B"0001", B"0011")
+ resint = IEOR(B"0001", 3)
+
+ resint = INT(B"1010")
+
+ !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments
+ res = IOR(B"0101", B"0011")
+ res = IOR(B"0101", 3)
+
+ res = MERGE_BITS(13,3,11)
+ res = MERGE_BITS(B"1101",3,11)
+ !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments
+ res = MERGE_BITS(B"1101",B"0011",11)
+ !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments
+ res = MERGE_BITS(B"1101",B"0011",B"1011")
+ res = MERGE_BITS(B"1101",3,B"1011")
+
+ res = REAL(B"1101")
+end subroutine
More information about the flang-commits
mailing list