This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Fix an error with C++17 auto non-type template parameters
ClosedPublic

Authored by erik.pilkington on Jul 31 2018, 10:56 AM.

Details

Summary

Clang used to error out on the following test case because we were forming a deduced-to-undeduced AutoType, which CheckNonTypeTemplateParameterType can't handle.

template <auto V> struct G {};

template <class T> struct S {
  template <auto V> void f() {
    G<V> x; // (incorrect) error while checking template parameter types
  }
};

The problem here was that CurrentInstantiationRebuilder TreeTransform'd the auto template parameter type of G, which strips away the type-dependent bit (see TreeTransform::RebuildAutoType) which was previously set by CheckNonTypeTemplateParameterType. This patch recovers this information by substituting in the dependent type again. This is a very similar fix to r290660.

rdar://41852459

Thanks for taking a look!
Erik

Diff Detail

Repository
rC Clang

Event Timeline

erik.pilkington retitled this revision from [Sema] Dig through AutoTypes that have been deduced to an undeduced AutoType in Type::isUndeducedType to [Sema] Fix an error with C++17 auto non-type template parameters.
erik.pilkington edited the summary of this revision. (Show Details)

New patch uses a different approach to fix this. I edited the summary/title to explain. Sorry for the flip-flop!

rsmith accepted this revision.Aug 7 2018, 3:20 PM
This revision is now accepted and ready to land.Aug 7 2018, 3:20 PM
rsmith added a comment.Aug 7 2018, 3:21 PM

Can you also add a test where the auto is not top-level (eg, template<auto *P>) and a test using decltype(auto)?

This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.