[PATCH] Fix for Bug 15290 - Segmentation fault during template instantiation

Ismail Pazarbasi ismail.pazarbasi at gmail.com
Mon Feb 25 06:38:46 PST 2013


Hi Richard,

> Great! Two things:
>
> 1) It would be a bit clearer to only check isFriendSpecified in the
> MemberContext case.
> 2) Please include some tests (the test from your original testcase plus the
> test from my reply would be fine).
>
> Then I'll check this fix in for you. Thanks!

Is there a reason static member functions are excluded from membership
check? The documentation and other uses of Sema::CXXThisScopeRAII
suggest that the purpose of IsCXX11MemberFunction variable is to allow
or disallow access to 'this' pointer. In terms of accessing 'this'
pointer, friend functions and static member functions are treated the
same.

Modified version of your example, when applied to template class (my
initial test), asserts at CXXMethodDecl::getThisType
(assert(isInstance() && "No 'this' for static methods!");) if check
for static is excluded from IsCXX11MemberFunction (i.e. check friend
function case only).

template<typename T>
struct foo {
  T v_;
  static int f() noexcept(noexcept(v_ + 42));
};

Because we are, again, transforming the expression into class member
access expression.

Two of the tests fail if I add check for static methods (i.e.
IsCXX11MemberFunction is false, if method is static). These are the
tests that were expected to fail, and now they pass. From
test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp:
namespace Static {
   struct X1 {
     int m;
    static auto f() -> decltype(m); // expected-error{{'this' cannot
be implicitly used in a static member function declaration}}
  };
}
m is an unevaluated operand; is this not legal? Is
IsCXX11MemberFunction used merely for name lookup purposes in
Parser::ParseFunctionDeclarator?

Thanks!



More information about the cfe-commits mailing list