[cfe-commits] r59331 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def include/clang/Parse/DeclSpec.h lib/Parse/DeclSpec.cpp lib/Parse/ParseDecl.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclCXX.cpp test/Parser/cxx-class.cpp test/SemaCXX/class.cpp www/cxx_status.html

Chris Lattner clattner at apple.com
Mon Nov 17 17:03:20 PST 2008


On Nov 17, 2008, at 3:12 PM, Sebastian Redl wrote:

> Chris Lattner wrote:
>>
>> On Nov 14, 2008, at 3:42 PM, Sebastian Redl wrote:
>>
>>> +    case DeclSpec::SCS_mutable:
>>> +      // mutable can only appear on non-static class members, so  
>>> it's always
>>> +      // an error here
>>> +      Diag(D.getIdentifierLoc(), diag::err_mutable_nonmember);
>>> +      InvalidDecl = true;
>>> +    }
>>
>> Please use an explicit break here, even though it isn't strictly  
>> needed.
> Of course. I'd never intentionally omit a break.
>>> +    case DeclSpec::SCS_mutable:
>>> +      if (isFunc) {
>>> +        if (DS.getStorageClassSpecLoc().isValid())
>>> +          Diag(DS.getStorageClassSpecLoc(),
>>> +               diag::err_mutable_function);
>>> +        else
>>> +          Diag(DS.getThreadSpecLoc(),
>>> +               diag::err_mutable_function);
>>> +        D.getMutableDeclSpec().ClearStorageClassSpecs();
>>
>> How does this work for things like:
>>
>>  mutable int Y(), X;
>> or:
>>  mutable int &Y, X;
>>
>> I guess it isn't the end of the world :), but it seems that it  
>> could cause spurious diagnostics in these cases by removing  
>> mutability from X.  Is it possible to recover by eliminating  
>> mutable from just Y?
> Yes, but at some effort. We would have to set a flag here and pass  
> it along to the function that actually creates the CXXFieldDecl  
> (ActOnField), so that it can ignore the mutable storage class.
> ActOnField, however, is a method of Action, so we shouldn't just add  
> a parameter to it that is an implementation detail of Sema. So we'd  
> have to create a new function that has this parameter and make  
> ActOnField a thin wrapper around it.
>
> I'll add a FIXME for now. I can do this I have some time with  
> nothing better to do.

Ok, seems fine with me.  Thanks Sebastian!

-Chris



More information about the cfe-commits mailing list