]> granicus.if.org Git - clang/commitdiff
AST: Treat inline function declarations in -fms-compatibility as if it were in C...
authorDavid Majnemer <david.majnemer@gmail.com>
Thu, 1 Aug 2013 17:26:42 +0000 (17:26 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Thu, 1 Aug 2013 17:26:42 +0000 (17:26 +0000)
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
test/CodeGen/inline.c

index 1b465312cc8d70aee5bdcb3e120145b47ab8b1fa..a3718fea338f18375672e13bc7d24db9492354ff 100644 (file)
@@ -7807,8 +7807,9 @@ GVALinkage ASTContext::GetGVALinkageForFunction(const FunctionDecl *FD) {
 
   if (!FD->isInlined())
     return External;
-    
-  if (!getLangOpts().CPlusPlus || FD->hasAttr<GNUInlineAttr>()) {
+
+  if ((!getLangOpts().CPlusPlus && !getLangOpts().MicrosoftMode) ||
+      FD->hasAttr<GNUInlineAttr>()) {
     // GNU or C99 inline semantics. Determine whether this symbol should be
     // externally visible.
     if (FD->isInlineDefinitionExternallyVisible())
index 442b38000b3cb1521752074aec9a584a51457029..c1a7f0fbae2681b37eb6b453912f4cccf6bde0bb 100644 (file)
 // 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() {