diff options
author | Eric Fiselier <eric@efcs.ca> | 2019-01-17 21:44:24 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2019-01-17 21:44:24 +0000 |
commit | 73b51ae160af6b94d4468331ff3fb6855cff3b18 (patch) | |
tree | b27bdad8e3d3de4d1d73c1a145e9b8ea6ea49341 /clang/include | |
parent | 4541be0686e682ea6e30933d9893fd2701b0e27f (diff) | |
download | bcm5719-llvm-73b51ae160af6b94d4468331ff3fb6855cff3b18.tar.gz bcm5719-llvm-73b51ae160af6b94d4468331ff3fb6855cff3b18.zip |
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
llvm-svn: 351484
Diffstat (limited to 'clang/include')
-rw-r--r-- | clang/include/clang/Basic/DiagnosticGroups.td | 2 | ||||
-rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 19e187cc5d9..568fbf1eee3 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -1050,3 +1050,5 @@ def NoDeref : DiagGroup<"noderef">; // A group for cross translation unit static analysis related warnings. def CrossTU : DiagGroup<"ctu">; + +def CTADMaybeUnsupported : DiagGroup<"ctad-maybe-unsupported">; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index b71f65d146c..a1029a22eb4 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2129,6 +2129,12 @@ def warn_cxx14_compat_class_template_argument_deduction : Warning< "class template argument deduction is incompatible with C++ standards " "before C++17%select{|; for compatibility, use explicit type name %1}0">, InGroup<CXXPre17Compat>, DefaultIgnore; +def warn_ctad_maybe_unsupported : Warning< + "%0 may not intend to support class template argument deduction">, + InGroup<CTADMaybeUnsupported>, DefaultIgnore; +def note_suppress_ctad_maybe_unsupported : Note< + "add a deduction guide to suppress this warning">; + // C++14 deduced return types def err_auto_fn_deduction_failure : Error< |