Correctly propagate the storage class to function template instantiations.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 16 Apr 2013 02:29:15 +0000 (02:29 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 16 Apr 2013 02:29:15 +0000 (02:29 +0000)
This fixes pr15753. This is another case of the fuzzy definition of the
"as written" storage class of an instantiation.

llvm-svn: 179581

clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/CodeGenCXX/pr15753.cpp [new file with mode: 0644]

index 2dbfeec..80c452f 100644 (file)
@@ -1162,7 +1162,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D,
   FunctionDecl *Function =
       FunctionDecl::Create(SemaRef.Context, DC, D->getInnerLocStart(),
                            D->getNameInfo(), T, TInfo,
-                           D->getStorageClass(),
+                           D->getCanonicalDecl()->getStorageClass(),
                            D->isInlineSpecified(), D->hasWrittenPrototype(),
                            D->isConstexpr());
 
diff --git a/clang/test/CodeGenCXX/pr15753.cpp b/clang/test/CodeGenCXX/pr15753.cpp
new file mode 100644 (file)
index 0000000..fd2000b
--- /dev/null
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+template <typename T> static int Foo(T t);
+template <typename T>
+int Foo(T t) {
+  return t;
+}
+template<> int Foo<int>(int i) {
+  return i;
+}
+
+// CHECK-NOT: define