summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2018-09-10 20:31:03 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2018-09-10 20:31:03 +0000
commit8eeb16f5d1008a3d3fc89e88d92b3bcebc36bba2 (patch)
tree515beea70adb40b91987b18587c4634a9ba4af7d /clang/lib/Sema/SemaInit.cpp
parent6dc896812423b7201492a116895df6c8c9601acf (diff)
downloadbcm5719-llvm-8eeb16f5d1008a3d3fc89e88d92b3bcebc36bba2.tar.gz
bcm5719-llvm-8eeb16f5d1008a3d3fc89e88d92b3bcebc36bba2.zip
Enhance -Wc++14-compat for class template argument deduction to list the
deduced type (if known). llvm-svn: 341858
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r--clang/lib/Sema/SemaInit.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 18a7aab1f5d..a25818f0fd3 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -9139,13 +9139,13 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer(
return QualType();
}
- Diag(TSInfo->getTypeLoc().getBeginLoc(),
- diag::warn_cxx14_compat_class_template_argument_deduction)
- << TSInfo->getTypeLoc().getSourceRange();
-
// Can't deduce from dependent arguments.
- if (Expr::hasAnyTypeDependentArguments(Inits))
+ if (Expr::hasAnyTypeDependentArguments(Inits)) {
+ Diag(TSInfo->getTypeLoc().getBeginLoc(),
+ diag::warn_cxx14_compat_class_template_argument_deduction)
+ << TSInfo->getTypeLoc().getSourceRange() << 0;
return Context.DependentTy;
+ }
// FIXME: Perform "exact type" matching first, per CWG discussion?
// Or implement this via an implied 'T(T) -> T' deduction guide?
@@ -9348,5 +9348,10 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer(
// C++ [dcl.type.class.deduct]p1:
// The placeholder is replaced by the return type of the function selected
// by overload resolution for class template deduction.
- return SubstAutoType(TSInfo->getType(), Best->Function->getReturnType());
+ QualType DeducedType =
+ SubstAutoType(TSInfo->getType(), Best->Function->getReturnType());
+ Diag(TSInfo->getTypeLoc().getBeginLoc(),
+ diag::warn_cxx14_compat_class_template_argument_deduction)
+ << TSInfo->getTypeLoc().getSourceRange() << 1 << DeducedType;
+ return DeducedType;
}
OpenPOWER on IntegriCloud