summaryrefslogtreecommitdiff
path: root/flang/test/Lower/constant-literal-mangling.f90
diff options
context:
space:
mode:
Diffstat (limited to 'flang/test/Lower/constant-literal-mangling.f90')
-rw-r--r--flang/test/Lower/constant-literal-mangling.f9079
1 files changed, 66 insertions, 13 deletions
diff --git a/flang/test/Lower/constant-literal-mangling.f90 b/flang/test/Lower/constant-literal-mangling.f90
index abb2754bc2f9..ef33ffe450b0 100644
--- a/flang/test/Lower/constant-literal-mangling.f90
+++ b/flang/test/Lower/constant-literal-mangling.f90
@@ -5,36 +5,89 @@ type someType
integer :: i
end type
+type otherType
+ integer :: i
+end type
+
print *, [42, 42]
-! CHECK: fir.address_of(@_QQro.2xi4.53fa91e04725d4ee6f22cf1e2d38428a)
+! CHECK: fir.address_of(@_QQro.2xi4.0)
print *, reshape([42, 42, 42, 42, 42, 42], [2,3])
-! CHECK: fir.address_of(@_QQro.2x3xi4.9af8c8182bab45c4e7888ec3623db3b6)
+! CHECK: fir.address_of(@_QQro.2x3xi4.1)
print *, [42_8, 42_8]
-! CHECK: fir.address_of(@_QQro.2xi8.3b1356831516d19b976038974b2673ac)
+! CHECK: fir.address_of(@_QQro.2xi8.2)
print *, [0.42, 0.42]
-! CHECK: fir.address_of(@_QQro.2xr4.3c5becae2e4426ad1615e253139ceff8)
+! CHECK: fir.address_of(@_QQro.2xr4.3)
print *, [0.42_8, 0.42_8]
-! CHECK: fir.address_of(@_QQro.2xr8.ebefec8f7537fbf54acc4530e75084e6)
+! CHECK: fir.address_of(@_QQro.2xr8.4)
print *, [.true.]
-! CHECK: fir.address_of(@_QQro.1xl4.4352d88a78aa39750bf70cd6f27bcaa5)
+! CHECK: fir.address_of(@_QQro.1xl4.5)
print *, [.true._8]
-! CHECK: fir.address_of(@_QQro.1xl8.33cdeccccebe80329f1fdbee7f5874cb)
+! CHECK: fir.address_of(@_QQro.1xl8.6)
print *, [(1., -1.), (-1., 1)]
-! CHECK: fir.address_of(@_QQro.2xz4.ac09ecb1abceb4f9cad4b1a50000074e)
+! CHECK: fir.address_of(@_QQro.2xz4.7)
print *, [(1._8, -1._8), (-1._8, 1._8)]
-! CHECK: fir.address_of(@_QQro.2xz8.a3652db37055e37d2cae8198ae4cd959)
+! CHECK: fir.address_of(@_QQro.2xz8.8)
print *, [someType(42), someType(43)]
-! CHECK: fir.address_of(@_QQro.2x_QFTsometype.
-! Note: the hash for derived types cannot clash with other constant in the same
-! compilation unit, but is unstable because it hashes some noise contained in
-! unused std::vector storage.
+! CHECK: fir.address_of(@_QQro.2x_QFTsometype.9
+
+ ! Verify that literals of the same type/shape
+ ! are mapped to different global objects:
+ print *, [someType(11)]
+! CHECK: fir.address_of(@_QQro.1x_QFTsometype.10)
+ print *, [someType(42)]
+! CHECK: fir.address_of(@_QQro.1x_QFTsometype.11)
+ print *, [someType(11)]
+! CHECK: fir.address_of(@_QQro.1x_QFTsometype.10)
+ print *, [someType(42)]
+! CHECK: fir.address_of(@_QQro.1x_QFTsometype.11)
+ print *, [someType(11)]
+! CHECK: fir.address_of(@_QQro.1x_QFTsometype.10)
+ print *, [someType(42)]
+! CHECK: fir.address_of(@_QQro.1x_QFTsometype.11)
+ print *, [someType(11)]
+! CHECK: fir.address_of(@_QQro.1x_QFTsometype.10)
+ print *, [someType(42)]
+! CHECK: fir.address_of(@_QQro.1x_QFTsometype.11)
+
+ print *, [Character(4)::]
+! CHECK: fir.address_of(@_QQro.0x4xc1.null.12)
+ print *, [Character(2)::]
+! CHECK: fir.address_of(@_QQro.0x2xc1.null.13)
+ print *, [Character(2)::]
+! CHECK: fir.address_of(@_QQro.0x2xc1.null.13)
+
+ print *, [otherType(42)]
+! CHECK: fir.address_of(@_QQro.1x_QFTothertype.14)
+
end
+
+! CHECK: fir.global internal @_QQro.1x_QFTsometype.10 constant : !fir.array<1x!fir.type<_QFTsometype{i:i32}>> {
+! CHECK: %{{.*}} = arith.constant 11 : i32
+! CHECK: }
+
+! CHECK: fir.global internal @_QQro.1x_QFTsometype.11 constant : !fir.array<1x!fir.type<_QFTsometype{i:i32}>> {
+! CHECK: %{{.*}} = arith.constant 42 : i32
+! CHECK: }
+
+! CHECK: fir.global internal @_QQro.0x4xc1.null.12 constant : !fir.array<0x!fir.char<1,4>> {
+! CHECK: %[[T1:.*]] = fir.undefined !fir.array<0x!fir.char<1,4>>
+! CHECK: fir.has_value %[[T1]] : !fir.array<0x!fir.char<1,4>>
+! CHECK: }
+
+! CHECK: fir.global internal @_QQro.0x2xc1.null.13 constant : !fir.array<0x!fir.char<1,2>> {
+! CHECK: %[[T2:.*]] = fir.undefined !fir.array<0x!fir.char<1,2>>
+! CHECK: fir.has_value %[[T2]] : !fir.array<0x!fir.char<1,2>>
+! CHECK: }
+
+! CHECK: fir.global internal @_QQro.1x_QFTothertype.14 constant : !fir.array<1x!fir.type<_QFTothertype{i:i32}>> {
+! CHECK: %{{.*}} = arith.constant 42 : i32
+! CHECK: }