HomePhabricator

Add -Wctad-maybe-unsupported to diagnose CTAD on types with no user defined…

Description

Add -Wctad-maybe-unsupported to diagnose CTAD on types with no user defined deduction guides.

Summary:
Some style guides want to allow using CTAD only on types that "opt-in"; i.e. on types that are designed to support it and not just types that *happen* to work with it.

This patch implements the -Wctad-maybe-unsupported warning, which is off by default, which warns when CTAD is used on a type that does not define any deduction guides.

The following pattern can be used to suppress the warning in cases where the type intentionally doesn't define any deduction guides:

struct allow_ctad_t;

template <class T>
struct TestSuppression {
  TestSuppression(T) {}
};
TestSuppression(allow_ctad_t)->TestSuppression<void>; // guides with incomplete parameter types are never considered.

Reviewers: rsmith, james.dennett, gromer

Reviewed By: rsmith

Subscribers: jdennett, Quuxplusone, lebedev.ri, cfe-commits

Differential Revision: https://reviews.llvm.org/D56731

Details

Committed
EricWFJan 17 2019, 1:44 PM
Reviewer
rsmith
Differential Revision
D56731: Add -Wctad-maybe-unsupported to diagnose CTAD on types with no user defined deduction guides.
Branches
Unknown
Tags
Unknown