[cfe-commits] [Patch] PR11179 - Update StmtPrinter to not complain on some IntegerLiteral types

Richard Trieu rtrieu at google.com
Thu Oct 20 17:12:09 PDT 2011


On Thu, Oct 20, 2011 at 4:39 PM, Richard Smith <richard at metafoo.co.uk>wrote:

> On Fri, October 21, 2011 00:08, Richard Trieu wrote:
> > On Thu, Oct 20, 2011 at 2:53 PM, Richard Smith <richard at metafoo.co.uk
> >wrote:
> >> On Thu, October 20, 2011 22:06, Richard Trieu wrote:
> >>> Update Clang to not complain when printing IntegerLiterals with type
> >>> short, unsigned short, __int128_t, or __uint128_t.  This will fix
> PR11179.
> >>>
> >>> PR:
> >>> http://llvm.org/bugs/show_bug.cgi?id=11179
> >>>
> >>>
> >>> Patch also located at:
> >>> http://codereview.appspot.com/5309045/
> >>
> >> For __int128_t and __uint128_t, the approach looks fine (though the
> printed
> >>  value should include the "i128" or "Ui128" suffix).
> >
> > Are those the correct suffixes?  Clang and gcc doesn't recognize them as
> > valid integer constant suffixes.
>
> You need -fms-extensions to enable it. Without that extension, there's no
> way
> to write an __int128_t literal.
>
> Should Clang be printing suffixes that are accepted only with certain
flags?


> >> For short and unsigned short, it seems to me that this is a bug in
> >> Sema::BuildExpressionFromIntegralTemplateArgument: we shouldn't be
> creating
> >> IntegerLiteral AST nodes with those types (or with negative values, for
> >> that matter).
> >
> > Why can't an integer literal be short or negative?
>
> That's just how the C language family works: there's no way of writing an
> integer literal which is negative or short.
>
> While there is no way to write negative or short integers, Clang uses
integer literal to store information for other purposes.  For instance,
instantiated templates will store template arguments as an integer literal.
 If the template parameter is a short and the argument used is negative,
then an integer literal with a negative value and short type will be
created.


> Richard
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111020/c1b44e54/attachment.html>


More information about the cfe-commits mailing list