Author: dblaikie
Date: Fri Apr 19 16:04:05 2019
New Revision: 358796

URL: http://llvm.org/viewvc/llvm-project?rev=358796&view=rev
Log:
Modules: Adopt template parameters for variable templates to set their decl 
context correctly

Exposed by a related bug about visibility of default arguments of nested
templates - without the correct decl context, default template
parameters of variable templates nested in classes would have incorrect
visibility computed.

Modified:
    cfe/trunk/lib/AST/DeclTemplate.cpp
    cfe/trunk/test/Modules/nested-template-default-arg-redecl.cpp

Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=358796&r1=358795&r2=358796&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Fri Apr 19 16:04:05 2019
@@ -956,6 +956,7 @@ VarTemplateDecl *VarTemplateDecl::Create
                                          SourceLocation L, DeclarationName 
Name,
                                          TemplateParameterList *Params,
                                          VarDecl *Decl) {
+  AdoptTemplateParameterList(Params, DC);
   return new (C, DC) VarTemplateDecl(C, DC, L, Name, Params, Decl);
 }
 

Modified: cfe/trunk/test/Modules/nested-template-default-arg-redecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/nested-template-default-arg-redecl.cpp?rev=358796&r1=358795&r2=358796&view=diff
==============================================================================
--- cfe/trunk/test/Modules/nested-template-default-arg-redecl.cpp (original)
+++ cfe/trunk/test/Modules/nested-template-default-arg-redecl.cpp Fri Apr 19 
16:04:05 2019
@@ -1,18 +1,16 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -x c++ -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t \
 // RUN:     -I %S/Inputs/nested-template-default-arg-redecl -std=c++14 \
-// RUN:     -fmodules-local-submodule-visibility -verify %s
+// RUN:     -fmodules-local-submodule-visibility -w -verify %s
+
+// expected-no-diagnostics
+
 #include "alias2.h"
 #include "var2.h"
 #include "strct2.h"
 #include "func2.h"
 
-// FIXME: Variable templates lexical decl context appears to be the translation
-// unit, which is incorrect. Fixing this will hopefully address the following
-// error/bug:
-
-// expected-note@Inputs/nested-template-default-arg-redecl/var.h:4 {{default 
argument declared here}}
-auto var = &var_outer::var<>; // expected-error {{default argument of 'var' 
must be imported from module 'VAR1' before it is required}}
+auto var = &var_outer::var<>;
 auto func = &func_outer::func<>;
 strct_outer::strct<> *strct;
 alias_outer::alias<> *alias;


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to