[PATCH] D19175: Fix for PR27015 (variable template initialized with a generic lambda expression)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 28 13:17:46 PDT 2016


On Thu, Apr 28, 2016 at 1:14 PM, Akira Hatanaka via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> ahatanak added a comment.
>
> If I try calling Init(AnyParent, F) in Scope::setFlags, clang fails to
> compile the following code because it cannot find the definition of struct
> "foo":
>
>   void foo3(void)
>     struct foo {
>       int a, f;
>     };
>     char *np = nullptr;
>     int *ip = &(((struct foo *)np)->f);
>     *ip = 0;
>   }
>
> I can fix this test if I add a boolean flag to Scope::Init, which tells
> the function to return early before DeclsInScope and other fields are
> cleared.
>

Instead of adding the bool parameter to `Init`, how about this: move
`setFlags` out of line, move the parts of `Init` that compute things based
on the flags into `setFlags`, and call `setFlags` from `Init`.


> All the other tests pass too except for test/CXX/drs/dr1xx.cpp:
>
>   namespace dr183 { // dr183: sup 382
>     template<typename T> struct A {};
>     template<typename T> struct B {
>       typedef int X;
>     };
>     template<> struct A<int> {
>       typename B<int>::X x;
>     };
>   }
>
> clang used to compile this code without any warnings or errors, but it now
> issues the following warning if -std=c++98 is on the command line:
>
> dr1xx.cpp:7:5: warning: 'typename' occurs outside of a template
> [-Wc++11-extensions]
>
>   typename B<int>::X x;
>   ^~~~~~~~~
>
> 1 warning generated.
>
> Is clang correct to issue the warning in this case?


Yes.


> http://reviews.llvm.org/D19175
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160428/953a34f6/attachment.html>


More information about the cfe-commits mailing list