gcc/ChangeLog:

        * config/i386/i386-options.cc (ix86_handle_cconv_attribute):
        Handle simultaneous use of regparm and thiscall attributes in
        case when regparm is set before thiscall.

gcc/testsuite/ChangeLog:

        * gcc.target/i386/attributes-error.c: Add more attributes
        combinations.
---
 gcc/config/i386/i386-options.cc               |  4 ++
 .../gcc.target/i386/attributes-error.c        | 41 +++++++++++++++----
 2 files changed, 38 insertions(+), 7 deletions(-)

diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc
index 755e5dcf9f1..e7b200cd4f1 100644
--- a/gcc/config/i386/i386-options.cc
+++ b/gcc/config/i386/i386-options.cc
@@ -3729,6 +3729,10 @@ ix86_handle_cconv_attribute (tree *node, tree name, tree 
args, int,
        {
          error ("cdecl and thiscall attributes are not compatible");
        }
+      if (lookup_attribute ("regparm", TYPE_ATTRIBUTES (*node)))
+       {
+         error ("regparm and thiscall attributes are not compatible");
+       }
     }
 
   /* Can combine sseregparm with all attributes.  */
diff --git a/gcc/testsuite/gcc.target/i386/attributes-error.c 
b/gcc/testsuite/gcc.target/i386/attributes-error.c
index 405eda50105..935ea4db0af 100644
--- a/gcc/testsuite/gcc.target/i386/attributes-error.c
+++ b/gcc/testsuite/gcc.target/i386/attributes-error.c
@@ -1,12 +1,39 @@
 /* { dg-do compile } */
 /* { dg-require-effective-target ia32 } */
 
-void foo1(int i, int j) __attribute__((fastcall, cdecl)); /* { dg-error "not 
compatible" } */
-void foo2(int i, int j) __attribute__((fastcall, stdcall)); /* { dg-error "not 
compatible" } */
+void foo1(int i, int j) __attribute__((cdecl, regparm(2)));
+void foo2(int i, int j) __attribute__((stdcall, regparm(2)));
 void foo3(int i, int j) __attribute__((fastcall, regparm(2))); /* { dg-error 
"not compatible" } */
-void foo4(int i, int j) __attribute__((stdcall, cdecl)); /* { dg-error "not 
compatible" } */
-void foo5(int i, int j) __attribute__((stdcall, fastcall)); /* { dg-error "not 
compatible" } */
-void foo6(int i, int j) __attribute__((cdecl, fastcall)); /* { dg-error "not 
compatible" } */
-void foo7(int i, int j) __attribute__((cdecl, stdcall)); /* { dg-error "not 
compatible" } */
-void foo8(int i, int j) __attribute__((regparm(2), fastcall)); /* { dg-error 
"not compatible" } */
+void foo4(int i, int j) __attribute__((thiscall, regparm(2))); /* { dg-error 
"not compatible" } */
+void foo5(int i, int j) __attribute__((sseregparm, regparm(2)));
+
+void foo6(int i, int j) __attribute__((stdcall, fastcall)); /* { dg-error "not 
compatible" } */
+void foo7(int i, int j) __attribute__((regparm(2), fastcall)); /* { dg-error 
"not compatible" } */
+void foo8(int i, int j) __attribute__((sseregparm, fastcall)); /* { dg-error 
"not compatible" } */
+void foo9(int i, int j) __attribute__((thiscall, fastcall)); /* { dg-error 
"not compatible" } */
+void foo10(int i, int j) __attribute__((sseregparm, fastcall));
+
+void foo11(int i, int j) __attribute__((cdecl, stdcall)); /* { dg-error "not 
compatible" } */
+void foo12(int i, int j) __attribute__((fastcall, stdcall)); /* { dg-error 
"not compatible" } */
+void foo13(int i, int j) __attribute__((thiscall, stdcall)); /* { dg-error 
"not compatible" } */
+void foo14(int i, int j) __attribute__((regparm(2), stdcall));
+void foo15(int i, int j) __attribute__((sseregparm, stdcall));
+
+void foo16(int i, int j) __attribute__((stdcall, cdecl)); /* { dg-error "not 
compatible" } */
+void foo17(int i, int j) __attribute__((fastcall, cdecl)); /* { dg-error "not 
compatible" } */
+void foo18(int i, int j) __attribute__((thiscall, cdecl)); /* { dg-error "not 
compatible" } */
+void foo19(int i, int j) __attribute__((regparm(2), cdecl));
+void foo20(int i, int j) __attribute__((sseregparm, cdecl));
+
+void foo21(int i, int j) __attribute__((stdcall, thiscall)); /* { dg-error 
"not compatible" } */
+void foo22(int i, int j) __attribute__((fastcall, thiscall)); /* { dg-error 
"not compatible" } */
+void foo23(int i, int j) __attribute__((cdecl, thiscall)); /* { dg-error "not 
compatible" } */
+void foo24(int i, int j) __attribute__((regparm(2), thiscall)); /* { dg-error 
"not compatible" } */
+void foo25(int i, int j) __attribute__((sseregparm, thiscall));
+
+void foo26(int i, int j) __attribute__((cdecl, sseregparm));
+void foo27(int i, int j) __attribute__((fastcall, sseregparm));
+void foo28(int i, int j) __attribute__((stdcall, sseregparm));
+void foo29(int i, int j) __attribute__((thiscall, sseregparm));
+void foo30(int i, int j) __attribute__((regparm(2), sseregparm));
 
-- 
2.50.1

Reply via email to