Skip to content

Commit

Permalink
[Sema][HLSL] Remove some duplicated code. NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
bogner committed Aug 25, 2023
1 parent ea32f99 commit d43f324
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10325,7 +10325,10 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
return NewFD;
}

if (getLangOpts().OpenCL) {
if (getLangOpts().OpenCL || getLangOpts().HLSL) {
// Neither OpenCL nor HLSL allow an address space qualifyer on a return
// type.
//
// OpenCL v1.1 s6.5: Using an address space qualifier in a function return
// type declaration will generate a compilation error.
LangAS AddressSpace = NewFD->getReturnType().getAddressSpace();
Expand Down Expand Up @@ -10360,13 +10363,6 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
}
}
}
// HLSL does not support specifying an address space on a function return
// type.
LangAS AddressSpace = NewFD->getReturnType().getAddressSpace();
if (AddressSpace != LangAS::Default) {
Diag(NewFD->getLocation(), diag::err_return_value_with_address_space);
NewFD->setInvalidDecl();
}
}

if (!getLangOpts().CPlusPlus) {
Expand Down

0 comments on commit d43f324

Please sign in to comment.