[llvm] r308599 - [globalisel][tablegen] Fix an issue with lambdas when compiling with older GCC's

Daniel Sanders via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 31 07:15:50 PDT 2017


> On 24 Jul 2017, at 22:31, David Blaikie <dblaikie at gmail.com> wrote:
> 
> 
> 
> On Thu, Jul 20, 2017 at 3:25 AM Daniel Sanders via llvm-commits <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>> wrote:
> Author: dsanders
> Date: Thu Jul 20 03:25:00 2017
> New Revision: 308599
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=308599&view=rev <http://llvm.org/viewvc/llvm-project?rev=308599&view=rev>
> Log:
> [globalisel][tablegen] Fix an issue with lambdas when compiling with older GCC's
> 
> It seems that G++ 4.8 doesn't accept the 'enum A' in code of the form:
>   enum A { ... };
>   const auto &F = []() -> enum A { ... };
> However, it does accept:
>   typedef enum { ... } A;
>   const auto &F = []() -> A { ... };
> 
> What if you drop the 'enum' keyword but don't modify the definition of A (leaving it 'enum A { ... }'). The 'typedef enum { ... } A' stuff is generally only needed in C (in C++ you don't need the 'enum' or 'struct' prefix to refer to an enum/struct type, even without the typedef).

That works on G++ 4.8 too. If there's a preference then I'm happy to change it.

> 
> 
> Modified:
>     llvm/trunk/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h
> 
> Modified: llvm/trunk/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h?rev=308599&r1=308598&r2=308599&view=diff <http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h?rev=308599&r1=308598&r2=308599&view=diff>
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h Thu Jul 20 03:25:00 2017
> @@ -29,8 +29,8 @@ bool InstructionSelector::executeMatchTa
>    uint64_t CurrentIdx = 0;
>    SmallVector<uint64_t, 8> OnFailResumeAt;
> 
> -  enum RejectAction { RejectAndGiveUp, RejectAndResume };
> -  auto handleReject = [&]() -> enum RejectAction {
> +  typedef enum { RejectAndGiveUp, RejectAndResume } RejectAction;
> +  auto handleReject = [&]() -> RejectAction {
>      DEBUG(dbgs() << CurrentIdx << ": Rejected\n");
>      if (OnFailResumeAt.empty())
>        return RejectAndGiveUp;
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170731/044d3a50/attachment.html>


More information about the llvm-commits mailing list