]> granicus.if.org Git - clang/commitdiff
Fix assert when instantiating a default argument of a template defined in a
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 1 Aug 2013 04:12:04 +0000 (04:12 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 1 Aug 2013 04:12:04 +0000 (04:12 +0000)
module.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187556 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Decl.cpp
test/Modules/Inputs/cxx-templates-a.h
test/Modules/cxx-templates.cpp

index 4ecb41b3f0b77f389fd56c42cef67a97946b0e21..772f7353c362e65643aac19c40a4ebe7f8e89075 100644 (file)
@@ -1959,7 +1959,10 @@ TemplateSpecializationKind VarDecl::getTemplateSpecializationKind() const {
 }
 
 MemberSpecializationInfo *VarDecl::getMemberSpecializationInfo() const {
-  return getASTContext().getInstantiatedFromStaticDataMember(this);
+  if (isStaticDataMember())
+    return getASTContext().getInstantiatedFromStaticDataMember(this);
+
+  return 0;
 }
 
 void VarDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK,
index cc83d7bc034012ddce0017b92939d0cc34a4938c..aaafc1b1bdb46f85c5afeeb959c1633b8336692b 100644 (file)
@@ -20,3 +20,5 @@ template<typename T> void PerformDelayedLookup(T &t) {
   typename T::Inner inner;
   FoundByADL(t);
 }
+
+template<typename T> void PerformDelayedLookupInDefaultArgument(T &t, int a = (FoundByADL(T()), 0)) {}
index bb8ba034be17e6b2a384f9a2b3b21d45a28e4bd4..79052dd34bb19274db7f7220cfc66ca24ae9d396 100644 (file)
@@ -51,6 +51,9 @@ void g() {
   // 'common'. That type is not visible here.
   PerformDelayedLookup(defined_in_common);
 
+  // Likewise, but via a default argument.
+  PerformDelayedLookupInDefaultArgument(defined_in_common);
+
   // Trigger the instantiation of a template in 'b' that uses a type defined in
   // 'b_impl'. That type is not visible here.
   UseDefinedInBImpl<int>();