r256651 - Implement [temp.deduct.type]p6: if the nested-name-specifier of a type is
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 30 12:56:05 PST 2015
Author: rsmith
Date: Wed Dec 30 14:56:05 2015
New Revision: 256651
URL: http://llvm.org/viewvc/llvm-project?rev=256651&view=rev
Log:
Implement [temp.deduct.type]p6: if the nested-name-specifier of a type is
dependent, the type is a non-deduced context.
Modified:
cfe/trunk/include/clang/AST/DeclarationName.h
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/SemaTemplate/deduction.cpp
Modified: cfe/trunk/include/clang/AST/DeclarationName.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclarationName.h?rev=256651&r1=256650&r2=256651&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclarationName.h (original)
+++ cfe/trunk/include/clang/AST/DeclarationName.h Wed Dec 30 14:56:05 2015
@@ -395,7 +395,7 @@ struct DeclarationNameLoc {
// Locations (if any) for the tilde (destructor) or operator keyword
// (conversion) are stored elsewhere.
struct NT {
- TypeSourceInfo* TInfo;
+ TypeSourceInfo *TInfo;
};
// The location (if any) of the operator keyword is stored elsewhere.
Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=256651&r1=256650&r2=256651&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Wed Dec 30 14:56:05 2015
@@ -4887,19 +4887,23 @@ MarkUsedTemplateParameters(ASTContext &C
break;
case Type::DependentTemplateSpecialization: {
+ // C++14 [temp.deduct.type]p5:
+ // The non-deduced contexts are:
+ // -- The nested-name-specifier of a type that was specified using a
+ // qualified-id
+ //
+ // C++14 [temp.deduct.type]p6:
+ // When a type name is specified in a way that includes a non-deduced
+ // context, all of the types that comprise that type name are also
+ // non-deduced.
+ if (OnlyDeduced)
+ break;
+
const DependentTemplateSpecializationType *Spec
= cast<DependentTemplateSpecializationType>(T);
- if (!OnlyDeduced)
- MarkUsedTemplateParameters(Ctx, Spec->getQualifier(),
- OnlyDeduced, Depth, Used);
- // C++0x [temp.deduct.type]p9:
- // If the template argument list of P contains a pack expansion that is not
- // the last template argument, the entire template argument list is a
- // non-deduced context.
- if (OnlyDeduced &&
- hasPackExpansionBeforeEnd(Spec->getArgs(), Spec->getNumArgs()))
- break;
+ MarkUsedTemplateParameters(Ctx, Spec->getQualifier(),
+ OnlyDeduced, Depth, Used);
for (unsigned I = 0, N = Spec->getNumArgs(); I != N; ++I)
MarkUsedTemplateParameters(Ctx, Spec->getArg(I), OnlyDeduced, Depth,
Modified: cfe/trunk/test/SemaTemplate/deduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/deduction.cpp?rev=256651&r1=256650&r2=256651&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/deduction.cpp (original)
+++ cfe/trunk/test/SemaTemplate/deduction.cpp Wed Dec 30 14:56:05 2015
@@ -207,3 +207,14 @@ namespace PR18645 {
template<typename F> F Quux(F &&f);
auto Baz = Quux(Quux<float>);
}
+
+namespace NonDeducedNestedNameSpecifier {
+ template<typename T> struct A {
+ template<typename U> struct B {
+ B(int) {}
+ };
+ };
+
+ template<typename T> int f(A<T>, typename A<T>::template B<T>);
+ int k = f(A<int>(), 0);
+}
More information about the cfe-commits
mailing list