[cfe-commits] r172375 - in /cfe/trunk: lib/Parse/ParseDecl.cpp test/Parser/cxx0x-decl.cpp

Jordan Rose jordan_rose at apple.com
Mon Jan 14 09:43:07 PST 2013


Oops, later commit reminded me that this is happening before the member function has been fully declared yet. Carry on.


On Jan 14, 2013, at 9:40 , Jordan Rose <jordan_rose at apple.com> wrote:

> Aren't constexpr member functions implicitly const? Is there a reason that we're not modeling that in the AST?
> 
> 
> On Jan 13, 2013, at 17:55 , Richard Smith <richard-llvm at metafoo.co.uk> wrote:
> 
>> Author: rsmith
>> Date: Sun Jan 13 19:55:13 2013
>> New Revision: 172375
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=172375&view=rev
>> Log:
>> *this is const in a trailing-return-type for a constexpr member function.
>> 
>> Modified:
>>   cfe/trunk/lib/Parse/ParseDecl.cpp
>>   cfe/trunk/test/Parser/cxx0x-decl.cpp
>> 
>> Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=172375&r1=172374&r2=172375&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
>> +++ cfe/trunk/lib/Parse/ParseDecl.cpp Sun Jan 13 19:55:13 2013
>> @@ -4761,7 +4761,9 @@
>>          Actions.CurContext->isRecord()));
>>      Sema::CXXThisScopeRAII ThisScope(Actions,
>>                               dyn_cast<CXXRecordDecl>(Actions.CurContext),
>> -                               DS.getTypeQualifiers(),
>> +                               DS.getTypeQualifiers() |
>> +                               (D.getDeclSpec().isConstexprSpecified()
>> +                                  ? Qualifiers::Const : 0),
>>                               IsCXX11MemberFunction);
>> 
>>      // Parse exception-specification[opt].
>> 
>> Modified: cfe/trunk/test/Parser/cxx0x-decl.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-decl.cpp?rev=172375&r1=172374&r2=172375&view=diff
>> ==============================================================================
>> --- cfe/trunk/test/Parser/cxx0x-decl.cpp (original)
>> +++ cfe/trunk/test/Parser/cxx0x-decl.cpp Sun Jan 13 19:55:13 2013
>> @@ -41,3 +41,11 @@
>> };
>> 
>> using PR14855 = int S::; // expected-error {{expected ';' after alias declaration}}
>> +
>> +// Ensure that 'this' has a const-qualified type in a trailing return type for
>> +// a constexpr function.
>> +struct ConstexprTrailingReturn {
>> +  int n;
>> +  constexpr auto f() -> decltype((n));
>> +};
>> +constexpr const int &ConstexprTrailingReturn::f() const { return n; }
>> 
>> 
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 




More information about the cfe-commits mailing list