lib/src/vulkan/glslang/glslang/MachineIndependent/linkValidate.cpp
//
// Compare two global objects from two compilation units and see if they match
// well enough.  Rules can be different for intra- vs. cross-stage matching.
//
// This function only does one of intra- or cross-stage matching per call.
//
Compare two global objects from two compilation units and see if they match
well enough.  Rules can be different for intra- vs. cross-stage matching.

This function only does one of intra- or cross-stage matching per call.
Compare two global objects from two compilation units and see if they match well enough . Rules can be different for intra - vs . cross - stage matching . This function only does one of intra - or cross - stage matching per call .
void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& symbol, const TIntermSymbol& unitSymbol, bool crossStage)
{
    bool writeTypeComparison = false;
    if (symbol.getType() != unitSymbol.getType()) {
        error(infoSink, "Types must match:");
        writeTypeComparison = true;
    }
    if (symbol.getQualifier().storage != unitSymbol.getQualifier().storage) {
        error(infoSink, "Storage qualifiers must match:");
        writeTypeComparison = true;
    }
    if (symbol.getQualifier().precision != unitSymbol.getQualifier().precision) {
        error(infoSink, "Precision qualifiers must match:");
        writeTypeComparison = true;
    }
    if (! crossStage && symbol.getQualifier().invariant != unitSymbol.getQualifier().invariant) {
        error(infoSink, "Presence of invariant qualifier must match:");
        writeTypeComparison = true;
    }
    if (! crossStage && symbol.getQualifier().noContraction != unitSymbol.getQualifier().noContraction) {
        error(infoSink, "Presence of precise qualifier must match:");
        writeTypeComparison = true;
    }
    if (symbol.getQualifier().centroid  != unitSymbol.getQualifier().centroid ||
        symbol.getQualifier().smooth    != unitSymbol.getQualifier().smooth ||
        symbol.getQualifier().flat      != unitSymbol.getQualifier().flat ||
        symbol.getQualifier().sample    != unitSymbol.getQualifier().sample ||
        symbol.getQualifier().patch     != unitSymbol.getQualifier().patch ||
        symbol.getQualifier().nopersp   != unitSymbol.getQualifier().nopersp) {
        error(infoSink, "Interpolation and auxiliary storage qualifiers must match:");
        writeTypeComparison = true;
    }
    if (symbol.getQualifier().coherent  != unitSymbol.getQualifier().coherent ||
        symbol.getQualifier().volatil   != unitSymbol.getQualifier().volatil ||
        symbol.getQualifier().restrict  != unitSymbol.getQualifier().restrict ||
        symbol.getQualifier().readonly  != unitSymbol.getQualifier().readonly ||
        symbol.getQualifier().writeonly != unitSymbol.getQualifier().writeonly) {
        error(infoSink, "Memory qualifiers must match:");
        writeTypeComparison = true;
    }
    if (symbol.getQualifier().layoutMatrix    != unitSymbol.getQualifier().layoutMatrix ||
        symbol.getQualifier().layoutPacking   != unitSymbol.getQualifier().layoutPacking ||
        symbol.getQualifier().layoutLocation  != unitSymbol.getQualifier().layoutLocation ||
        symbol.getQualifier().layoutComponent != unitSymbol.getQualifier().layoutComponent ||
        symbol.getQualifier().layoutIndex     != unitSymbol.getQualifier().layoutIndex ||
        symbol.getQualifier().layoutBinding   != unitSymbol.getQualifier().layoutBinding ||
        (symbol.getQualifier().hasBinding() && (symbol.getQualifier().layoutOffset != unitSymbol.getQualifier().layoutOffset))) {
        error(infoSink, "Layout qualification must match:");
        writeTypeComparison = true;
    }
    if (! writeTypeComparison) {
        if (! symbol.getConstArray().empty() && ! unitSymbol.getConstArray().empty()) {
            if (symbol.getConstArray() != unitSymbol.getConstArray()) {
                error(infoSink, "Initializers must match:");
                infoSink.info << "    " << symbol.getName() << "\n";
            }
        }
    }
    if (writeTypeComparison)
        infoSink.info << "    " << symbol.getName() << ": \"" << symbol.getType().getCompleteString() << "\" versus \"" <<
                                                             unitSymbol.getType().getCompleteString() << "\"\n";
}
void TIntermediate :: mergeErrorCheck ( TInfoSink & infoSink , const TIntermSymbol & symbol , const TIntermSymbol & unitSymbol , bool crossStage ) { bool writeTypeComparison = false ; if ( symbol . getType ( ) != unitSymbol . getType ( ) ) { error ( infoSink , " " ) ; writeTypeComparison = true ; } if ( symbol . getQualifier ( ) . storage != unitSymbol . getQualifier ( ) . storage ) { error ( infoSink , " " ) ; writeTypeComparison = true ; } if ( symbol . getQualifier ( ) . precision != unitSymbol . getQualifier ( ) . precision ) { error ( infoSink , " " ) ; writeTypeComparison = true ; } if ( ! crossStage && symbol . getQualifier ( ) . invariant != unitSymbol . getQualifier ( ) . invariant ) { error ( infoSink , " " ) ; writeTypeComparison = true ; } if ( ! crossStage && symbol . getQualifier ( ) . noContraction != unitSymbol . getQualifier ( ) . noContraction ) { error ( infoSink , " " ) ; writeTypeComparison = true ; } if ( symbol . getQualifier ( ) . centroid != unitSymbol . getQualifier ( ) . centroid || symbol . getQualifier ( ) . smooth != unitSymbol . getQualifier ( ) . smooth || symbol . getQualifier ( ) . flat != unitSymbol . getQualifier ( ) . flat || symbol . getQualifier ( ) . sample != unitSymbol . getQualifier ( ) . sample || symbol . getQualifier ( ) . patch != unitSymbol . getQualifier ( ) . patch || symbol . getQualifier ( ) . nopersp != unitSymbol . getQualifier ( ) . nopersp ) { error ( infoSink , " " ) ; writeTypeComparison = true ; } if ( symbol . getQualifier ( ) . coherent != unitSymbol . getQualifier ( ) . coherent || symbol . getQualifier ( ) . volatil != unitSymbol . getQualifier ( ) . volatil || symbol . getQualifier ( ) . restrict != unitSymbol . getQualifier ( ) . restrict || symbol . getQualifier ( ) . readonly != unitSymbol . getQualifier ( ) . readonly || symbol . getQualifier ( ) . writeonly != unitSymbol . getQualifier ( ) . writeonly ) { error ( infoSink , " " ) ; writeTypeComparison = true ; } if ( symbol . getQualifier ( ) . layoutMatrix != unitSymbol . getQualifier ( ) . layoutMatrix || symbol . getQualifier ( ) . layoutPacking != unitSymbol . getQualifier ( ) . layoutPacking || symbol . getQualifier ( ) . layoutLocation != unitSymbol . getQualifier ( ) . layoutLocation || symbol . getQualifier ( ) . layoutComponent != unitSymbol . getQualifier ( ) . layoutComponent || symbol . getQualifier ( ) . layoutIndex != unitSymbol . getQualifier ( ) . layoutIndex || symbol . getQualifier ( ) . layoutBinding != unitSymbol . getQualifier ( ) . layoutBinding || ( symbol . getQualifier ( ) . hasBinding ( ) && ( symbol . getQualifier ( ) . layoutOffset != unitSymbol . getQualifier ( ) . layoutOffset ) ) ) { error ( infoSink , " " ) ; writeTypeComparison = true ; } if ( ! writeTypeComparison ) { if ( ! symbol . getConstArray ( ) . empty ( ) && ! unitSymbol . getConstArray ( ) . empty ( ) ) { if ( symbol . getConstArray ( ) != unitSymbol . getConstArray ( ) ) { error ( infoSink , " " ) ; infoSink . info << " " << symbol . getName ( ) << " \n " ; } } } if ( writeTypeComparison ) infoSink . info << " " << symbol . getName ( ) << " \" " << symbol . getType ( ) . getCompleteString ( ) << " \" \" " << unitSymbol . getType ( ) . getCompleteString ( ) << " \" \n " ; }
Compare two global objects from two compilation units and see if they match
well enough.
Compare two global objects from two compilation units and see if they match well enough .
// Types have to match // Qualifiers have to (almost) match // Storage... // Precision... // Invariance... // Precise... // Auxiliary and interpolation... // Memory... // Layouts...  // TODO: 4.4 enhanced layouts: Generalize to include offset/align: current spec  //       requires separate user-supplied offset from actual computed offset, but  //       current implementation only has one offset. // Initializers have to match, if both are present, and if we don't already know the types don't match