From 13163700843a0ad1df903bdadcce59ae86827d72 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Thu, 1 Aug 2013 17:26:42 +0000 Subject: [PATCH] AST: Treat inline function declarations in -fms-compatibility as if it were in C++ when in C mode This essentially fixes PR16766. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187586 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ASTContext.cpp | 5 +++-- test/CodeGen/inline.c | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 1b465312cc..a3718fea33 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -7807,8 +7807,9 @@ GVALinkage ASTContext::GetGVALinkageForFunction(const FunctionDecl *FD) { if (!FD->isInlined()) return External; - - if (!getLangOpts().CPlusPlus || FD->hasAttr()) { + + if ((!getLangOpts().CPlusPlus && !getLangOpts().MicrosoftMode) || + FD->hasAttr()) { // GNU or C99 inline semantics. Determine whether this symbol should be // externally visible. if (FD->isInlineDefinitionExternallyVisible()) diff --git a/test/CodeGen/inline.c b/test/CodeGen/inline.c index 442b38000b..c1a7f0fbae 100644 --- a/test/CodeGen/inline.c +++ b/test/CodeGen/inline.c @@ -51,6 +51,15 @@ // CHECK3: define available_externally void @_Z13gnu_ei_inlinev() // CHECK3: define linkonce_odr i32 @_Z2eiv() +// RUN: echo "MS C Mode tests:" +// RUN: %clang %s -target i386-unknown-unknown -O1 -emit-llvm -S -o - -std=c99 -fms-compatibility | FileCheck %s --check-prefix=CHECK4 +// CHECK4: define i32 @bar() +// CHECK4: define void @gnu_inline() +// CHECK4: define available_externally void @gnu_ei_inline() +// CHECK4: define linkonce_odr i32 @foo() +// CHECK4-NOT: unreferenced +// CHECK4: define linkonce_odr i32 @ei() + extern __inline int ei() { return 123; } __inline int foo() { -- 2.40.0