This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Suppressing assembler warnings from C++ in C6000 CGT?

For some background, I am trying to implement a software breakpoint that I can use as a debug assert.

Here is my code:

#define SOFTWARE_BREAKPOINT() { \
    _Pragma("diag_suppress 1119"); \
    asm( " .long 0x1001E000" ); \
    _Pragma("diag_default 1119");}

....

if(somethingbad)
    SOFTWARE_BREAKPOINT();

I am getting the following warning from the C6000 CGT 7.30 tools:

    Description    Resource    Path    Location    Type
    #1119-D this assembly directive potentially unsafe inside a function    startupshutdown.c    /DSPLINKTest    line 72    C/C++ Problem

As you can see, it does not appear that the suppress pragma is trickling down into the assembler?

I can't find any documentation that suggests a way to suppress warnings in the assembler. I was expecting to find something I could do such as  "asm(" code to turn off warnings");"

Anyone have any ideas?





  • Further investigation yields that this is generated by the C compiler, and the diag_default pragma is the problem.

    I'm not sure how I can properly deal with this. My general method, as can be seen here, has been to disable the diagnostic message just before the offending code, and re-enable it after the offending code. It seems like I can't do that for some reason.

  • And through further guessing I assume that the compiler  thinks the "asm" statement isn't a line of C it should care about, so it assumes that the diag_suppress followed by diag_default can simply be "optimized" out.  Or perhaps it's some strange alignment issue.

    My solution, which seems to work, is to wrap some C around the offending statement:

    #define SOFTWARE_BREAKPOINT() { \
        _Pragma("diag_suppress=1119") \
        do { \
        asm(" .long 0x1001E000"); \
        } while(0); \
        _Pragma("diag_default=1119") \
    }

  • It seems it is easy to fool the compiler with:

       __asm("  nop 6\n  .long 0x1001E000\n  nop 6 ");

    Only a "  nop\n " prefix is necessary, but I think it is better to surround it with enought nop to prevent problems with the delay slots (but maybe it is not necessary).