VirtualBox

Changeset 57002 in vbox for trunk/src/bldprogs


Ignore:
Timestamp:
Jul 18, 2015 11:44:13 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
101717
Message:

gccplugin: Use error_at instead of warning_at when there are too many or too few arguments. Implemented %M.

Location:
trunk/src/bldprogs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bldprogs/VBoxCompilerPlugIns.h

    r56977 r57002  
    6262 * Implements checking format string replacement (%M).
    6363 *
    64  * Caller will have checked all that can be checked.
     64 * Caller will have checked all that can be checked.  This means that there is a
     65 * string argument present, or it won't make the call.
    6566 *
    6667 * @param   pState              The format string checking state.
     
    8081 */
    8182void            VFmtChkWarnFmt(PVFMTCHKSTATE pState, const char *pszLoc, const char *pszFormat, ...);
     83
     84/**
     85 * Error.
     86 *
     87 * @returns
     88 * @param   pState              .
     89 * @param   pszLoc              .
     90 * @param   pszFormat           .
     91 * @param   ...                 .
     92 */
     93void            VFmtChkErrFmt(PVFMTCHKSTATE pState, const char *pszLoc, const char *pszFormat, ...);
    8294
    8395/**
  • trunk/src/bldprogs/VBoxCompilerPlugInsCommon.cpp

    r56981 r57002  
    118118            cchWidth = 0;
    119119            fFlags |= RTSTR_F_WIDTH;
     120            ch = *pszFmt++;
    120121        }
    121122
     
    142143                iArg++;
    143144                cchPrecision = 0;
     145                ch = *pszFmt++;
    144146            }
    145147            else
    146                 VFmtChkWarnFmt(pState, pszPct, "Missing precision value, only got the '.'");
     148                VFmtChkErrFmt(pState, pszPct, "Missing precision value, only got the '.'");
    147149            if (cchPrecision < 0)
    148150            {
    149                 VFmtChkWarnFmt(pState, pszPct, "Negative precision value: %d", cchPrecision);
     151                VFmtChkErrFmt(pState, pszPct, "Negative precision value: %d", cchPrecision);
    150152                cchPrecision = 0;
    151153            }
     
    223225            {
    224226                if (*pszFmt)
    225                     VFmtChkWarnFmt(pState, pszFmt, "Characters following '%%M' will be ignored");
     227                    VFmtChkErrFmt(pState, pszFmt, "Characters following '%%M' will be ignored");
    226228                if (chSize != '\0')
    227229                    VFmtChkWarnFmt(pState, pszFmt, "'%%M' does not support any size flags (%c)", chSize);
  • trunk/src/bldprogs/VBoxCompilerPlugInsGcc.cpp

    r56977 r57002  
    617617
    618618
     619void VFmtChkErrFmt(PVFMTCHKSTATE pState, const char *pszLoc, const char *pszFormat, ...)
     620{
     621    char szTmp[1024];
     622    va_list va;
     623    va_start(va, pszFormat);
     624    vsnprintf(szTmp, sizeof(szTmp), pszFormat, va);
     625    va_end(va);
     626
     627    /* display the warning. */
     628    error_at(MyGetFormatStringLocation(pState, pszLoc), "%s", szTmp);
     629}
     630
     631
    619632
    620633void VFmtChkVerifyEndOfArgs(PVFMTCHKSTATE pState, unsigned iArg)
     
    631644            tree hArg = gimple_call_arg(pState->hStmt, iArg);
    632645            if (cArgs - iArg > 1)
    633                 warning_at(MY_LOC(hArg, pState), 0, "%u extra arguments not consumed by format string", cArgs - iArg);
     646                error_at(MY_LOC(hArg, pState), "%u extra arguments not consumed by format string", cArgs - iArg);
    634647            else if (   TREE_CODE(hArg) != INTEGER_CST
    635648                     || !TREE_INT_CST(hArg).fits_shwi()
    636649                     || TREE_INT_CST(hArg).to_shwi() != -99) /* ignore final dummy argument: ..., -99); */
    637                 warning_at(MY_LOC(hArg, pState), 0, "one extra argument not consumed by format string");
     650                error_at(MY_LOC(hArg, pState), "one extra argument not consumed by format string");
    638651        }
    639652        /* This should be handled elsewhere, but just in case. */
    640653        else if (iArg - 1 == cArgs)
    641             warning_at(pState->hFmtLoc, 0, "one argument too few");
     654            error_at(pState->hFmtLoc, "one argument too few");
    642655        else
    643             warning_at(pState->hFmtLoc, 0, "%u arguments too few", iArg - cArgs);
     656            error_at(pState->hFmtLoc, "%u arguments too few", iArg - cArgs);
    644657    }
    645658}
     
    654667        if (iArg >= cArgs)
    655668        {
    656             VFmtChkWarnFmt(pState, pszLoc, "Missing argument! %s", pszMessage);
     669            VFmtChkErrFmt(pState, pszLoc, "Missing argument! %s", pszMessage);
    657670            return false;
    658671        }
     
    695708
    696709
    697 
    698710void VFmtChkHandleReplacementFormatString(PVFMTCHKSTATE pState, const char *pszPctM, unsigned iArg)
    699711{
    700712    if (pState->iArgs > 0)
    701713    {
    702         pState->iArgs += iArg;
    703 
     714        pState->iFmt  = pState->iArgs + iArg;
     715        pState->iArgs = pState->iFmt  + 1;
     716        MyCheckFormatRecursive(pState, gimple_call_arg(pState->hStmt, pState->iFmt - 1));
    704717    }
    705718}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette