Page MenuHomePhabricator

Partial specialization after class template instantiation.
Needs ReviewPublic

Authored by AntonBikineev on Oct 12 2014, 7:44 AM.

Details

Reviewers
rsmith

Diff Detail

Event Timeline

AntonBikineev retitled this revision from to Partial specialization after class template instantiation..
AntonBikineev updated this object.
AntonBikineev edited the test plan for this revision. (Show Details)
AntonBikineev added reviewers: rsmith, nikola.
AntonBikineev added a subscriber: Unknown Object (MLST).
nikola edited edge metadata.Oct 12 2014, 10:16 PM

It looks good ignoring two style nitpicks. I'll have more confidence when you add the test for this, code review can stay open until you get to it.

lib/Sema/SemaTemplate.cpp
6226

const auto *

6234

Same here.

majnemer added inline comments.
lib/Sema/SemaTemplate.cpp
6228–6229

It would probably be more concise to do:

for (ClassTemplateSpecializationDecl &S : ClassTemplate.specializations())

In case const auto * deduced type has different meaning (pointer to constant), so it doesn’t compile.

You can drop the const altogether, we know that the pointer won't change.

AntonBikineev edited edge metadata.

some notes have been applied;
some tests have been added.
feel free to suggest some new test cases.

rsmith added inline comments.Oct 24 2014, 12:54 PM
../llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
3395 ↗(On Diff #14872)

Please use partial_spec or partial_specialization rather than part_specialization, like other diagnostics do.

../llvm/tools/clang/lib/Sema/SemaTemplate.cpp
6225 ↗(On Diff #14872)

We don't need these checks for a redeclaration:

if (isPartialSpecialization && !PrevDecl) {
6227 ↗(On Diff #14872)

Use cast, not static_cast, here. (It'll assert if the type doesn't match.)

6232 ↗(On Diff #14872)

Hmm, what happens if we get an error outside of the immediate context during this deduction? Are we allowed to reject the program for that reason?

For instance:

template<typename T> struct X { typedef typename T::type type; };
template<typename T, typename U> struct A {};
A<int, int> Aint;
template<typename T> struct A<T, typename X<T>::type> {};

Do we provide a sufficiently useful template instantiation backtrace in this case?

Applied some comments

nikola resigned from this revision.Dec 13 2015, 6:54 PM
nikola removed a reviewer: nikola.

@rsmith, are there any plans/suggestions regarding this patch?