[PATCH] D84969: [flang] Fix an assert on duplicate initializations
Pete Steinfeld via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 30 12:58:59 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfac84536bcb9: [flang] Fix an assert on duplicate initializations (authored by PeteSteinfeld).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84969/new/
https://reviews.llvm.org/D84969
Files:
flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/resolve91.f90
Index: flang/test/Semantics/resolve91.f90
===================================================================
--- flang/test/Semantics/resolve91.f90
+++ flang/test/Semantics/resolve91.f90
@@ -63,3 +63,14 @@
!ERROR: Derived type 'ubound' not found
integer :: ivar = ubound(iarray)(1)
end module m7
+
+module m8
+ integer :: iVar = 3
+ !ERROR: The type of 'ivar' has already been declared
+ integer :: iVar = 4
+ integer, target :: jVar = 5
+ integer, target :: kVar = 5
+ integer, pointer :: pVar => jVar
+ !ERROR: The type of 'pvar' has already been declared
+ integer, pointer :: pVar => kVar
+end module m8
Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -5680,22 +5680,25 @@
const parser::ConstantExpr &expr, bool inComponentDecl) {
if (name.symbol) {
Symbol &ultimate{name.symbol->GetUltimate()};
- if (IsPointer(ultimate)) {
- Say(name, "'%s' is a pointer but is not initialized like one"_err_en_US);
- } else if (auto *details{ultimate.detailsIf<ObjectEntityDetails>()}) {
- CHECK(!details->init());
- Walk(expr);
- // TODO: check C762 - all bounds and type parameters of component
- // are colons or constant expressions if component is initialized
- if (inComponentDecl) {
- // Can't convert to type of component, which might not yet
- // be known; that's done later during instantiation.
- if (MaybeExpr value{EvaluateExpr(expr)}) {
- details->set_init(std::move(*value));
+ if (!context().HasError(ultimate)) {
+ if (IsPointer(ultimate)) {
+ Say(name,
+ "'%s' is a pointer but is not initialized like one"_err_en_US);
+ } else if (auto *details{ultimate.detailsIf<ObjectEntityDetails>()}) {
+ CHECK(!details->init());
+ Walk(expr);
+ // TODO: check C762 - all bounds and type parameters of component
+ // are colons or constant expressions if component is initialized
+ if (inComponentDecl) {
+ // Can't convert to type of component, which might not yet
+ // be known; that's done later during instantiation.
+ if (MaybeExpr value{EvaluateExpr(expr)}) {
+ details->set_init(std::move(*value));
+ }
+ } else if (MaybeExpr folded{EvaluateConvertedExpr(
+ ultimate, expr, expr.thing.value().source)}) {
+ details->set_init(std::move(*folded));
}
- } else if (MaybeExpr folded{EvaluateConvertedExpr(
- ultimate, expr, expr.thing.value().source)}) {
- details->set_init(std::move(*folded));
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84969.282028.patch
Type: text/x-patch
Size: 2755 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200730/666a227a/attachment.bin>
More information about the llvm-commits
mailing list