From 3acbe8145c60f4d1e7a180b4602a94269a489df5 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Thu, 27 Apr 2023 12:36:59 +0800 Subject: Fix most of the disabled warnings on gcc/clang (#2839) --- source/slang/slang-reflection-api.cpp | 39 ++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'source/slang/slang-reflection-api.cpp') diff --git a/source/slang/slang-reflection-api.cpp b/source/slang/slang-reflection-api.cpp index e3e9de2cd..5d35c7eef 100644 --- a/source/slang/slang-reflection-api.cpp +++ b/source/slang/slang-reflection-api.cpp @@ -90,6 +90,7 @@ static inline ProgramLayout* convert(SlangReflection* program) return (ProgramLayout*) program; } +[[maybe_unused]] static inline SlangReflection* convert(ProgramLayout* program) { return (SlangReflection*) program; @@ -311,27 +312,27 @@ SLANG_API SlangTypeKind spReflectionType_GetKind(SlangReflectionType* inType) // TODO(tfoley: Don't emit the same type more than once... - if (auto basicType = as(type)) + if (const auto basicType = as(type)) { return SLANG_TYPE_KIND_SCALAR; } - else if (auto vectorType = as(type)) + else if (const auto vectorType = as(type)) { return SLANG_TYPE_KIND_VECTOR; } - else if (auto matrixType = as(type)) + else if (const auto matrixType = as(type)) { return SLANG_TYPE_KIND_MATRIX; } - else if (auto parameterBlockType = as(type)) + else if (const auto parameterBlockType = as(type)) { return SLANG_TYPE_KIND_PARAMETER_BLOCK; } - else if (auto constantBufferType = as(type)) + else if (const auto constantBufferType = as(type)) { return SLANG_TYPE_KIND_CONSTANT_BUFFER; } - else if( auto streamOutputType = as(type) ) + else if( const auto streamOutputType = as(type) ) { return SLANG_TYPE_KIND_OUTPUT_STREAM; } @@ -347,15 +348,15 @@ SLANG_API SlangTypeKind spReflectionType_GetKind(SlangReflectionType* inType) { return SLANG_TYPE_KIND_SHADER_STORAGE_BUFFER; } - else if (auto samplerStateType = as(type)) + else if (const auto samplerStateType = as(type)) { return SLANG_TYPE_KIND_SAMPLER_STATE; } - else if (auto textureType = as(type)) + else if (const auto textureType = as(type)) { return SLANG_TYPE_KIND_RESOURCE; } - else if (auto feedbackType = as(type)) + else if (const auto feedbackType = as(type)) { return SLANG_TYPE_KIND_FEEDBACK; } @@ -376,7 +377,7 @@ SLANG_API SlangTypeKind spReflectionType_GetKind(SlangReflectionType* inType) CASE(UntypedBufferResourceType); #undef CASE - else if (auto arrayType = as(type)) + else if (const auto arrayType = as(type)) { return SLANG_TYPE_KIND_ARRAY; } @@ -401,11 +402,11 @@ SLANG_API SlangTypeKind spReflectionType_GetKind(SlangReflectionType* inType) return SLANG_TYPE_KIND_STRUCT; } } - else if( auto specializedType = as(type) ) + else if( const auto specializedType = as(type) ) { return SLANG_TYPE_KIND_SPECIALIZED; } - else if (auto errorType = as(type)) + else if (const auto errorType = as(type)) { // This means we saw a type we didn't understand in the user's code return SLANG_TYPE_KIND_NONE; @@ -510,11 +511,11 @@ SLANG_API unsigned int spReflectionType_GetRowCount(SlangReflectionType* inType) { return (unsigned int) getIntVal(matrixType->getRowCount()); } - else if(auto vectorType = as(type)) + else if(const auto vectorType = as(type)) { return 1; } - else if( auto basicType = as(type) ) + else if( const auto basicType = as(type) ) { return 1; } @@ -535,7 +536,7 @@ SLANG_API unsigned int spReflectionType_GetColumnCount(SlangReflectionType* inTy { return (unsigned int) getIntVal(vectorType->elementCount); } - else if( auto basicType = as(type) ) + else if( const auto basicType = as(type) ) { return 1; } @@ -1238,7 +1239,7 @@ namespace Slang SlangBindingType _calcResourceBindingType( Type* type) { - if(auto combinedTextureSamplerType = as(type)) + if(const auto combinedTextureSamplerType = as(type)) { return SLANG_BINDING_TYPE_COMBINED_TEXTURE_SAMPLER; } @@ -1260,7 +1261,7 @@ namespace Slang return SlangBindingType(SLANG_BINDING_TYPE_TYPED_BUFFER | mutableFlag); } } - else if( auto structuredBufferType = as(type) ) + else if( const auto structuredBufferType = as(type) ) { if( as(type) ) { @@ -1275,7 +1276,7 @@ namespace Slang { return SLANG_BINDING_TYPE_RAY_TRACING_ACCELERATION_STRUCTURE; } - else if( auto untypedBufferType = as(type) ) + else if( const auto untypedBufferType = as(type) ) { if( as(type) ) { @@ -1928,7 +1929,7 @@ namespace Slang m_extendedInfo->m_bindingRanges.add(bindingRange); // For `StructuredBuffer` fields, we also make sure to report it as a sub-object range. - if (auto structuredBufferTypeLayout = as(typeLayout)) + if (const auto structuredBufferTypeLayout = as(typeLayout)) { TypeLayout::ExtendedInfo::SubObjectRangeInfo subObjectRange; subObjectRange.bindingRangeIndex = bindingRangeIndex; -- cgit v1.2.3