diff options
author | peter klausler <pklausler@nvidia.com> | 2021-04-14 10:57:53 -0700 |
---|---|---|
committer | peter klausler <pklausler@nvidia.com> | 2021-04-14 11:33:31 -0700 |
commit | cfc12a2120fc84fd240a8a8c426e18f695bccde0 (patch) | |
tree | 16d16e877f2706fd7635efa0a7a7ceb758e42199 /flang/lib/Semantics | |
parent | [clang][FileManager] Support empty file name in getVirtualFileRef for seriali... (diff) | |
download | llvm-project-cfc12a2120fc84fd240a8a8c426e18f695bccde0.tar.gz llvm-project-cfc12a2120fc84fd240a8a8c426e18f695bccde0.tar.bz2 llvm-project-cfc12a2120fc84fd240a8a8c426e18f695bccde0.zip |
[flang] Correct the interpretation of BIND(C,NAME='')
An empty NAME= should mean that there is no C binding, not the
binding that would result from BIND(C) without a NAME=.
See 18.10.2p2.
Differential Revision: https://reviews.llvm.org/D100494
Diffstat (limited to 'flang/lib/Semantics')
-rw-r--r-- | flang/lib/Semantics/resolve-names.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp index a62b7c36fe61..0aca2cddb953 100644 --- a/flang/lib/Semantics/resolve-names.cpp +++ b/flang/lib/Semantics/resolve-names.cpp @@ -235,7 +235,7 @@ public: Attrs GetAttrs(); Attrs EndAttrs(); bool SetPassNameOn(Symbol &); - bool SetBindNameOn(Symbol &); + void SetBindNameOn(Symbol &); void Post(const parser::LanguageBindingSpec &); bool Pre(const parser::IntentSpec &); bool Pre(const parser::Pass &); @@ -1529,28 +1529,26 @@ bool AttrsVisitor::SetPassNameOn(Symbol &symbol) { return true; } -bool AttrsVisitor::SetBindNameOn(Symbol &symbol) { +void AttrsVisitor::SetBindNameOn(Symbol &symbol) { if (!attrs_ || !attrs_->test(Attr::BIND_C)) { - return false; + return; } std::optional<std::string> label{evaluate::GetScalarConstantValue< evaluate::Type<TypeCategory::Character, 1>>(bindName_)}; // 18.9.2(2): discard leading and trailing blanks, ignore if all blank if (label) { auto first{label->find_first_not_of(" ")}; - auto last{label->find_last_not_of(" ")}; if (first == std::string::npos) { + // Empty NAME= means no binding at all (18.10.2p2) Say(currStmtSource().value(), "Blank binding label ignored"_en_US); - label.reset(); - } else { - label = label->substr(first, last - first + 1); + return; } - } - if (!label) { + auto last{label->find_last_not_of(" ")}; + label = label->substr(first, last - first + 1); + } else { label = parser::ToLowerCaseLetters(symbol.name().ToString()); } symbol.SetBindName(std::move(*label)); - return true; } void AttrsVisitor::Post(const parser::LanguageBindingSpec &x) { |