r263947 - clang-cl: support __cdecl-on-struct anachronism
Reid Kleckner via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 21 09:08:49 PDT 2016
Author: rnk
Date: Mon Mar 21 11:08:49 2016
New Revision: 263947
URL: http://llvm.org/viewvc/llvm-project?rev=263947&view=rev
Log:
clang-cl: support __cdecl-on-struct anachronism
Summary:
The Microsoft compiler emits
warning C4229: anachronism used : modifiers on data are ignored
for
struct {} __cdecl s;
but ICU's gendict can generate such (and does when building
LibreOffice), so accepting this in clang-cl too would be useful.
Reviewers: rnk
Patch by Stephan Bergmann
Differential Revision: http://reviews.llvm.org/D16628
Added:
cfe/trunk/test/Parser/ms-anachronism.c
Modified:
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=263947&r1=263946&r2=263947&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Mon Mar 21 11:08:49 2016
@@ -1103,6 +1103,15 @@ bool Parser::isValidAfterTypeSpecifier(b
return true;
case tok::colon:
return CouldBeBitfield; // enum E { ... } : 2;
+ // Microsoft compatibility
+ case tok::kw___cdecl: // struct foo {...} __cdecl x;
+ case tok::kw___fastcall: // struct foo {...} __fastcall x;
+ case tok::kw___stdcall: // struct foo {...} __stdcall x;
+ case tok::kw___thiscall: // struct foo {...} __thiscall x;
+ case tok::kw___vectorcall: // struct foo {...} __vectorcall x;
+ // We will diagnose these calling-convention specifiers on non-function
+ // declarations later, so claim they are valid after a type specifier.
+ return getLangOpts().MicrosoftExt;
// Type qualifiers
case tok::kw_const: // struct foo {...} const x;
case tok::kw_volatile: // struct foo {...} volatile x;
Added: cfe/trunk/test/Parser/ms-anachronism.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/ms-anachronism.c?rev=263947&view=auto
==============================================================================
--- cfe/trunk/test/Parser/ms-anachronism.c (added)
+++ cfe/trunk/test/Parser/ms-anachronism.c Mon Mar 21 11:08:49 2016
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -fms-extensions -fsyntax-only -verify %s
+
+struct {} __cdecl s; // expected-warning {{'__cdecl' only applies to function types; type here is 'struct}}
More information about the cfe-commits
mailing list