r236063 - PR20625: Instantiate static constexpr member function of a local struct in a function template earlier.

Richard Smith richard at metafoo.co.uk
Wed Apr 29 10:51:38 PDT 2015


Reverted for now in r236134.

On Wed, Apr 29, 2015 at 10:37 AM, Reid Kleckner <rnk at google.com> wrote:

> This broke ASTMatcherTests HasAncestor.MatchesClosestAncestor on Windows:
>
> http://lab.llvm.org:8011/builders/clang-x86-win2008-selfhost/builds/540/steps/ninja%20check%202/logs/FAIL%3A%20Clang-Unit%3A%3AHasAncestor.MatchesClosestAncestor
> Assertion failed: getContainingDC(DC) == CurContext && "The next
> DeclContext should be lexically contained in the current one.", file
> C:\buildbot\slave-config\clang-x86-win2008-selfhost\llvm\tools\clang\lib\Sema\SemaDecl.cpp,
> line 1073
>
> I have a feeling there are bugs here with -fdelayed-template-parsing that
> can be easily exercised in a lit test.
>
> On Tue, Apr 28, 2015 at 5:07 PM, Richard Smith <richard-llvm at metafoo.co.uk
> > wrote:
>
>> Author: rsmith
>> Date: Tue Apr 28 19:07:09 2015
>> New Revision: 236063
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=236063&view=rev
>> Log:
>> PR20625: Instantiate static constexpr member function of a local struct
>> in a function template earlier.
>>
>> This is necessary in order to allow the use of a constexpr member
>> function, or
>> a member function with deduced return type, of a local class within a
>> surrounding instantiated function template specialization.
>>
>> Patch by Michael Park!
>>
>> Modified:
>>     cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>>     cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=236063&r1=236062&r2=236063&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Tue Apr 28
>> 19:07:09 2015
>> @@ -1302,11 +1302,19 @@ Decl *TemplateDeclInstantiator::VisitCXX
>>    // DR1484 clarifies that the members of a local class are instantiated
>> as part
>>    // of the instantiation of their enclosing entity.
>>    if (D->isCompleteDefinition() && D->isLocalClass()) {
>> +    Sema::SavePendingLocalImplicitInstantiationsRAII
>> +        SavedPendingLocalImplicitInstantiations(SemaRef);
>> +
>>      SemaRef.InstantiateClass(D->getLocation(), Record, D, TemplateArgs,
>>                               TSK_ImplicitInstantiation,
>>                               /*Complain=*/true);
>> +
>>      SemaRef.InstantiateClassMembers(D->getLocation(), Record,
>> TemplateArgs,
>>                                      TSK_ImplicitInstantiation);
>> +
>> +    // This class may have local implicit instantiations that need to be
>> +    // performed within this scope.
>> +    SemaRef.PerformPendingInstantiations(/*LocalOnly=*/true);
>>    }
>>
>>    SemaRef.DiagnoseUnusedNestedTypedefs(Record);
>>
>> Modified: cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp?rev=236063&r1=236062&r2=236063&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp (original)
>> +++ cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp Tue Apr 28
>> 19:07:09 2015
>> @@ -213,3 +213,16 @@ namespace PR23194 {
>>      return make_seed_pair();
>>    }
>>  }
>> +
>> +namespace PR20625 {
>> +template <typename T>
>> +void f() {
>> +  struct N {
>> +    static constexpr int get() { return 42; }
>> +  };
>> +  constexpr int n = N::get();
>> +  static_assert(n == 42, "n == 42");
>> +}
>> +
>> +void g() { f<void>(); }
>> +}
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150429/d8002cfe/attachment.html>


More information about the cfe-commits mailing list