summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2015-09-15 17:23:56 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2015-09-15 17:23:56 +0000
commit235bfa8c7d430e772f29b476113e34ccd8cd18e4 (patch)
tree124fd9198b1c777a3cbb9977f3b18872674b4e86
parent1693eda79d412eac81b97288892a7328792cf404 (diff)
[OPENMP] Emit an additional note during analysis of 'if' clause.
Patch adds emission of additional note for 'if' clauses with name modifiers in case if 'if' clause without name modified was specified or 'if' clause with the same name modifier was specified. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247706 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaOpenMP.cpp8
-rw-r--r--test/OpenMP/parallel_for_if_messages.cpp4
-rw-r--r--test/OpenMP/parallel_for_simd_if_messages.cpp4
-rw-r--r--test/OpenMP/parallel_if_messages.cpp4
-rw-r--r--test/OpenMP/parallel_sections_if_messages.cpp4
-rw-r--r--test/OpenMP/target_data_if_messages.cpp2
-rw-r--r--test/OpenMP/target_if_messages.cpp4
-rw-r--r--test/OpenMP/task_if_messages.cpp4
8 files changed, 20 insertions, 14 deletions
diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp
index cf7ce23866..22170f3dde 100644
--- a/lib/Sema/SemaOpenMP.cpp
+++ b/lib/Sema/SemaOpenMP.cpp
@@ -2015,6 +2015,7 @@ static bool checkIfClauses(Sema &S, OpenMPDirectiveKind Kind,
unsigned NamedModifiersNumber = 0;
SmallVector<const OMPIfClause *, OMPC_unknown + 1> FoundNameModifiers(
OMPD_unknown + 1);
+ SmallVector<SourceLocation, 4> NameModifierLoc;
for (const auto *C : Clauses) {
if (const auto *IC = dyn_cast_or_null<OMPIfClause>(C)) {
// At most one if clause without a directive-name-modifier can appear on
@@ -2025,8 +2026,10 @@ static bool checkIfClauses(Sema &S, OpenMPDirectiveKind Kind,
<< getOpenMPDirectiveName(Kind) << getOpenMPClauseName(OMPC_if)
<< (CurNM != OMPD_unknown) << getOpenMPDirectiveName(CurNM);
ErrorFound = true;
- } else if (CurNM != OMPD_unknown)
+ } else if (CurNM != OMPD_unknown) {
+ NameModifierLoc.push_back(IC->getNameModifierLoc());
++NamedModifiersNumber;
+ }
FoundNameModifiers[CurNM] = IC;
if (CurNM == OMPD_unknown)
continue;
@@ -2079,6 +2082,9 @@ static bool checkIfClauses(Sema &S, OpenMPDirectiveKind Kind,
diag::err_omp_unnamed_if_clause)
<< (TotalAllowedNum > 1) << Values;
}
+ for (auto Loc : NameModifierLoc) {
+ S.Diag(Loc, diag::note_omp_previous_named_if_clause);
+ }
ErrorFound = true;
}
return ErrorFound;
diff --git a/test/OpenMP/parallel_for_if_messages.cpp b/test/OpenMP/parallel_for_if_messages.cpp
index 555f3713b5..2b7a5f7e2b 100644
--- a/test/OpenMP/parallel_for_if_messages.cpp
+++ b/test/OpenMP/parallel_for_if_messages.cpp
@@ -46,7 +46,7 @@ int tmain(T argc, S **argv) {
for (i = 0; i < argc; ++i) foo();
#pragma omp parallel for if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp parallel for' cannot contain more than one 'if' clause with 'parallel' name modifier}}
for (i = 0; i < argc; ++i) foo();
- #pragma omp parallel for if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}}
+ #pragma omp parallel for if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
for (i = 0; i < argc; ++i) foo();
return 0;
@@ -90,7 +90,7 @@ int main(int argc, char **argv) {
for (i = 0; i < argc; ++i) foo();
#pragma omp parallel for if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp parallel for' cannot contain more than one 'if' clause with 'parallel' name modifier}}
for (i = 0; i < argc; ++i) foo();
- #pragma omp parallel for if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}}
+ #pragma omp parallel for if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
for (i = 0; i < argc; ++i) foo();
return tmain(argc, argv);
diff --git a/test/OpenMP/parallel_for_simd_if_messages.cpp b/test/OpenMP/parallel_for_simd_if_messages.cpp
index 7662d0f5e7..829b825aaf 100644
--- a/test/OpenMP/parallel_for_simd_if_messages.cpp
+++ b/test/OpenMP/parallel_for_simd_if_messages.cpp
@@ -46,7 +46,7 @@ int tmain(T argc, S **argv) {
for (i = 0; i < argc; ++i) foo();
#pragma omp parallel for simd if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'if' clause with 'parallel' name modifier}}
for (i = 0; i < argc; ++i) foo();
- #pragma omp parallel for simd if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}}
+ #pragma omp parallel for simd if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
for (i = 0; i < argc; ++i) foo();
return 0;
@@ -90,7 +90,7 @@ int main(int argc, char **argv) {
for (i = 0; i < argc; ++i) foo();
#pragma omp parallel for simd if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'if' clause with 'parallel' name modifier}}
for (i = 0; i < argc; ++i) foo();
- #pragma omp parallel for simd if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}}
+ #pragma omp parallel for simd if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
for (i = 0; i < argc; ++i) foo();
return tmain(argc, argv);
diff --git a/test/OpenMP/parallel_if_messages.cpp b/test/OpenMP/parallel_if_messages.cpp
index bba2861e64..1ffc567b59 100644
--- a/test/OpenMP/parallel_if_messages.cpp
+++ b/test/OpenMP/parallel_if_messages.cpp
@@ -28,7 +28,7 @@ int tmain(T argc, S **argv) {
#pragma omp parallel if(parallel : argc)
#pragma omp parallel if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp parallel'}}
#pragma omp parallel if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp parallel' cannot contain more than one 'if' clause with 'parallel' name modifier}}
- #pragma omp parallel if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}}
+ #pragma omp parallel if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
foo();
return 0;
@@ -53,7 +53,7 @@ int main(int argc, char **argv) {
#pragma omp parallel if(parallel : argc)
#pragma omp parallel if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp parallel'}}
#pragma omp parallel if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp parallel' cannot contain more than one 'if' clause with 'parallel' name modifier}}
- #pragma omp parallel if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}}
+ #pragma omp parallel if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
foo();
return tmain(argc, argv);
diff --git a/test/OpenMP/parallel_sections_if_messages.cpp b/test/OpenMP/parallel_sections_if_messages.cpp
index db4d0a1ec7..c2e3f5ec99 100644
--- a/test/OpenMP/parallel_sections_if_messages.cpp
+++ b/test/OpenMP/parallel_sections_if_messages.cpp
@@ -75,7 +75,7 @@ int tmain(T argc, S **argv) {
{
foo();
}
- #pragma omp parallel sections if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}}
+ #pragma omp parallel sections if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
{
foo();
}
@@ -152,7 +152,7 @@ int main(int argc, char **argv) {
{
foo();
}
- #pragma omp parallel sections if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}}
+ #pragma omp parallel sections if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
{
foo();
}
diff --git a/test/OpenMP/target_data_if_messages.cpp b/test/OpenMP/target_data_if_messages.cpp
index 38008dd30f..77edefa48b 100644
--- a/test/OpenMP/target_data_if_messages.cpp
+++ b/test/OpenMP/target_data_if_messages.cpp
@@ -25,7 +25,7 @@ int main(int argc, char **argv) {
#pragma omp target data if(target data : argc)
#pragma omp target data if(target data : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target data'}}
#pragma omp target data if(target data : argc) if (target data:argc) // expected-error {{directive '#pragma omp target data' cannot contain more than one 'if' clause with 'target data' name modifier}}
- #pragma omp target data if(target data : argc) if (argc) // expected-error {{no more 'if' clause is allowed}}
+ #pragma omp target data if(target data : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
foo();
return 0;
diff --git a/test/OpenMP/target_if_messages.cpp b/test/OpenMP/target_if_messages.cpp
index 58a9ba2af8..4ee7302282 100644
--- a/test/OpenMP/target_if_messages.cpp
+++ b/test/OpenMP/target_if_messages.cpp
@@ -27,7 +27,7 @@ int tmain(T argc, S **argv) {
#pragma omp target if(target : argc)
#pragma omp target if(target : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target'}}
#pragma omp target if(target : argc) if (target:argc) // expected-error {{directive '#pragma omp target' cannot contain more than one 'if' clause with 'target' name modifier}}
- #pragma omp target if(target : argc) if (argc) // expected-error {{no more 'if' clause is allowed}}
+ #pragma omp target if(target : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
foo();
return 0;
@@ -51,7 +51,7 @@ int main(int argc, char **argv) {
#pragma omp target if(target : argc)
#pragma omp target if(target : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target'}}
#pragma omp target if(target : argc) if (target:argc) // expected-error {{directive '#pragma omp target' cannot contain more than one 'if' clause with 'target' name modifier}}
- #pragma omp target if(target : argc) if (argc) // expected-error {{no more 'if' clause is allowed}}
+ #pragma omp target if(target : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
foo();
return tmain(argc, argv);
diff --git a/test/OpenMP/task_if_messages.cpp b/test/OpenMP/task_if_messages.cpp
index 029e4e1f1b..f3f56d5167 100644
--- a/test/OpenMP/task_if_messages.cpp
+++ b/test/OpenMP/task_if_messages.cpp
@@ -27,7 +27,7 @@ int tmain(T argc, S **argv) {
#pragma omp task if(task : argc)
#pragma omp task if(task : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp task'}}
#pragma omp task if(task : argc) if (task:argc) // expected-error {{directive '#pragma omp task' cannot contain more than one 'if' clause with 'task' name modifier}}
- #pragma omp task if(task : argc) if (argc) // expected-error {{no more 'if' clause is allowed}}
+ #pragma omp task if(task : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
foo();
return 0;
@@ -51,7 +51,7 @@ int main(int argc, char **argv) {
#pragma omp task if(task : argc)
#pragma omp task if(task : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp task'}}
#pragma omp task if(task : argc) if (task:argc) // expected-error {{directive '#pragma omp task' cannot contain more than one 'if' clause with 'task' name modifier}}
- #pragma omp task if(task : argc) if (argc) // expected-error {{no more 'if' clause is allowed}}
+ #pragma omp task if(task : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
foo();
return tmain(argc, argv);