[PATCH] Treat inline function declarations in -fms-extensions as if it were in C++ when in C mode.

David Majnemer david.majnemer at gmail.com
Wed Jul 31 19:47:05 PDT 2013

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.



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() {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1254.1.patch
Type: text/x-patch
Size: 1329 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130731/9960ff2c/attachment.bin>

More information about the cfe-commits mailing list