Merge pull request #3175 from imirkin/master

make gcc check the printf format strings
This commit is contained in:
Pierre Bourdon 2015-10-17 03:44:28 +02:00
commit c0d157e6f6
3 changed files with 11 additions and 5 deletions

View File

@ -184,7 +184,7 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
out.Write("//Pixel Shader for TEV stages\n");
out.Write("//%i TEV stages, %i texgens, %i IND stages\n",
numStages, numTexgen, bpmem.genMode.numindstages);
numStages, numTexgen, bpmem.genMode.numindstages.Value());
uid_data->dstAlphaMode = dstAlphaMode;
uid_data->genMode_numindstages = bpmem.genMode.numindstages;

View File

@ -32,8 +32,11 @@ public:
* Can be used like printf.
* @note In the ShaderCode implementation, this does indeed write the parameter string to an internal buffer. However, you're free to do whatever you like with the parameter.
*/
template<typename... Args>
void Write(const char*, Args...) {}
void Write(const char*, ...)
#ifdef __GNUC__
__attribute__((format(printf, 2, 3)))
#endif
{}
/*
* Returns a read pointer to the internal buffer.
@ -116,6 +119,9 @@ public:
}
void Write(const char* fmt, ...)
#ifdef __GNUC__
__attribute__((format(printf, 2, 3)))
#endif
{
va_list arglist;
va_start(arglist, fmt);

View File

@ -83,11 +83,11 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
else
{
// Let's set up attributes
for (size_t i = 0; i < 8; ++i)
for (u32 i = 0; i < 8; ++i)
{
if (i < xfmem.numTexGen.numTexGens)
{
out.Write("%s out float3 uv%d;\n", GetInterpolationQualifier(api_type), i);
out.Write("%s out float3 uv%u;\n", GetInterpolationQualifier(api_type), i);
}
}
out.Write("%s out float4 clipPos;\n", GetInterpolationQualifier(api_type));