#pragma options [no]info, #pragma info
Produces or suppresses groups of informational messages.
The messages are written to standard output and, optionally, to the listing file if one is generated.
Option syntax >>- -q--+-noinfo-------------------------+--------------------->< '-info--+----------------------+-' | .-:-------------. | | V | | '-=----+-all-------+-+-' +-noall-----+ +-als-------+ +-noals-----+ +-group-----+ +-nogroup---+ +-private---+ +-reduction-+ +-stp-------+ '-nostp-----'
Pragma syntax .-,-------------. V | >>-#--pragma--info--(----+-all-------+-+--)-------------------->< +-none------+ +-als-------+ +-noals-----+ +-group-----+ +-nogroup---+ +-private---+ +-reduction-+ '-restore---'
-qnoinfo
-qnoinfo
-qinfo=lan:trx
c99 | noc99
cls | nocls
vft | novft
Specifying -qinfo with
no suboptions is equivalent to -qinfo=all.
Specifying -qinfo with
no suboptions is equivalent to -qinfo=all:noppt.
Specifying -qnoinfo is equivalent to -qinfo=noall.
None.
xlc myprogram.c -qinfo=all -qinfo=nocnv:norea
The following example shows code constructs that the compiler
detects when the code is compiled with -qinfo=cnd:eff:got:obs:par:pro:rea:ret:uni in
effect: #define COND 0
void faa() // Obsolete prototype (-qinfo=obs)
{
printf("In faa\n"); // Unprototyped function call (-qinfo=pro)
}
int foo(int i, int k)
{
int j; // Uninitialized variable (-qinfo=uni)
switch(i) {
case 0:
i++;
if (COND) // Condition is always false (-qinfo=cnd)
i--; // Unreachable statement (-qinfo=rea)
break;
case 1:
break;
i++; // Unreachable statement (-qinfo=rea)
default:
k = (i) ? (j) ? j : i : 0;
}
goto L; // Use of goto statement (-qinfo=got)
return 3; // Unreachable statement (-qinfo=rea)
L:
faa(); // faa() does not have a prototype (-qinfo=pro)
// End of the function may be reached without returning a value
// because of there may be a jump to label L (-qinfo=ret)
} //Parameter k is never referenced (-qinfo=ref)
int main(void) {
({ int i = 0; i = i + 1; i; }); // Statement does not have side effects (-qinfo=eff)
return foo(1,2);
}
The following example
shows code constructs that the compiler detects, with this code is
compiled with -qinfo=cls:cnd:eff:use in effect: #pragma abc // pragma not supported (-qinfo=eff or -qinfo=gen)
int bar() __attribute__((xyz)); // attribute not supported (-qinfo=eff)
int j();
class A {
public:
A(): x(0), y(0), z(0) { }; // this constructor is in the correct order
// hence, no info message.
A(int m): y(0), z(0)
{ x=m; }; // suggest using member initialization list
for x (-qinfo=cls)
A(int m, int n):
x(0), z(0) { }; // not all data members are initialized
// namely, y is not initialized (-qinfo=cls)
A(int m, int n, int* l):
x(m), z(l), y(n) { }; // order of class initialization (-qinfo=cls)
private:
int x;
int y;
int *z; // suggest having user-defined copy constructor/
// assignment operator to handle the pointer data member
// (-qinfo=cls)
};
int foo() {
int j=5;
j; // null statement (-qinfo=eff)
// The user may mean to call j().
return j;
}
void boo() {
int x;
int *i = &x;
float *f; // f is not used (-qinfo=use)
f = (float *) i; // incompatible type (-qinfo=eff)
// With ansi aliasing mode, a float pointer
// is not supposed to point to an int
}
void cond(int y) {
const int i=0;
int j;
int k=0;
if (i) { // condition is always false (-qinfo=cnd)
j=3;
}
if (1) { // condition is always true (-qinfo=cnd)
j=4;
}
j=0;
if (j==0) { // cond. is always true (-qinfo=cnd)
j=5;
}
if (y) {
k+=5
}
if (k==5) { // This case cannot be determined, because k+=5
// is in a conditional block.
j=6;
}
}
In the following example, the #pragma info(eff, nouni) directive preceding MyFunction1 instructs the compiler to generate messages identifying statements or pragmas with no effect, and to suppress messages identifying uninitialized variables. The #pragma info(restore) directive preceding MyFunction2 instructs the compiler to restore the message options that were in effect before the #pragma info(eff, nouni) directive was specified.
#pragma info(eff, nouni)
int MyFunction1()
{
.
.
.
}
#pragma info(restore)
int MyFunction2()
{
.
.
.
}
t1.c:
int main() {
short s = 42;
int *pi = (int*) &s;
*pi = 63;
return 0;
}
xlC -+ -qinfo=als t1.c
"t1.c", line 4.3: 1540-0590 (I) Dereference may not conform to the current
aliasing rules.
"t1.c", line 4.3: 1540-0591 (I) The dereferenced expression has type "int".
"pi" may point to "s" which has incompatible
type "short".
"t1.c", line 4.3: 1540-0592 (I) Check assignment at line 3 column 11 of t1.c.
t2.c:
int* floatToInt(float *pf) { return (int*)pf; }
int main() {
int i;
float f;
int* pi = floatToInt((float*)*&i));
floatToInt(&f;)
return *pi;
}
xlC -+ -qinfo=als t2.c
"t2.c", line 8.10: 1540-0590 (I) Dereference may not conform to the current
aliasing rules.
"t2.c", line 8.10: 1540-0591 (I) The dereferenced expression has type "int".
"pi" may point to "f" which has incompatible
type "float".
"t2.c", line 8.10: 1540-0592 (I) Check assignment at line 7 column 14 of t2.c.
"t2.c", line 8.10: 1540-0592 (I) Check assignment at line 1 column 37 of t2.c.
"t2.c", line 8.10: 1540-0592 (I) Check assignment at line 6 column 11 of t2.c.
t3.c:
int main() {
float f;
int i = 42;
int *p = (int*) &f;
p = &i;
return *p;
}
xlC -+ -qinfo=als t3.c
"t3.c", line 6.10: 1540-0590 (I) Dereference may not conform to the current aliasing rules.
"t3.c", line 6.10: 1540-0591 (I) The dereferenced expression has type "int". "p" may point to
"f" which has incompatible type "float".
"t3.c", line 6.10: 1540-0592 (I) Check assignment at line 4 column 10 of t3.c.