Home > User Support > CoverageMaster winAMS FAQ

CoverageMaster winAMS FAQ

CasePlayer2 Analysis

019_09: When analyzing with CasePlayer2, an analysis error occurs at a line that accesses a structure/union member. How do I fix it?

Question:

When analyzing with CasePlayer2, an analysis error occurs at a line that accesses a structure/union member. How do I fix it?

Answer:

The cause is because there are members of type "nameless structure" or "nameless union" in the structure/union.

For example, when analyzing the source code below in CasePlayer2's advanced analysis mode, the analysis errors below occur at the line of * error occurs here.

typedef union {
    struct {
        unsigned char aaa;
        unsigned short bbb;
        unsigned long ccc;
    };
        unsigned char BYTE[20];
} UTable;

int test(int a)
{
    UTable table;

    if (a < 0) {
        return -1;
    }

    table.aaa = 1; // * error occurs here
    return a;
}

Creating-Documentation...
Analyzing C_source...
C:\SL1\SL1 0 Management\support\etc\FAQ\019_09\test\src\test.c
CasePlayer2-E-SYN: Name (aaa) is not declared.
C:\SL1\SL1 0 Management\support\etc\FAQ\019_09\test\src\test.c(18)
CasePlayer2-I-COMP: Error: 1 Warning: 0
Complete-Documentation-Generation.

Accessing members using an nameless structure is an extension introduced by GCC, so an analysis error will occur in CasePlayer2's default "ANSI-C" mode.

Solution

The error can be avoided by changing the CasePlayer2 C Source Language Setting to "GNU-C".

However, if instead you need to analyze in ANSI-C mode for some reason, you need to change the source code. Specifically, first in the structure definition portion. Specify the structure name as below (the name is arbitrary).

typedef union {
    struct {
        unsigned char aaa;
        unsigned short bbb;
        unsigned long ccc;
    } ST; // * change here
        unsigned char BYTE[20];
} UTable;

Also change the code where the structure is referenced to use the new structure name as below.

int test(int a)
{
    UTable table;

    if (a < 0) {
        return -1;
    }

    table.ST.aaa = 1; // * change here
    return a;
}



Related Technical Tips Search

Other technical tips in GAIO's web site can be searched for using the links below.

Search key word link: Settings with CoverageMaster
Technical Tips Google Search

 

Information Links