summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2017-02-13 06:49:45 +0100
committerMatthias Braun <matze@braunis.de>2017-02-13 09:02:11 +0100
commit44d7c29b3012cd5d8db0a82c446fcaff5949f7b3 (patch)
treea01aede1bea51bc7040a435807b0dbd267066602
parent6930152cfc5d15b7841efd5491336ade22976686 (diff)
Ignore fastcall/stdcall on non-win32 32bit targets
This is only a valid calling convention on win32 32bit targets, on other targets the linker cannot even deal with the name mangling containing '@' characters.
-rw-r--r--src/ast/attribute.c15
-rw-r--r--src/ast/dialect.h3
-rw-r--r--src/driver/target.c1
3 files changed, 16 insertions, 3 deletions
diff --git a/src/ast/attribute.c b/src/ast/attribute.c
index 58f29ac..7709f5d 100644
--- a/src/ast/attribute.c
+++ b/src/ast/attribute.c
@@ -11,6 +11,7 @@
#include "ast_t.h"
#include "attribute_t.h"
#include "constfold.h"
+#include "dialect.h"
#include "driver/diagnostic.h"
#include "driver/warning.h"
#include "entity_t.h"
@@ -464,11 +465,21 @@ type_t *handle_type_attributes(const attribute_t *attributes, type_t *type)
break;
case ATTRIBUTE_MS_STDCALL:
case ATTRIBUTE_GNU_STDCALL:
- type = change_calling_convention(type, CC_STDCALL);
+ if (dialect.support_fastcall_stdcall) {
+ type = change_calling_convention(type, CC_STDCALL);
+ } else {
+ warningf(WARN_OTHER, &attribute->pos,
+ "Ignoring attribute 'stdcall' for this target");
+ }
break;
case ATTRIBUTE_MS_FASTCALL:
case ATTRIBUTE_GNU_FASTCALL:
- type = change_calling_convention(type, CC_FASTCALL);
+ if (dialect.support_fastcall_stdcall) {
+ type = change_calling_convention(type, CC_FASTCALL);
+ } else {
+ warningf(WARN_OTHER, &attribute->pos,
+ "Ignoring attribute 'fastcall' for this target");
+ }
break;
case ATTRIBUTE_MS_THISCALL:
type = change_calling_convention(type, CC_THISCALL);
diff --git a/src/ast/dialect.h b/src/ast/dialect.h
index 123fcaa..612a2b0 100644
--- a/src/ast/dialect.h
+++ b/src/ast/dialect.h
@@ -38,7 +38,8 @@ typedef struct c_dialect_t {
bool ms : 1;
bool long_double_x87_80bit_float : 1;
/** enable hack to add call to __main into the main function (mingw) */
- bool enable_main_collect2_hack : 1;
+ bool enable_main_collect2_hack : 1;
+ bool support_fastcall_stdcall : 1;
unsigned char long_double_size;
unsigned char long_long_and_double_struct_align;
unsigned char long_long_size;
diff --git a/src/driver/target.c b/src/driver/target.c
index e943f1c..d1c47b1 100644
--- a/src/driver/target.c
+++ b/src/driver/target.c
@@ -364,6 +364,7 @@ bsd:
target.user_label_prefix = "_";
dialect.pointer_sized_int = ATOMIC_TYPE_INT;
dialect.pointer_sized_uint = ATOMIC_TYPE_UINT;
+ dialect.support_fastcall_stdcall = true;
}
} else if (strstart(os, "midipix")) {
driver_default_exe_output = "a.out";