[PATCH] D16628: clang-cl: support __cdecl-on-struct anachronism

Stephan Bergmann via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 27 06:32:53 PST 2016


sberg created this revision.
sberg added a reviewer: rnk.
sberg added a subscriber: cfe-commits.

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.

http://reviews.llvm.org/D16628

Files:
  lib/Parse/ParseDeclCXX.cpp
  test/Parser/ms-anachronism.c

Index: test/Parser/ms-anachronism.c
===================================================================
--- /dev/null
+++ test/Parser/ms-anachronism.c
@@ -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}}
Index: lib/Parse/ParseDeclCXX.cpp
===================================================================
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -1103,6 +1103,11 @@
     return true;
   case tok::colon:
     return CouldBeBitfield;     // enum E { ... }   :         2;
+  // Microsoft compatibility
+  case tok::kw___cdecl:         // struct foo {...} __cdecl   x; // C4229
+    if (!getLangOpts().MicrosoftExt)
+      break;
+    // fall through
   // Type qualifiers
   case tok::kw_const:           // struct foo {...} const     x;
   case tok::kw_volatile:        // struct foo {...} volatile  x;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16628.46130.patch
Type: text/x-patch
Size: 988 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160127/3df8cdfb/attachment.bin>


More information about the cfe-commits mailing list