]> granicus.if.org Git - clang/commitdiff
lib/Basic/Targets.cpp: __declspec(attr) should be provided on mingw as macro, alias...
authorNAKAMURA Takumi <geek4civic@gmail.com>
Tue, 15 Mar 2011 02:32:50 +0000 (02:32 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Tue, 15 Mar 2011 02:32:50 +0000 (02:32 +0000)
On mingw without -fms-extensions, we can provide "as-is" __declspec.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127655 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Targets.cpp

index a9667bb2dd356da5d4fe9f7cd023010665b397ab..02b1610b0e3ec7727a55d314ccd842dd65606648 100644 (file)
@@ -1481,7 +1481,15 @@ public:
     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 @@ public:
     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