#1090 cpp parser exception with inline asm

PMD-5.2.2
closed
None
CPD
3-Major
Bug
5.0.4
2014-12-03
2013-05-06
No

Got this error while running CPD on a C++ codebase:

net.sourceforge.pmd.lang.ast.TokenMgrError: Lexical error in file /work/mhargett/qa-tools-trunk/./perf-test/mtest.cc at line 157, column 11. Encountered: "\n" (10), after : "\""
at net.sourceforge.pmd.lang.cpp.ast.CppParserTokenManager.getNextToken(CppParserTokenManager.java:1648)
at net.sourceforge.pmd.lang.cpp.CppTokenManager.getNextToken(CppTokenManager.java:23)
at net.sourceforge.pmd.cpd.CPPTokenizer.tokenize(CPPTokenizer.java:29)
at net.sourceforge.pmd.cpd.CPD.add(CPD.java:110)

the code in question:

#if 0
static void my_memset(void *dest,int fill_value,int count)
{
    __asm __volatile__(
         "cld\n"
         "mov %ecx, %ebx\n"
         "shr 2,%ecx\n"
         "rep "
         "stosl\n"
         "mov %ebx,%ecx\n"
         "  // line 157 mentioned above
         : 
         : "c" (count), "a" (fill_value), "D" (dest)
         : "cc","%ebx" );
}
#endif

The syntax is incorrect, of course, but I'm not sure that PMD should be trying to process something that is #if 0'd out. Simian appears to correctly skip #if 0'd things and has no problem with this file.

Discussion

  • Andreas Dangel

    Andreas Dangel - 2014-02-09
    • Milestone: PMD-5.0.x --> PMD-Backlog
     
  • Andreas Dangel

    Andreas Dangel - 2014-11-28

    Will be fixed/implemented with 5.2.2.

    2 new parameters for CPD have been introduced:

    • --no-skip-blocks: can disable the behavior. By default, skip blocks is activated.
    • --skip-blocks-pattern: the start/end pattern to identify a block .By default "#if 0|#endif" is used. The start/end patterns are separated by a "|".
     
  • Andreas Dangel

    Andreas Dangel - 2014-11-28
    • status: open --> closed
    • assigned_to: Andreas Dangel
    • Milestone: PMD-Backlog --> PMD-Next
     
  • Andreas Dangel

    Andreas Dangel - 2014-11-28
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,12 +1,15 @@
     Got this error while running CPD on a C++ codebase:
    -net.sourceforge.pmd.lang.ast.TokenMgrError: Lexical error in file /work/mhargett/qa-tools-trunk/./perf-test/mtest.cc at line 157, column 11.  Encountered: "\n" (10), after : "\""
    -   at net.sourceforge.pmd.lang.cpp.ast.CppParserTokenManager.getNextToken(CppParserTokenManager.java:1648)
    -   at net.sourceforge.pmd.lang.cpp.CppTokenManager.getNextToken(CppTokenManager.java:23)
    -   at net.sourceforge.pmd.cpd.CPPTokenizer.tokenize(CPPTokenizer.java:29)
    -   at net.sourceforge.pmd.cpd.CPD.add(CPD.java:110)
    +
    +> net.sourceforge.pmd.lang.ast.TokenMgrError: Lexical error in file /work/mhargett/qa-tools-trunk/./perf-test/mtest.cc at line 157, column 11.  Encountered: "\n" (10), after : "\""
    +>        at net.sourceforge.pmd.lang.cpp.ast.CppParserTokenManager.getNextToken(CppParserTokenManager.java:1648)
    +>        at net.sourceforge.pmd.lang.cpp.CppTokenManager.getNextToken(CppTokenManager.java:23)
    +>        at net.sourceforge.pmd.cpd.CPPTokenizer.tokenize(CPPTokenizer.java:29)
    +>        at net.sourceforge.pmd.cpd.CPD.add(CPD.java:110)
    
     the code in question:
    +
    +~~~~~
     #if 0
     static void my_memset(void *dest,int fill_value,int count)
     {
    @@ -23,5 +26,6 @@
              : "cc","%ebx" );
     }
     #endif
    +~~~~~
    
     The syntax is incorrect, of course, but I'm not sure that PMD should be trying to process something that is #if 0'd out. Simian appears to correctly skip #if 0'd things and has no problem with this file.
    
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks