[llvm-branch-commits] [clang] b39efdb - [Concepts] Fix incorrect TemplateArgs for introduction of local parameters

Saar Raz via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Jan 26 15:00:44 PST 2020


Author: Saar Raz
Date: 2020-01-27T01:00:12+02:00
New Revision: b39efdbcfcb7c7a5e867a99c2d3e756c538fbb9f

URL: https://github.com/llvm/llvm-project/commit/b39efdbcfcb7c7a5e867a99c2d3e756c538fbb9f
DIFF: https://github.com/llvm/llvm-project/commit/b39efdbcfcb7c7a5e867a99c2d3e756c538fbb9f.diff

LOG: [Concepts] Fix incorrect TemplateArgs for introduction of local parameters

The wrong set of TemplateArgs was being provided to addInstantiatedParametersToScope.
Caused bug #44658.

(cherry picked from commit 9c24fca2a33fc0fd059e278bb95c84803dfff9ae)

Added: 
    

Modified: 
    clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
    clang/test/SemaTemplate/instantiate-requires-clause.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index fbbab8f00703..2e437cbe44d3 100755
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4246,18 +4246,17 @@ bool Sema::CheckInstantiatedFunctionTemplateConstraints(
   Sema::ContextRAII savedContext(*this, Decl);
   LocalInstantiationScope Scope(*this);
 
-  MultiLevelTemplateArgumentList MLTAL =
-    getTemplateInstantiationArgs(Decl, nullptr, /*RelativeToPrimary*/true);
-
   // If this is not an explicit specialization - we need to get the instantiated
   // version of the template arguments and add them to scope for the
   // substitution.
   if (Decl->isTemplateInstantiation()) {
     InstantiatingTemplate Inst(*this, Decl->getPointOfInstantiation(),
         InstantiatingTemplate::ConstraintsCheck{}, Decl->getPrimaryTemplate(),
-        MLTAL.getInnermost(), SourceRange());
+        TemplateArgs, SourceRange());
     if (Inst.isInvalid())
       return true;
+    MultiLevelTemplateArgumentList MLTAL(
+        *Decl->getTemplateSpecializationArgs());
     if (addInstantiatedParametersToScope(
             *this, Decl, Decl->getPrimaryTemplate()->getTemplatedDecl(),
             Scope, MLTAL))

diff  --git a/clang/test/SemaTemplate/instantiate-requires-clause.cpp b/clang/test/SemaTemplate/instantiate-requires-clause.cpp
index 31cf484d564c..8e9d5bffa906 100644
--- a/clang/test/SemaTemplate/instantiate-requires-clause.cpp
+++ b/clang/test/SemaTemplate/instantiate-requires-clause.cpp
@@ -51,3 +51,10 @@ struct S2 {
 
 static_assert((S2<int>::f(), true));
 
+template<typename T>
+struct S3 {
+	template<typename... Args> requires true
+	static constexpr void f(Args...) { }
+};
+
+static_assert((S3<int>::f(), true));
\ No newline at end of file


        


More information about the llvm-branch-commits mailing list