[cfe-commits] Bug 11709 Fix: va_list on ARM is not following AAPCS 7.1.4

Logan Chien tzuhsiang.chien at gmail.com
Thu Oct 18 01:40:44 PDT 2012


Hi,

  Here's another attempt to solve __builtin_va_arg issue.
In this patch, there is a special check for C++ and va_list as
record type:

  } else if (VaListType->isRecordType() && getLangOpts().CPlusPlus) {
    // If va_list is a record type and we are compiling under C++ mode,
    // then we should check the argument by copy assignment operator.
    InitializedEntity Entity
      = InitializedEntity::InitializeParameter(Context,
          Context.getLValueReferenceType(VaListType), false);
    ExprResult Init = PerformCopyInitialization(Entity, SourceLocation(),
E);
    if (Init.isInvalid())
      return ExprError();
    E = Init.takeAs<Expr>();

With this patch, I can get the same assembly result.  However, I'm not
familiar with InitializedEntity.  Please have a look.

Sincerely,
Logan


On Thu, Oct 18, 2012 at 9:22 AM, Eli Friedman <eli.friedman at gmail.com>wrote:

> On Wed, Oct 17, 2012 at 6:00 PM, Weiming Zhao <weimingz at codeaurora.org>
> wrote:
> > Hi Eli,
> >
> > Thanks for your info.
> >
> > Do you mean, in ActOnVAArg or BuildVAArgExpr, it needs
> > InitializationSequence, InitializedEntity if va_list is a record type?
> (I'm
> > not familiar with this)
>
> In C++, yes; it's the same sort of check we would perform if you
> called a function like "void f(va_list&);".  (In C, the existing check
> is fine.)
>
> A testcase would be to make sure we print a reasonable error message
> for the following in C++:
>
> __builtin_va_list a();
> int b() {
>   return __builtin_va_arg(a(), int);
> }
>
> -Eli
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121018/f2bb28ee/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-__builtin_va_arg-assertion-failure-in-ARM-AAPCS.patch
Type: application/octet-stream
Size: 2866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121018/f2bb28ee/attachment.obj>


More information about the cfe-commits mailing list