Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,12 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
bool Pre(const parser::OpenMPAllocatorsConstruct &);
void Post(const parser::OpenMPAllocatorsConstruct &);

bool Pre(const parser::OmpDeclareVariantDirective &x) {
PushContext(x.source, llvm::omp::Directive::OMPD_declare_variant);
return true;
}
void Post(const parser::OmpDeclareVariantDirective &) { PopContext(); };

void Post(const parser::OmpObjectList &x) {
// The objects from OMP clauses should have already been resolved,
// except common blocks (the ResolveNamesVisitor does not visit
Expand Down
27 changes: 27 additions & 0 deletions flang/test/Parser/OpenMP/declare-variant.f90
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,30 @@ subroutine vsub(v1, v2)
type(c_ptr), value :: v1, v2
end
end subroutine

subroutine f
real :: x, y
y = 2
!omp simd
call f2(x, y)
!omp end simd
contains
subroutine f1 (x, y)
real :: x, y
end

subroutine f2 (x, y)
real :: x, y
!$omp declare variant (f1) match (construct={simd(uniform(y))})
end
end subroutine
!CHECK: !$OMP DECLARE VARIANT (f1) MATCH(CONSTRUCT={SIMD(UNIFORM(y))})
!PARSE-TREE: | | | | DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OmpDeclareVariantDirective
!PARSE-TREE-NEXT: | | | | | Verbatim
!PARSE-TREE-NEXT: | | | | | Name = 'f1'
!PARSE-TREE-NEXT: | | | | | OmpClauseList -> OmpClause -> Match -> OmpMatchClause -> OmpContextSelectorSpecification -> OmpTraitSetSelector
!PARSE-TREE-NEXT: | | | | | | OmpTraitSetSelectorName -> Value = Construct
!PARSE-TREE-NEXT: | | | | | | OmpTraitSelector
!PARSE-TREE-NEXT: | | | | | | | OmpTraitSelectorName -> Value = Simd
!PARSE-TREE-NEXT: | | | | | | | Properties
!PARSE-TREE-NEXT: | | | | | | | | OmpTraitProperty -> OmpClause -> Uniform -> Name = 'y'
Loading