Author: Justin Bogner Date: 2023-08-25T01:03:22-07:00 New Revision: d43f324f6de40f81001e4105fe99305ac3b1c875
URL: https://github.com/llvm/llvm-project/commit/d43f324f6de40f81001e4105fe99305ac3b1c875 DIFF: https://github.com/llvm/llvm-project/commit/d43f324f6de40f81001e4105fe99305ac3b1c875.diff LOG: [Sema][HLSL] Remove some duplicated code. NFC Added: Modified: clang/lib/Sema/SemaDecl.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 0d5f696bf04061..4eacc05f85e69e 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -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(); @@ -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) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits