This is an archive of the discontinued LLVM Phabricator instance.

Check default arguments of template template parameters for compatibility.
Needs ReviewPublic

Authored by faisalv on Mar 26 2016, 5:25 PM.

Details

Reviewers
rsmith
Summary

I'm not sure why this check wasn't being done at template definition time.
I can't devise a test case to trigger the concerns in the deleted comments below.

Anything I might be missing by simply adding the CheckTemplateArgument check here?

Thanks!

Diff Detail

Event Timeline

faisalv updated this revision to Diff 51725.Mar 26 2016, 5:25 PM
faisalv retitled this revision from to Check default arguments of template template parameters for compatibility..
faisalv updated this object.
faisalv added a reviewer: rsmith.
faisalv added a subscriber: cfe-commits.
rsmith added inline comments.Mar 26 2016, 9:31 PM
lib/Sema/SemaTemplate.cpp
793–800

You don't appear to have added any test coverage for these cases. Are there existing tests for this? Something like:

template<typename T, template<T> typename A>
struct X {
  template<template<int> typename = A> struct Y {};
};

Similar cases exist where the template template parameter has a parameter pack and is used as a default template argument for a template template parameter that takes a non-pack.

test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp
73–74

This looks like a rejects-valid. Consider:

template<int, class> struct Q;
A<Q>::B<int> b;

Here, TT refers to Q, which is valid as a template template argument for parameter UU.

faisalv marked 2 inline comments as done.Mar 27 2016, 9:14 AM
faisalv added inline comments.
lib/Sema/SemaTemplate.cpp
793–800

Thanks for the example - I was struggling with conjuring an example that would represent the concerns expressed in those comments. Example added to test suite.

test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp
73–74

Aah yes - nice example - I agree this should work. Please see revision patch.

faisalv updated this revision to Diff 51742.Mar 27 2016, 9:32 AM
faisalv marked 2 inline comments as done.

Updated the patch with the following:

  • while checking dependent template template arguments at template definition time, we must accept the more general (pack) as compatible with the more specific (non-pack sequence), since the instantiation time check will preserve the compatibility between template parameter lists (for a subset of pack-expansions compatible with the non-pack sequences) mandated by the standard.
  • added Richard's examples.

Thanks!