[PATCH] D83491: [flang] Fix a crash when creating generics from a copy
Pete Steinfeld via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 9 15:50:58 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG85d9745c83a1: [flang] Fix a crash when creating generics from a copy (authored by PeteSteinfeld).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83491/new/
https://reviews.llvm.org/D83491
Files:
flang/include/flang/Semantics/symbol.h
flang/lib/Semantics/symbol.cpp
flang/test/Semantics/resolve53.f90
Index: flang/test/Semantics/resolve53.f90
===================================================================
--- flang/test/Semantics/resolve53.f90
+++ flang/test/Semantics/resolve53.f90
@@ -457,3 +457,26 @@
integer :: i, j
end
end
+
+module m20
+ interface operator(.not.)
+ real function f(x)
+ character(*),intent(in) :: x
+ end function
+ end interface
+ interface operator(+)
+ procedure f
+ end interface
+end module
+
+subroutine s1()
+ use m20
+ interface operator(.not.)
+ !ERROR: Procedure 'f' is already specified in generic 'operator(.not.)'
+ procedure f
+ end interface
+ interface operator(+)
+ !ERROR: Procedure 'f' is already specified in generic 'operator(+)'
+ procedure f
+ end interface
+end subroutine s1
Index: flang/lib/Semantics/symbol.cpp
===================================================================
--- flang/lib/Semantics/symbol.cpp
+++ flang/lib/Semantics/symbol.cpp
@@ -150,9 +150,6 @@
return *this;
}
-GenericDetails::GenericDetails(const SymbolVector &specificProcs)
- : specificProcs_{specificProcs} {}
-
void GenericDetails::AddSpecificProc(
const Symbol &proc, SourceName bindingName) {
specificProcs_.push_back(proc);
@@ -186,6 +183,8 @@
}
void GenericDetails::CopyFrom(const GenericDetails &from) {
+ CHECK(specificProcs_.size() == bindingNames_.size());
+ CHECK(from.specificProcs_.size() == from.bindingNames_.size());
if (from.specific_) {
CHECK(!specific_ || specific_ == from.specific_);
specific_ = from.specific_;
@@ -194,11 +193,13 @@
CHECK(!derivedType_ || derivedType_ == from.derivedType_);
derivedType_ = from.derivedType_;
}
- for (const Symbol &symbol : from.specificProcs_) {
+ for (std::size_t i{0}; i < from.specificProcs_.size(); ++i) {
if (std::find_if(specificProcs_.begin(), specificProcs_.end(),
- [&](const Symbol &mySymbol) { return &mySymbol == &symbol; }) ==
- specificProcs_.end()) {
- specificProcs_.push_back(symbol);
+ [&](const Symbol &mySymbol) {
+ return &mySymbol == &*from.specificProcs_[i];
+ }) == specificProcs_.end()) {
+ specificProcs_.push_back(from.specificProcs_[i]);
+ bindingNames_.push_back(from.bindingNames_[i]);
}
}
}
Index: flang/include/flang/Semantics/symbol.h
===================================================================
--- flang/include/flang/Semantics/symbol.h
+++ flang/include/flang/Semantics/symbol.h
@@ -423,7 +423,6 @@
class GenericDetails {
public:
GenericDetails() {}
- GenericDetails(const SymbolVector &specificProcs);
GenericKind kind() const { return kind_; }
void set_kind(GenericKind kind) { kind_ = kind; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83491.276859.patch
Type: text/x-patch
Size: 2721 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200709/34616a96/attachment.bin>
More information about the llvm-commits
mailing list