[cfe-commits] r127655 - /cfe/trunk/lib/Basic/Targets.cpp

NAKAMURA Takumi geek4civic at gmail.com
Mon Mar 14 19:32:50 PDT 2011


Author: chapuni
Date: Mon Mar 14 21:32:50 2011
New Revision: 127655

URL: http://llvm.org/viewvc/llvm-project?rev=127655&view=rev
Log:
lib/Basic/Targets.cpp: __declspec(attr) should be provided on mingw as macro, alias of __attribute__.

On mingw without -fms-extensions, we can provide "as-is" __declspec.

Modified:
    cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=127655&r1=127654&r2=127655&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Mar 14 21:32:50 2011
@@ -1481,7 +1481,15 @@
     Builder.defineMacro("_X86_");
     Builder.defineMacro("__MSVCRT__");
     Builder.defineMacro("__MINGW32__");
-    Builder.defineMacro("__declspec", "__declspec");
+
+    // mingw32-gcc provides __declspec(a) as alias of __attribute__((a)).
+    // In contrast, clang-cc1 provides __declspec(a) with -fms-extensions.
+    if (Opts.Microsoft)
+      // Provide "as-is" __declspec.
+      Builder.defineMacro("__declspec", "__declspec");
+    else
+      // Provide alias of __attribute__ like mingw32-gcc.
+      Builder.defineMacro("__declspec(a)", "__attribute__((a))");
   }
 };
 } // end anonymous namespace
@@ -1631,7 +1639,15 @@
     Builder.defineMacro("__MSVCRT__");
     Builder.defineMacro("__MINGW32__");
     Builder.defineMacro("__MINGW64__");
-    Builder.defineMacro("__declspec", "__declspec");
+
+    // mingw32-gcc provides __declspec(a) as alias of __attribute__((a)).
+    // In contrast, clang-cc1 provides __declspec(a) with -fms-extensions.
+    if (Opts.Microsoft)
+      // Provide "as-is" __declspec.
+      Builder.defineMacro("__declspec", "__declspec");
+    else
+      // Provide alias of __attribute__ like mingw32-gcc.
+      Builder.defineMacro("__declspec(a)", "__attribute__((a))");
   }
 };
 } // end anonymous namespace





More information about the cfe-commits mailing list