]> granicus.if.org Git - clang/commitdiff
Look through parenthesized declarators when determining whether an
authorDouglas Gregor <dgregor@apple.com>
Tue, 5 Jul 2011 18:30:26 +0000 (18:30 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 5 Jul 2011 18:30:26 +0000 (18:30 +0000)
instantiated function template was written with a prototype or via
some kind of typedef. Fixes PR10273 / <rdar://problem/9723679>.

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

lib/Sema/SemaTemplateInstantiateDecl.cpp
test/SemaTemplate/instantiate-function-2.cpp

index b6d5abfcc819d6223ea3c0f0bd15f5949ac39c4f..0a05d0e3042a90b7ca49f7715803c129b4e84198 100644 (file)
@@ -1090,7 +1090,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D,
   Function->setLexicalDeclContext(LexicalDC);
 
   // Attach the parameters
-  if (isa<FunctionProtoType>(Function->getType())) {
+  if (isa<FunctionProtoType>(Function->getType().IgnoreParens())) {
     // Adopt the already-instantiated parameters into our own context.
     for (unsigned P = 0; P < Params.size(); ++P)
       if (Params[P])
index 21eccd49013914e9cfdd9970d69f9e56dc759321..087ede2b89cbbc1028b3bed96fa4d3c789075265 100644 (file)
@@ -56,3 +56,11 @@ namespace AliasTagDef {
 
   int n = f<int>();
 }
+
+namespace PR10273 {
+  template<typename T> void (f)(T t) {}
+
+  void g() {
+    (f)(17);
+  }
+}