summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-01-17 02:14:37 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-01-17 02:14:37 +0000
commit957fbf1f9f739d97811c3c335eb03f93221cc49e (patch)
treed0b109adaa78d07b30a9366923aa8093c8351e21 /clang/lib
parent51aff488e5bc382fbfdcac5bf566fbbbe05b31ab (diff)
downloadbcm5719-llvm-957fbf1f9f739d97811c3c335eb03f93221cc49e.tar.gz
bcm5719-llvm-957fbf1f9f739d97811c3c335eb03f93221cc49e.zip
Partial revert of r290511.
The rules around typechecking deduced template arguments during partial ordering are not clear, and while the prior behavior does not seem to be correct (it doesn't follow the general model of partial ordering where each template parameter is replaced by a non-dependent but unique value), the new behavior is also not clearly right and breaks some existing idioms. The new behavior is retained for dealing with non-type template parameters with 'auto' types, as without it even the most basic uses of that feature don't work. We can revisit this once CWG has come to an agreement on how partial ordering with 'auto' non-type template parameters is supposed to work. llvm-svn: 292183
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 1c19f67cb0f..2920ede3b5e 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -5123,18 +5123,22 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
if (CTAK == CTAK_Deduced &&
!Context.hasSameType(ParamType.getNonLValueExprType(Context),
Arg->getType())) {
- // C++ [temp.deduct.type]p17: (DR1770)
- // If P has a form that contains <i>, and if the type of i differs from
- // the type of the corresponding template parameter of the template named
- // by the enclosing simple-template-id, deduction fails.
- //
- // Note that CTAK will be CTAK_DeducedFromArrayBound if the form was [i]
- // rather than <i>.
- //
- // FIXME: We interpret the 'i' here as referring to the expression
- // denoting the non-type template parameter rather than the parameter
- // itself, and so strip off references before comparing types. It's
- // not clear how this is supposed to work for references.
+ // FIXME: If either type is dependent, we skip the check. This isn't
+ // correct, since during deduction we're supposed to have replaced each
+ // template parameter with some unique (non-dependent) placeholder.
+ // FIXME: If the argument type contains 'auto', we carry on and fail the
+ // type check in order to force specific types to be more specialized than
+ // 'auto'. It's not clear how partial ordering with 'auto' is supposed to
+ // work.
+ if ((ParamType->isDependentType() || Arg->isTypeDependent()) &&
+ !Arg->getType()->getContainedAutoType()) {
+ Converted = TemplateArgument(Arg);
+ return Arg;
+ }
+ // FIXME: This attempts to implement C++ [temp.deduct.type]p17. Per DR1770,
+ // we should actually be checking the type of the template argument in P,
+ // not the type of the template argument deduced from A, against the
+ // template parameter type.
Diag(StartLoc, diag::err_deduced_non_type_template_arg_type_mismatch)
<< Arg->getType()
<< ParamType.getUnqualifiedType();
OpenPOWER on IntegriCloud