majnemer added you to the CC list for the revision "Treat inline function 
declarations in -fms-extensions as if it were in C++ when in C mode.".

Hi rnk,

This essentially fixes LLVM PR16766.

See http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx for more details.

The only open question is how Microsoft plans on implementing __inline for C99 
code, I suppose we could cross that bridge when we get there.

http://llvm-reviews.chandlerc.com/D1254

Files:
  lib/AST/ASTContext.cpp
  test/CodeGen/inline.c

Index: lib/AST/ASTContext.cpp
===================================================================
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -7807,8 +7807,9 @@
 
   if (!FD->isInlined())
     return External;
-    
-  if (!getLangOpts().CPlusPlus || FD->hasAttr<GNUInlineAttr>()) {
+
+  if ((!getLangOpts().CPlusPlus && !getLangOpts().MicrosoftExt) ||
+      FD->hasAttr<GNUInlineAttr>()) {
     // GNU or C99 inline semantics. Determine whether this symbol should be
     // externally visible.
     if (FD->isInlineDefinitionExternallyVisible())
Index: test/CodeGen/inline.c
===================================================================
--- test/CodeGen/inline.c
+++ 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 Extensions tests:"
+// RUN: %clang %s -target i386-unknown-unknown -O1 -emit-llvm -S -o - -std=c99 
-fms-extensions | 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() {
Index: lib/AST/ASTContext.cpp
===================================================================
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -7807,8 +7807,9 @@
 
   if (!FD->isInlined())
     return External;
-    
-  if (!getLangOpts().CPlusPlus || FD->hasAttr<GNUInlineAttr>()) {
+
+  if ((!getLangOpts().CPlusPlus && !getLangOpts().MicrosoftExt) ||
+      FD->hasAttr<GNUInlineAttr>()) {
     // GNU or C99 inline semantics. Determine whether this symbol should be
     // externally visible.
     if (FD->isInlineDefinitionExternallyVisible())
Index: test/CodeGen/inline.c
===================================================================
--- test/CodeGen/inline.c
+++ 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 Extensions tests:"
+// RUN: %clang %s -target i386-unknown-unknown -O1 -emit-llvm -S -o - -std=c99 -fms-extensions | 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() {
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to