[PATCH] D60875: [OpenMP] Add checks for requires and target directives.
This revision was automatically updated to reflect the committed changes. Closed by commit rC358709: [OpenMP] Add checks for requires and target directives. (authored by gbercea, committed by ). Changed prior to commit: https://reviews.llvm.org/D60875?vs=195793&id=195803#toc Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D60875/new/ https://reviews.llvm.org/D60875 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaOpenMP.cpp test/OpenMP/requires_messages.cpp test/OpenMP/requires_target_messages.cpp Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -9132,6 +9132,10 @@ "Only one %0 clause can appear on a requires directive in a single translation unit">; def note_omp_requires_previous_clause : Note < "%0 clause previously used here">; +def err_omp_target_before_requires : Error < + "target region encountered before requires directive with '%0' clause">; +def note_omp_requires_encountered_target : Note < + "target previously encountered here">; def err_omp_invalid_scope : Error < "'#pragma omp %0' directive must appear only in file scope">; def note_omp_invalid_length_on_this_ptr_mapping : Note < Index: test/OpenMP/requires_target_messages.cpp === --- test/OpenMP/requires_target_messages.cpp +++ test/OpenMP/requires_target_messages.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s + +void foo2() { + int a; + #pragma omp target // expected-note 4 {{Target previously encountered here}} + { +a = a + 1; + } +} + +#pragma omp requires atomic_default_mem_order(seq_cst) +#pragma omp requires unified_address //expected-error {{Target region encountered before requires directive with 'unified_address' clause}} +#pragma omp requires unified_shared_memory //expected-error {{Target region encountered before requires directive with 'unified_shared_memory' clause}} +#pragma omp requires reverse_offload //expected-error {{Target region encountered before requires directive with 'reverse_offload' clause}} +#pragma omp requires dynamic_allocators //expected-error {{Target region encountered before requires directive with 'dynamic_allocators' clause}} Index: test/OpenMP/requires_messages.cpp === --- test/OpenMP/requires_messages.cpp +++ test/OpenMP/requires_messages.cpp @@ -7,7 +7,7 @@ #pragma omp requires unified_shared_memory, unified_shared_memory // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_shared_memory' clause}} -#pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} +#pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} #pragma omp requires unified_address, unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_address' clause}} @@ -29,13 +29,13 @@ #pragma omp requires atomic_default_mem_order( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} -#pragma omp requires atomic_default_mem_order(seq_cst // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} +#pragma omp requires atomic_default_mem_order(seq_cst // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} -#pragma omp requires atomic_default_mem_order(invalid_modifier) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} +#pragma omp requires atomic_default_mem_order(invalid_modifier) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} #pragma omp requires atomic_default_mem_order(shared) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause
[PATCH] D60875: [OpenMP] Add checks for requires and target directives.
ABataev accepted this revision. ABataev added a comment. This revision is now accepted and ready to land. LG Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D60875/new/ https://reviews.llvm.org/D60875 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D60875: [OpenMP] Add checks for requires and target directives.
gtbercea updated this revision to Diff 195793. gtbercea added a comment. - Lower case. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D60875/new/ https://reviews.llvm.org/D60875 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaOpenMP.cpp test/OpenMP/requires_messages.cpp test/OpenMP/requires_target_messages.cpp Index: test/OpenMP/requires_target_messages.cpp === --- /dev/null +++ test/OpenMP/requires_target_messages.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s + +void foo2() { + int a; + #pragma omp target // expected-note 4 {{Target previously encountered here}} + { +a = a + 1; + } +} + +#pragma omp requires atomic_default_mem_order(seq_cst) +#pragma omp requires unified_address //expected-error {{Target region encountered before requires directive with 'unified_address' clause}} +#pragma omp requires unified_shared_memory //expected-error {{Target region encountered before requires directive with 'unified_shared_memory' clause}} +#pragma omp requires reverse_offload //expected-error {{Target region encountered before requires directive with 'reverse_offload' clause}} +#pragma omp requires dynamic_allocators //expected-error {{Target region encountered before requires directive with 'dynamic_allocators' clause}} Index: test/OpenMP/requires_messages.cpp === --- test/OpenMP/requires_messages.cpp +++ test/OpenMP/requires_messages.cpp @@ -7,7 +7,7 @@ #pragma omp requires unified_shared_memory, unified_shared_memory // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_shared_memory' clause}} -#pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} +#pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} #pragma omp requires unified_address, unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_address' clause}} @@ -29,13 +29,13 @@ #pragma omp requires atomic_default_mem_order( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} -#pragma omp requires atomic_default_mem_order(seq_cst // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} +#pragma omp requires atomic_default_mem_order(seq_cst // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} -#pragma omp requires atomic_default_mem_order(invalid_modifier) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} +#pragma omp requires atomic_default_mem_order(invalid_modifier) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} #pragma omp requires atomic_default_mem_order(shared) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} -#pragma omp requires atomic_default_mem_order(acq_rel), atomic_default_mem_order(relaxed) // expected-error {{directive '#pragma omp requires' cannot contain more than one 'atomic_default_mem_order' claus}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} +#pragma omp requires atomic_default_mem_order(acq_rel), atomic_default_mem_order(relaxed) // expected-error {{directive '#pragma omp requires' cannot contain more than one 'atomic_default_mem_order' claus}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} #pragma omp requires // expected-error {{expected at least one clause on '#pragma omp requires' directive}} Index: lib/Sema/SemaOpenMP.cpp === --- lib/Sema/Se
[PATCH] D60875: [OpenMP] Add checks for requires and target directives.
ABataev added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9136 +def err_omp_target_before_requires : Error < + "Target region encountered before requires directive with '%0' clause">; +def note_omp_requires_encountered_target : Note < The messages must start from lower letter. Other messages must be fixed too in separate patches. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D60875/new/ https://reviews.llvm.org/D60875 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D60875: [OpenMP] Add checks for requires and target directives.
gtbercea updated this revision to Diff 195771. gtbercea added a comment. - Fix. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D60875/new/ https://reviews.llvm.org/D60875 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaOpenMP.cpp test/OpenMP/requires_messages.cpp test/OpenMP/requires_target_messages.cpp Index: test/OpenMP/requires_target_messages.cpp === --- /dev/null +++ test/OpenMP/requires_target_messages.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s + +void foo2() { + int a; + #pragma omp target // expected-note 4 {{Target previously encountered here}} + { +a = a + 1; + } +} + +#pragma omp requires atomic_default_mem_order(seq_cst) +#pragma omp requires unified_address //expected-error {{Target region encountered before requires directive with 'unified_address' clause}} +#pragma omp requires unified_shared_memory //expected-error {{Target region encountered before requires directive with 'unified_shared_memory' clause}} +#pragma omp requires reverse_offload //expected-error {{Target region encountered before requires directive with 'reverse_offload' clause}} +#pragma omp requires dynamic_allocators //expected-error {{Target region encountered before requires directive with 'dynamic_allocators' clause}} Index: test/OpenMP/requires_messages.cpp === --- test/OpenMP/requires_messages.cpp +++ test/OpenMP/requires_messages.cpp @@ -7,7 +7,7 @@ #pragma omp requires unified_shared_memory, unified_shared_memory // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_shared_memory' clause}} -#pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} +#pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} #pragma omp requires unified_address, unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_address' clause}} @@ -29,13 +29,13 @@ #pragma omp requires atomic_default_mem_order( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} -#pragma omp requires atomic_default_mem_order(seq_cst // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} +#pragma omp requires atomic_default_mem_order(seq_cst // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} -#pragma omp requires atomic_default_mem_order(invalid_modifier) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} +#pragma omp requires atomic_default_mem_order(invalid_modifier) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} #pragma omp requires atomic_default_mem_order(shared) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} -#pragma omp requires atomic_default_mem_order(acq_rel), atomic_default_mem_order(relaxed) // expected-error {{directive '#pragma omp requires' cannot contain more than one 'atomic_default_mem_order' claus}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} +#pragma omp requires atomic_default_mem_order(acq_rel), atomic_default_mem_order(relaxed) // expected-error {{directive '#pragma omp requires' cannot contain more than one 'atomic_default_mem_order' claus}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} #pragma omp requires // expected-error {{expected at least one clause on '#pragma omp requires' directive}} Index: lib/Sema/SemaOpenMP.cpp === --- lib/Sema/SemaOpenM
[PATCH] D60875: [OpenMP] Add checks for requires and target directives.
gtbercea updated this revision to Diff 195770. gtbercea marked an inline comment as done. gtbercea added a comment. - Fix. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D60875/new/ https://reviews.llvm.org/D60875 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaOpenMP.cpp test/OpenMP/requires_messages.cpp test/OpenMP/requires_target_messages.cpp Index: test/OpenMP/requires_target_messages.cpp === --- /dev/null +++ test/OpenMP/requires_target_messages.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s + +void foo2() { + int a; + #pragma omp target // expected-note {{Target previously encountered here}} expected-note {{Target previously encountered here}} expected-note {{Target previously encountered here}} expected-note {{Target previously encountered here}} + { +a = a + 1; + } +} + +#pragma omp requires atomic_default_mem_order(seq_cst) +#pragma omp requires unified_address //expected-error {{Target region encountered before requires directive with 'unified_address' clause}} +#pragma omp requires unified_shared_memory //expected-error {{Target region encountered before requires directive with 'unified_shared_memory' clause}} +#pragma omp requires reverse_offload //expected-error {{Target region encountered before requires directive with 'reverse_offload' clause}} +#pragma omp requires dynamic_allocators //expected-error {{Target region encountered before requires directive with 'dynamic_allocators' clause}} Index: test/OpenMP/requires_messages.cpp === --- test/OpenMP/requires_messages.cpp +++ test/OpenMP/requires_messages.cpp @@ -7,7 +7,7 @@ #pragma omp requires unified_shared_memory, unified_shared_memory // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_shared_memory' clause}} -#pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} +#pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} #pragma omp requires unified_address, unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_address' clause}} @@ -29,13 +29,13 @@ #pragma omp requires atomic_default_mem_order( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} -#pragma omp requires atomic_default_mem_order(seq_cst // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} +#pragma omp requires atomic_default_mem_order(seq_cst // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} -#pragma omp requires atomic_default_mem_order(invalid_modifier) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} +#pragma omp requires atomic_default_mem_order(invalid_modifier) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} #pragma omp requires atomic_default_mem_order(shared) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} -#pragma omp requires atomic_default_mem_order(acq_rel), atomic_default_mem_order(relaxed) // expected-error {{directive '#pragma omp requires' cannot contain more than one 'atomic_default_mem_order' claus}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} +#pragma omp requires atomic_default_mem_order(acq_rel), atomic_default_mem_order(relaxed) // expected-error {{directive '#pragma omp requires' cannot contain more than one 'atomic_default_mem_order' claus}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} #pragma omp requires // expecte
[PATCH] D60875: [OpenMP] Add checks for requires and target directives.
ABataev added inline comments. Comment at: lib/Sema/SemaOpenMP.cpp:4207 +DSAStack->hasRequiresDeclWithClause()) && + !CurContext->isDependentContext()) { +// Register target to DSA Stack. ABataev wrote: > Better to check for the dependent context at first, only after that check for > the clause Better to check for the dependent context at first, only after that check for the clause Comment at: test/OpenMP/requires_target_messages.cpp:5 + int a; + #pragma omp target // expected-note {{Target previously encountered here}} expected-note {{Target previously encountered here}} expected-note {{Target previously encountered here}} expected-note {{Target previously encountered here}} + { Just `expected-note 4 {{` Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D60875/new/ https://reviews.llvm.org/D60875 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D60875: [OpenMP] Add checks for requires and target directives.
gtbercea updated this revision to Diff 195768. gtbercea marked an inline comment as done. gtbercea added a comment. - Fix test. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D60875/new/ https://reviews.llvm.org/D60875 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaOpenMP.cpp test/OpenMP/requires_messages.cpp test/OpenMP/requires_target_messages.cpp Index: test/OpenMP/requires_target_messages.cpp === --- /dev/null +++ test/OpenMP/requires_target_messages.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s + +void foo2() { + int a; + #pragma omp target // expected-note {{Target previously encountered here}} expected-note {{Target previously encountered here}} expected-note {{Target previously encountered here}} expected-note {{Target previously encountered here}} + { +a = a + 1; + } +} + +#pragma omp requires atomic_default_mem_order(seq_cst) +#pragma omp requires unified_address //expected-error {{Target region encountered before requires directive with 'unified_address' clause}} +#pragma omp requires unified_shared_memory //expected-error {{Target region encountered before requires directive with 'unified_shared_memory' clause}} +#pragma omp requires reverse_offload //expected-error {{Target region encountered before requires directive with 'reverse_offload' clause}} +#pragma omp requires dynamic_allocators //expected-error {{Target region encountered before requires directive with 'dynamic_allocators' clause}} Index: test/OpenMP/requires_messages.cpp === --- test/OpenMP/requires_messages.cpp +++ test/OpenMP/requires_messages.cpp @@ -7,7 +7,7 @@ #pragma omp requires unified_shared_memory, unified_shared_memory // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_shared_memory' clause}} -#pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} +#pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} #pragma omp requires unified_address, unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_address' clause}} @@ -29,13 +29,13 @@ #pragma omp requires atomic_default_mem_order( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} -#pragma omp requires atomic_default_mem_order(seq_cst // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} +#pragma omp requires atomic_default_mem_order(seq_cst // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} -#pragma omp requires atomic_default_mem_order(invalid_modifier) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} +#pragma omp requires atomic_default_mem_order(invalid_modifier) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} #pragma omp requires atomic_default_mem_order(shared) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} -#pragma omp requires atomic_default_mem_order(acq_rel), atomic_default_mem_order(relaxed) // expected-error {{directive '#pragma omp requires' cannot contain more than one 'atomic_default_mem_order' claus}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} +#pragma omp requires atomic_default_mem_order(acq_rel), atomic_default_mem_order(relaxed) // expected-error {{directive '#pragma omp requires' cannot contain more than one 'atomic_default_mem_order' claus}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} #pragma omp requires // ex
[PATCH] D60875: [OpenMP] Add checks for requires and target directives.
gtbercea updated this revision to Diff 195762. gtbercea added a comment. Fix test, Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D60875/new/ https://reviews.llvm.org/D60875 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaOpenMP.cpp test/OpenMP/requires_messages.cpp test/OpenMP/requires_target_messages.cpp Index: test/OpenMP/requires_target_messages.cpp === --- /dev/null +++ test/OpenMP/requires_target_messages.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s + +void foo2() { + int a; + #pragma omp target // expected-note {{Target previously encountered here}} + { +a = a + 1; + } +} + +#pragma omp requires atomic_default_mem_order(seq_cst) +#pragma omp requires unified_shared_memory //expected-error {{Target region encountered before requires directive with unified_shared_memory clause}} Index: test/OpenMP/requires_messages.cpp === --- test/OpenMP/requires_messages.cpp +++ test/OpenMP/requires_messages.cpp @@ -7,7 +7,7 @@ #pragma omp requires unified_shared_memory, unified_shared_memory // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_shared_memory' clause}} -#pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} +#pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} #pragma omp requires unified_address, unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_address' clause}} @@ -29,13 +29,13 @@ #pragma omp requires atomic_default_mem_order( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} -#pragma omp requires atomic_default_mem_order(seq_cst // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} +#pragma omp requires atomic_default_mem_order(seq_cst // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} -#pragma omp requires atomic_default_mem_order(invalid_modifier) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} +#pragma omp requires atomic_default_mem_order(invalid_modifier) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} #pragma omp requires atomic_default_mem_order(shared) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} -#pragma omp requires atomic_default_mem_order(acq_rel), atomic_default_mem_order(relaxed) // expected-error {{directive '#pragma omp requires' cannot contain more than one 'atomic_default_mem_order' claus}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} +#pragma omp requires atomic_default_mem_order(acq_rel), atomic_default_mem_order(relaxed) // expected-error {{directive '#pragma omp requires' cannot contain more than one 'atomic_default_mem_order' claus}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} #pragma omp requires // expected-error {{expected at least one clause on '#pragma omp requires' directive}} Index: lib/Sema/SemaOpenMP.cpp === --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -193,6 +193,8 @@ /// Expression for the predefined allocators. Expr *OMPPredefinedAllocators[OMPAllocateDeclAttr::OMPUserDefinedMemAlloc] = { nullptr}; + /// Vector of previously encountered target directives + SmallVector TargetLocations; public: explicit DSAStackTy(Sema &S) : SemaRef(S) {} @@ -454,6 +456,16 @@ return IsDuplicate; } + /// Add location of p
[PATCH] D60875: [OpenMP] Add checks for requires and target directives.
ABataev added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9136 +def err_omp_target_before_requires : Error < + "Target region encountered before requires directive with %0 clause">; +def note_omp_requires_encountered_target : Note < Enclose `%0` in single quotes for better reading Comment at: lib/Sema/SemaOpenMP.cpp:2440 +// Check if any of the requires clauses affect target regions. +if (!TargetLocations.empty() && +(isa(CNew) || Better to check for `TargetLocations.empty()` before the loop Comment at: lib/Sema/SemaOpenMP.cpp:4207 +DSAStack->hasRequiresDeclWithClause()) && + !CurContext->isDependentContext()) { +// Register target to DSA Stack. Better to check for the dependent context at first, only after that check for the clause Comment at: test/OpenMP/requires_target_messages.cpp:11 + +#pragma omp requires unified_shared_memory //expected-error {{Target region encountered before requires directive with unified_shared_memory clause}} Add the checks for all the clauses that may cause this error Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D60875/new/ https://reviews.llvm.org/D60875 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D60875: [OpenMP] Add checks for requires and target directives.
gtbercea created this revision. gtbercea added reviewers: ABataev, AlexEichenberger, caomhin. Herald added subscribers: cfe-commits, jdoerfert, jfb, guansong. Herald added a project: clang. The requires directive containing target related clauses must appear before any target region in the compilation unit. Repository: rC Clang https://reviews.llvm.org/D60875 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaOpenMP.cpp test/OpenMP/requires_messages.cpp test/OpenMP/requires_target_messages.cpp Index: test/OpenMP/requires_target_messages.cpp === --- /dev/null +++ test/OpenMP/requires_target_messages.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s + +void foo2() { + int a; + #pragma omp target // expected-note {{Target previously encountered here}} + { +a = a + 1; + } +} + +#pragma omp requires unified_shared_memory //expected-error {{Target region encountered before requires directive with unified_shared_memory clause}} Index: test/OpenMP/requires_messages.cpp === --- test/OpenMP/requires_messages.cpp +++ test/OpenMP/requires_messages.cpp @@ -7,7 +7,7 @@ #pragma omp requires unified_shared_memory, unified_shared_memory // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_shared_memory' clause}} -#pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} +#pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} #pragma omp requires unified_address, unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_address' clause}} @@ -29,13 +29,13 @@ #pragma omp requires atomic_default_mem_order( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} -#pragma omp requires atomic_default_mem_order(seq_cst // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} +#pragma omp requires atomic_default_mem_order(seq_cst // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} -#pragma omp requires atomic_default_mem_order(invalid_modifier) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} +#pragma omp requires atomic_default_mem_order(invalid_modifier) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} #pragma omp requires atomic_default_mem_order(shared) // expected-error {{expected 'seq_cst', 'acq_rel' or 'relaxed' in OpenMP clause 'atomic_default_mem_order'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} -#pragma omp requires atomic_default_mem_order(acq_rel), atomic_default_mem_order(relaxed) // expected-error {{directive '#pragma omp requires' cannot contain more than one 'atomic_default_mem_order' claus}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} +#pragma omp requires atomic_default_mem_order(acq_rel), atomic_default_mem_order(relaxed) // expected-error {{directive '#pragma omp requires' cannot contain more than one 'atomic_default_mem_order' claus}} expected-error {{Only one atomic_default_mem_order clause can appear on a requires directive in a single translation unit}} #pragma omp requires // expected-error {{expected at least one clause on '#pragma omp requires' directive}} Index: lib/Sema/SemaOpenMP.cpp === --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -193,6 +193,8 @@ /// Expression for the predefined allocators. Expr *OMPPredefinedAllocators[OMPAllocateDeclAttr::OMPUserDefinedMemAlloc] = { nullptr}; + /// Vector of previously encountered target directives + SmallVector TargetLocations; public: explicit DSAStackTy