From 8eeb16f5d1008a3d3fc89e88d92b3bcebc36bba2 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 10 Sep 2018 20:31:03 +0000 Subject: Enhance -Wc++14-compat for class template argument deduction to list the deduced type (if known). llvm-svn: 341858 --- clang/lib/Sema/SemaInit.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'clang/lib/Sema/SemaInit.cpp') 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; } -- cgit v1.2.3