From f4966557bedd375dbf0909c8d94e092ddf0dc8de Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 18 Nov 2013 22:40:04 +0000 Subject: [PATCH] The attached patch is a follow up from my previous one. The existing logic was not handling typedefs as free functions. This was not causing problems with the existing tests, but does with the microsoft abi where they have to get a different calling convention. I will try to refactor this into a method on Declarator in a second. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195050 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaType.cpp | 8 +++++--- test/SemaCXX/decl-microsoft-call-conv.cpp | 9 +++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 2fd9fc45d8..436b4b63ae 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -3240,9 +3240,11 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // top-level template type arguments. bool FreeFunction; if (!D.getCXXScopeSpec().isSet()) { - FreeFunction = ((D.getContext() != Declarator::MemberContext && - D.getContext() != Declarator::LambdaExprContext) || - D.getDeclSpec().isFriendSpecified()); + const DeclSpec &Spec = D.getDeclSpec(); + FreeFunction = (D.getContext() != Declarator::MemberContext && + D.getContext() != Declarator::LambdaExprContext) || + Spec.isFriendSpecified() || + Spec.getStorageClassSpec() == DeclSpec::SCS_typedef; } else { DeclContext *DC = S.computeDeclContext(D.getCXXScopeSpec()); FreeFunction = (DC && !DC->isRecord()); diff --git a/test/SemaCXX/decl-microsoft-call-conv.cpp b/test/SemaCXX/decl-microsoft-call-conv.cpp index 9d42add813..e47a5c2a5c 100644 --- a/test/SemaCXX/decl-microsoft-call-conv.cpp +++ b/test/SemaCXX/decl-microsoft-call-conv.cpp @@ -167,3 +167,12 @@ namespace test2 { }; extern template void foo::bar(const void *); } + +namespace test3 { + struct foo { + typedef void bar(); + }; + bool zed(foo::bar *); + void bah() {} + void baz() { zed(bah); } +} -- 2.50.0