[LLVMdev] Clang source question around failing MSVC build

Gaster, Benedict Benedict.Gaster at amd.com
Mon Jul 13 12:42:35 PDT 2009


ParseDecl.cpp fails to compile with MSVC reporting the following error:

 

ParseDecl.cpp

compiler\llvm\tools\clang\lib\Parse\ParseDecl.cpp(2760) : error C2248: 'clang::A

STOwningResult<Destroyer>::operator =' : cannot access private member declared i

n class 'clang::ASTOwningResult<Destroyer>'

        with

        [

            Destroyer=::up▲

        ]

        compiler¥llvm¥tools¥clang¥include¥clang/Parse/Ownership.h(411) : see dec

laration of 'clang::ASTOwningResult<Destroyer>::operator ='

        with

        [

            Destroyer=::up▲

        ]

 

The problems comes with the following code:

 

} else if (Tok.isNot(tok::r_square)) {

    // Note, in C89, this production uses the constant-expr production instead

    // of assignment-expr.  The only difference is that assignment-expr allows

    // things like '=' and '*='.  Sema rejects these in C89 mode because they

    // are not i-c-e's, so we don't need to distinguish between the two here.

    

    // Parse the constant-expression or assignment-expression now (depending

    // on dialect).

    if (getLang().CPlusPlus)

      NumElements = ParseConstantExpression();

    else

      NumElements = ParseAssignmentExpression();

  }

 

As far as I can tell this code should not compile because of the following code from Ownership.h: 

 

template <ASTDestroyer Destroyer>

  class ASTOwningResult

  {

   …

    ASTOwningResult(ASTOwningResult&); // DO NOT IMPLEMENT

    ASTOwningResult& operator =(ASTOwningResult&); // DO NOT IMPLEMENT

 

Both the copy constructor and assignment operator are no implemented and restricted.

 

A fix for this seems to be:

 

} else if (Tok.isNot(tok::r_square)) {

    // Note, in C89, this production uses the constant-expr production instead

    // of assignment-expr.  The only difference is that assignment-expr allows

    // things like '=' and '*='.  Sema rejects these in C89 mode because they

    // are not i-c-e's, so we don't need to distinguish between the two here.

    

    // Parse the constant-expression or assignment-expression now (depending

    // on dialect).

    if (getLang().CPlusPlus)

      NumElements = OwningExprResult(ParseAssignmentExpression());

    else

      NumElements = OwningExprResult(ParseAssignmentExpression());

  }

 

Is this correct or have I missed something?

 

Many thanks,

 

Ben

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090713/bd3db65a/attachment.html>


More information about the llvm-dev mailing list