From: Erich Keane Date: Tue, 26 Sep 2017 18:55:16 +0000 (+0000) Subject: Allow IUnknown/IInterface types to come from extern C++ X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dcf0996993a4981e35914ede1b1c074feee0fcf0;p=clang Allow IUnknown/IInterface types to come from extern C++ It was brought up in response to my last implementation for this struct-as-interface features that at least 1 header in the MS SDK uses "extern C++" around an IUnknown declaration. The previous implementation demanded that this type exist in the TranslationUnit DeclContext. This small change simply also allows in the situation where we're extern "C++". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314235 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index d63d42c66f..e85ab41851 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -1491,7 +1491,8 @@ bool CXXRecordDecl::isInterfaceLike() const { // Check "Special" types. const auto *Uuid = getAttr(); - if (Uuid && isStruct() && getDeclContext()->isTranslationUnit() && + if (Uuid && isStruct() && (getDeclContext()->isTranslationUnit() || + getDeclContext()->isExternCXXContext()) && ((getName() == "IUnknown" && Uuid->getGuid() == "00000000-0000-0000-C000-000000000046") || (getName() == "IDispatch" && diff --git a/test/SemaCXX/ms-iunknown.cpp b/test/SemaCXX/ms-iunknown.cpp index c965a4c0a1..f73864d43f 100644 --- a/test/SemaCXX/ms-iunknown.cpp +++ b/test/SemaCXX/ms-iunknown.cpp @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) IUnknown { +extern "C++" struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) IUnknown { void foo(); }; struct IPropertyPageBase : public IUnknown {};