diff --git a/Test/baseResults/functionSemantics.frag.out b/Test/baseResults/functionSemantics.frag.out index a9dfb91c53cbafd1b8c35dbd7dcbdc2b88c15778..1ea7dbd68edb670b143e2c818c4839c3e37190ea 100644 --- a/Test/baseResults/functionSemantics.frag.out +++ b/Test/baseResults/functionSemantics.frag.out @@ -1,8 +1,12 @@ functionSemantics.frag Warning, version 400 is not yet complete; most version-specific features are present, but some are missing. +ERROR: 0:74: 'return' : cannot convert return value to function return type +WARNING: 0:74: 'return' : type conversion on return values was not explicitly allowed until version 420 +ERROR: 1 compilation errors. No code generated. + Shader version: 400 -0:? Sequence +ERROR: node is still EOpNull! 0:5 Function Definition: foo(i1;i1;i1;i1;i1;i1; (global int) 0:5 Function Parameters: 0:5 'a' (in int) @@ -195,6 +199,11 @@ Shader version: 400 0:69 Construct ivec2 (temp 2-component vector of int) 0:69 Convert float to int (temp int) 0:69 'F' (temp float) +0:72 Function Definition: badConv( (global 4-component vector of float) +0:72 Function Parameters: +0:74 Sequence +0:74 Branch: Return with expression +0:74 'u' (uniform float) 0:? Linker Objects 0:? 'u' (uniform float) @@ -203,7 +212,7 @@ Linked fragment stage: Shader version: 400 -0:? Sequence +ERROR: node is still EOpNull! 0:5 Function Definition: foo(i1;i1;i1;i1;i1;i1; (global int) 0:5 Function Parameters: 0:5 'a' (in int) @@ -396,6 +405,11 @@ Shader version: 400 0:69 Construct ivec2 (temp 2-component vector of int) 0:69 Convert float to int (temp int) 0:69 'F' (temp float) +0:72 Function Definition: badConv( (global 4-component vector of float) +0:72 Function Parameters: +0:74 Sequence +0:74 Branch: Return with expression +0:74 'u' (uniform float) 0:? Linker Objects 0:? 'u' (uniform float) diff --git a/Test/functionSemantics.frag b/Test/functionSemantics.frag index 15ebc604c2ec66a8f4e9f50bea9887afdc8eea1a..e5c3ed00e99d403a53bc7483e2f59e73ad4a5c20 100644 --- a/Test/functionSemantics.frag +++ b/Test/functionSemantics.frag @@ -68,3 +68,8 @@ void aggCall() float F; m(ivec2(F)); // test input conversion of single argument that's an aggregate; other function tests in 120.vert } + +vec4 badConv() +{ + return u; // ERROR, can change scalar to vector +} \ No newline at end of file diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 49ac1c9bf3a48c87199571d0e555453973ed4886..fe22ff80b02cc4c46b09c800a5c3c3561995c015 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -1208,6 +1208,8 @@ TIntermNode* TParseContext::handleReturnValue(const TSourceLoc& loc, TIntermType } else if (*currentFunctionType != value->getType()) { TIntermTyped* converted = intermediate.addConversion(EOpReturn, *currentFunctionType, value); if (converted) { + if (*currentFunctionType != converted->getType()) + error(loc, "cannot convert return value to function return type", "return", ""); if (version < 420) warn(loc, "type conversion on return values was not explicitly allowed until version 420", "return", ""); return intermediate.addBranch(EOpReturn, converted, loc);