<p dir="ltr">You don't seem to have any tests for the calling convention macros?</p>
<div class="gmail_quote">On 21 Apr 2014 13:50, "Reid Kleckner" <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi majnemer, asl,<br>
<br>
This is for compatibility with GCC.<br>
<br>
<a href="http://reviews.llvm.org/D3444" target="_blank">http://reviews.llvm.org/D3444</a><br>
<br>
Files:<br>
lib/Basic/Targets.cpp<br>
test/SemaCXX/decl-microsoft-call-conv.cpp<br>
<br>
Index: lib/Basic/Targets.cpp<br>
===================================================================<br>
--- lib/Basic/Targets.cpp<br>
+++ lib/Basic/Targets.cpp<br>
@@ -3085,6 +3085,31 @@<br>
};<br>
} // end anonymous namespace<br>
<br>
+static void addMinGWDefines(const LangOptions &Opts, MacroBuilder &Builder) {<br>
+ Builder.defineMacro("__MSVCRT__");<br>
+ Builder.defineMacro("__MINGW32__");<br>
+<br>
+ // Mingw defines __declspec(a) to __attribute__((a)). Clang supports<br>
+ // __declspec natively under -fms-extensions, but we define a no-op __declspec<br>
+ // macro anyway for pre-processor compatibility.<br>
+ if (Opts.MicrosoftExt)<br>
+ Builder.defineMacro("__declspec", "__declspec");<br>
+ else<br>
+ Builder.defineMacro("__declspec(a)", "__attribute__((a))");<br>
+<br>
+ if (!Opts.MicrosoftExt) {<br>
+ // Provide macros for all the calling convention keywords. Provide both<br>
+ // single and double underscore prefixed variants. These are available on<br>
+ // x64 as well as x86, even though they have no effect.<br>
+ const char *CCs[] = {"cdecl", "stdcall", "fastcall", "thiscall", "pascal"};<br>
+ for (const char *CC : CCs) {<br>
+ Twine GCCSpelling = Twine("__attribute__((__") + CC + Twine("__))");<br>
+ Builder.defineMacro(Twine("_") + CC, GCCSpelling);<br>
+ Builder.defineMacro(Twine("__") + CC, GCCSpelling);<br>
+ }<br>
+ }<br>
+}<br>
+<br>
namespace {<br>
// x86-32 MinGW target<br>
class MinGWX86_32TargetInfo : public WindowsX86_32TargetInfo {<br>
@@ -3097,17 +3122,7 @@<br>
DefineStd(Builder, "WIN32", Opts);<br>
DefineStd(Builder, "WINNT", Opts);<br>
Builder.defineMacro("_X86_");<br>
- Builder.defineMacro("__MSVCRT__");<br>
- Builder.defineMacro("__MINGW32__");<br>
-<br>
- // mingw32-gcc provides __declspec(a) as alias of __attribute__((a)).<br>
- // In contrast, clang-cc1 provides __declspec(a) with -fms-extensions.<br>
- if (Opts.MicrosoftExt)<br>
- // Provide "as-is" __declspec.<br>
- Builder.defineMacro("__declspec", "__declspec");<br>
- else<br>
- // Provide alias of __attribute__ like mingw32-gcc.<br>
- Builder.defineMacro("__declspec(a)", "__attribute__((a))");<br>
+ addMinGWDefines(Opts, Builder);<br>
}<br>
};<br>
} // end anonymous namespace<br>
@@ -3327,18 +3342,8 @@<br>
MacroBuilder &Builder) const override {<br>
WindowsX86_64TargetInfo::getTargetDefines(Opts, Builder);<br>
DefineStd(Builder, "WIN64", Opts);<br>
- Builder.defineMacro("__MSVCRT__");<br>
- Builder.defineMacro("__MINGW32__");<br>
Builder.defineMacro("__MINGW64__");<br>
-<br>
- // mingw32-gcc provides __declspec(a) as alias of __attribute__((a)).<br>
- // In contrast, clang-cc1 provides __declspec(a) with -fms-extensions.<br>
- if (Opts.MicrosoftExt)<br>
- // Provide "as-is" __declspec.<br>
- Builder.defineMacro("__declspec", "__declspec");<br>
- else<br>
- // Provide alias of __attribute__ like mingw32-gcc.<br>
- Builder.defineMacro("__declspec(a)", "__attribute__((a))");<br>
+ addMinGWDefines(Opts, Builder);<br>
}<br>
};<br>
} // end anonymous namespace<br>
Index: test/SemaCXX/decl-microsoft-call-conv.cpp<br>
===================================================================<br>
--- test/SemaCXX/decl-microsoft-call-conv.cpp<br>
+++ test/SemaCXX/decl-microsoft-call-conv.cpp<br>
@@ -1,4 +1,6 @@<br>
// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -verify %s<br>
+// RUN: %clang_cc1 -triple i686-pc-mingw32 -verify %s<br>
+// RUN: %clang_cc1 -triple i686-pc-mingw32 -fms-extensions -verify %s<br>
<br>
typedef void void_fun_t();<br>
typedef void __cdecl cdecl_fun_t();<br>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div>