This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C vs. C++ parsers and the __attribute__ syntax


we're seeing discrepancies between the C and C++ parser as to how
__attribute__ ((mode)) is handled.  On s390x-ibm-{tpf,linux}, we
use __attribute__ ((mode (SI))) with pointer types to declare 32-bit
pointer variables (the default pointer size is 64-bit).

The question is now how to express this syntactically.  Is there 
a document that formally specifies the syntax of the attribute
extension?  The info pages appear a bit vague ...

I had assumed the following:

typedef struct test * __attribute__ ((mode (SI))) test_ptr32;

would be the correct way to declare a SImode pointer type to
'struct test', if the placement of attribute is analogous to
'const' or 'volatile' -- it is 'test_ptr32' that is of mode
SImode, not '*test_ptr32'.

And indeed, this does have the effect I intended with the C
parser.  However, the C++ parser, while it accepts the above
construct, appears to simply ignore the attribute.

On the hand, *this* declaration:

typedef struct test __attribute__ ((mode (SI))) *test_ptr32;

*has* the effect I wanted to achieve (declaring test_ptr32
as an SImode pointer type) with the C++ parser.  Interestingly
enough, the C parser accepts this construct as well, with the
same effect as the first.

Is this intentional?  If not, which parser gets it right?

How would I declare a type like 'an SImode pointer to a
TImode integer'?

  Dr. Ulrich Weigand

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]