[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.

llvm-svn: 247706
This commit is contained in:
Alexey Bataev 2015-09-15 17:23:56 +00:00
parent 454faa84e2
commit ecb156aba2
8 changed files with 20 additions and 14 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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();
}

View File

@ -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;

View File

@ -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);

View File

@ -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);