summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseOpenMP.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2019-10-08 15:56:43 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2019-10-08 15:56:43 +0000
commit5d154c3e7d9dcd8f651ac6b34ee21aa553c82c74 (patch)
treee36f867dfd19147ec36f175575c39616bb383a99 /clang/lib/Parse/ParseOpenMP.cpp
parent6d7fb29914e3dd9e7f7d7524c5f98367a1aa613a (diff)
downloadbcm5719-llvm-5d154c3e7d9dcd8f651ac6b34ee21aa553c82c74.tar.gz
bcm5719-llvm-5d154c3e7d9dcd8f651ac6b34ee21aa553c82c74.zip
[OPENMP50]Prohibit multiple context selector sets in context selectors.
According to OpenMP 5.0, 2.3.2 Context Selectors, Restrictions, each trait-set-selector-name can only be specified once. Added check to implement this restriction. llvm-svn: 374072
Diffstat (limited to 'clang/lib/Parse/ParseOpenMP.cpp')
-rw-r--r--clang/lib/Parse/ParseOpenMP.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 998fae657a4..e487e0ab652 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -892,6 +892,7 @@ bool Parser::parseOpenMPContextSelectors(
llvm::function_ref<void(SourceRange,
const Sema::OpenMPDeclareVariantCtsSelectorData &)>
Callback) {
+ llvm::StringMap<SourceLocation> UsedCtxSets;
do {
// Parse inner context selector set name.
if (!Tok.is(tok::identifier)) {
@@ -901,6 +902,16 @@ bool Parser::parseOpenMPContextSelectors(
}
SmallString<16> Buffer;
StringRef CtxSelectorSetName = PP.getSpelling(Tok, Buffer);
+ auto Res = UsedCtxSets.try_emplace(CtxSelectorSetName, Tok.getLocation());
+ if (!Res.second) {
+ // OpenMP 5.0, 2.3.2 Context Selectors, Restrictions.
+ // Each trait-set-selector-name can only be specified once.
+ Diag(Tok.getLocation(), diag::err_omp_declare_variant_ctx_set_mutiple_use)
+ << CtxSelectorSetName;
+ Diag(Res.first->getValue(),
+ diag::note_omp_declare_variant_ctx_set_used_here)
+ << CtxSelectorSetName;
+ }
// Parse '='.
(void)ConsumeToken();
if (Tok.isNot(tok::equal)) {
OpenPOWER on IntegriCloud