]> granicus.if.org Git - clang/commit
Add -Wctad-maybe-unsupported to diagnose CTAD on types with no user defined deduction...
authorEric Fiselier <eric@efcs.ca>
Thu, 17 Jan 2019 21:44:24 +0000 (21:44 +0000)
committerEric Fiselier <eric@efcs.ca>
Thu, 17 Jan 2019 21:44:24 +0000 (21:44 +0000)
commit8abc38eefae434edc7fc43ab41086bfccb0641e3
treec0fc99e81741caaf0e82ebe40311ced8dbf846e5
parent025ee129ac0bfc0cad76eb6ac14bab9c1343b4ea
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351484 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticGroups.td
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaInit.cpp
test/SemaCXX/cxx1z-class-template-argument-deduction.cpp