Front-end: enforce qualifiers that cannot appear on block declarations.

Also seems to pick up some white-space (line-ending) test differences with a
prevoius checkin.
This commit is contained in:
John Kessenich 2015-07-14 19:30:11 -06:00
parent 8318878c89
commit fdfa6bbdfe
6 changed files with 74 additions and 14 deletions

View File

@ -123,3 +123,19 @@ out gl_PerVertex { // ERROR, already used and already redeclared
highp vec4 gl_Position;
highp vec4 t;
};
smooth out smo { // ERROR, no smooth on a block
int i;
} smon;
flat out fmo { // ERROR, no flat on a block
int i;
} fmon;
centroid out cmo { // ERROR, no centroid on a block
int i;
} cmon;
invariant out imo { // ERROR, no invariant on a block
int i;
} imon;

View File

@ -23,7 +23,11 @@ ERROR: 0:109: 'gl_PerVertex' : block redeclaration has extra members
ERROR: 0:119: 'gl_PointSize' : member of nameless block was not redeclared
ERROR: 0:119: 'assign' : cannot convert from 'const float' to 'gl_PointSize highp void PointSize'
ERROR: 0:122: 'gl_PerVertex' : can only redeclare a built-in block once, and before any use
ERROR: 22 compilation errors. No code generated.
ERROR: 0:127: 'flat/smooth/noperspective' : cannot use interpolation qualifiers on an interface block
ERROR: 0:131: 'flat/smooth/noperspective' : cannot use interpolation qualifiers on an interface block
ERROR: 0:135: 'centroid' : cannot use centroid qualifier on an interface block
ERROR: 0:139: 'invariant' : cannot use invariant qualifier on an interface block
ERROR: 26 compilation errors. No code generated.
Shader version: 310
@ -225,6 +229,10 @@ ERROR: node is still EOpNull!
0:? 'aliased' (layout(location=12 ) smooth out highp int)
0:? 'inbinst' (in block{in highp int a})
0:? 'anon@1' (out block{gl_Position highp 4-component vector of float Position gl_Position, })
0:? 'smon' (smooth out block{out highp int i})
0:? 'fmon' (flat out block{out highp int i})
0:? 'cmon' (centroid out block{out highp int i})
0:? 'imon' (invariant out block{out highp int i})
0:? 'gl_VertexID' (gl_VertexId highp int VertexId)
0:? 'gl_InstanceID' (gl_InstanceId highp int InstanceId)
@ -431,6 +439,10 @@ ERROR: node is still EOpNull!
0:? 'aliased' (layout(location=12 ) smooth out highp int)
0:? 'inbinst' (in block{in highp int a})
0:? 'anon@1' (out block{gl_Position highp 4-component vector of float Position gl_Position, })
0:? 'smon' (smooth out block{out highp int i})
0:? 'fmon' (flat out block{out highp int i})
0:? 'cmon' (centroid out block{out highp int i})
0:? 'imon' (invariant out block{out highp int i})
0:? 'gl_VertexID' (gl_VertexId highp int VertexId)
0:? 'gl_InstanceID' (gl_InstanceId highp int InstanceId)

View File

@ -1,8 +1,8 @@
Warning, version 310 is not yet complete; most version-specific features are present, but some are missing.
ERROR: 0:9: '#error' : This should show up in pp output .
ERROR: 0:14: '#' : invalid directive: def
ERROR: 0:15: 'preprocessor evaluation' : undefined macro in expression not allowed in es profile Y
ERROR: 0:21: '' : missing #endif
ERROR: 4 compilation errors. No code generated.
Warning, version 310 is not yet complete; most version-specific features are present, but some are missing.
ERROR: 0:9: '#error' : This should show up in pp output .
ERROR: 0:14: '#' : invalid directive: def
ERROR: 0:15: 'preprocessor evaluation' : undefined macro in expression not allowed in es profile Y
ERROR: 0:21: '' : missing #endif
ERROR: 4 compilation errors. No code generated.

View File

@ -1,4 +1,4 @@
int x(){
something that shouldnt compile;
}
int x(){
something that shouldnt compile;
}

View File

@ -4586,6 +4586,7 @@ TIntermTyped* TParseContext::constructStruct(TIntermNode* node, const TType& typ
void TParseContext::declareBlock(TSourceLoc loc, TTypeList& typeList, const TString* instanceName, TArraySizes* arraySizes)
{
blockStageIoCheck(loc, currentBlockQualifier);
blockQualifierCheck(loc, currentBlockQualifier);
if (arraySizes)
arrayUnsizedCheck(loc, currentBlockQualifier, arraySizes->getOuterSize(), false);
arrayDimCheck(loc, arraySizes, 0);
@ -4810,10 +4811,40 @@ void TParseContext::blockStageIoCheck(TSourceLoc loc, const TQualifier& qualifie
break;
default:
error(loc, "only uniform, buffer, in, or out blocks are supported", blockName->c_str(), "");
return;
break;
}
}
// Do all block-declaration checking regarding its qualifers.
void TParseContext::blockQualifierCheck(TSourceLoc loc, const TQualifier& qualifier)
{
// The 4.5 specification says:
//
// interface-block :
// layout-qualifieropt interface-qualifier block-name { member-list } instance-nameopt ;
//
// interface-qualifier :
// in
// out
// patch in
// patch out
// uniform
// buffer
//
// Note however memory qualifiers aren't included, yet the specification also says
//
// "...memory qualifiers may also be used in the declaration of shader storage blocks..."
if (qualifier.isInterpolation())
error(loc, "cannot use interpolation qualifiers on an interface block", "flat/smooth/noperspective", "");
if (qualifier.centroid)
error(loc, "cannot use centroid qualifier on an interface block", "centroid", "");
if (qualifier.sample)
error(loc, "cannot use sample qualifier on an interface block", "sample", "");
if (qualifier.invariant)
error(loc, "cannot use invariant qualifier on an interface block", "invariant", "");
}
//
// "For a block, this process applies to the entire block, or until the first member
// is reached that has a location layout qualifier. When a block member is declared with a location

View File

@ -193,6 +193,7 @@ public:
TIntermTyped* constructBuiltIn(const TType&, TOperator, TIntermTyped*, TSourceLoc, bool subset);
void declareBlock(TSourceLoc, TTypeList& typeList, const TString* instanceName = 0, TArraySizes* arraySizes = 0);
void blockStageIoCheck(TSourceLoc, const TQualifier&);
void blockQualifierCheck(TSourceLoc, const TQualifier&);
void fixBlockLocations(TSourceLoc, TQualifier&, TTypeList&, bool memberWithLocation, bool memberWithoutLocation);
void fixBlockXfbOffsets(TQualifier&, TTypeList&);
void fixBlockUniformOffsets(TQualifier&, TTypeList&);