From 7d2fd1bf78f086cdff9e0f7191d580580cae618b Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Mon, 21 Jan 2019 21:42:41 +0100 Subject: [PATCH] make pascal attribute imply C linkage (fixes #75) --- gcc/gcc/config/rs6000/macos.h | 2 +- gcc/gcc/config/rs6000/rs6000.c | 3 +++ gcc/gcc/cp/decl.c | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gcc/gcc/config/rs6000/macos.h b/gcc/gcc/config/rs6000/macos.h index 6b79262dc8..c2f5d2f925 100644 --- a/gcc/gcc/config/rs6000/macos.h +++ b/gcc/gcc/config/rs6000/macos.h @@ -156,7 +156,7 @@ builtin_assert ("machine=powerpc"); \ builtin_assert ("cpu=m68k"); \ builtin_assert ("machine=m68k"); \ - builtin_define("pascal="); \ + builtin_define("pascal=__attribute__((__pascal__))"); \ builtin_define("__IEEE_BIG_ENDIAN"); \ } \ while (0) diff --git a/gcc/gcc/config/rs6000/rs6000.c b/gcc/gcc/config/rs6000/rs6000.c index b9f4c4398d..bcb85a4005 100644 --- a/gcc/gcc/config/rs6000/rs6000.c +++ b/gcc/gcc/config/rs6000/rs6000.c @@ -1547,6 +1547,9 @@ static const struct attribute_spec rs6000_attribute_table[] = rs6000_handle_struct_attribute, NULL }, { "gcc_struct", 0, 0, false, false, false, false, rs6000_handle_struct_attribute, NULL }, + { "pascal", 0, 0, false, true, true, false/*don't be strict about function pointers*/, + NULL, NULL }, + #ifdef SUBTARGET_ATTRIBUTE_TABLE SUBTARGET_ATTRIBUTE_TABLE, #endif diff --git a/gcc/gcc/cp/decl.c b/gcc/gcc/cp/decl.c index c0cc71f4eb..28738cc174 100644 --- a/gcc/gcc/cp/decl.c +++ b/gcc/gcc/cp/decl.c @@ -8855,6 +8855,12 @@ grokfndecl (tree ctype, (IDENTIFIER_POINTER (declarator)))))) SET_DECL_LANGUAGE (decl, lang_c); + if (attrlist && lookup_attribute ("pascal", *attrlist)) + { + // paradoxical, but true: Mac pascal function names aren't mangled. + SET_DECL_LANGUAGE (decl, lang_c); + } + /* Should probably propagate const out from type to decl I bet (mrs). */ if (staticp) {