Commit 88b0e79e by Jacek Caban Committed by Kai Tietz

c-target.def: New hook

2013-09-13  Jacek Caban  <jacek@codeweavers.com>

	* c-target.def: New hook
    
    gcc/ChangeLog:

2013-09-13  Jacek Caban  <jacek@codeweavers.com>

	* config.gcc: Use new winnt-c.c target hooks
	* config/t-winnt: New file
	* config/winnt-c.c: New file
	* doc/tm.texi.in: Document new hook
	* doc/tm.texi: Regenerated
    
    gcc/cp/Changelog:

2013-09-13  Jacek Caban  <jacek@codeweavers.com>

	* decl.c: Use new cxx_implicit_extern_c hook
    
    gcc/testsuite/ChangeLog:

2013-09-13  Jacek Caban  <jacek@codeweavers.com>

	* g++.dg/abi/main.C: Added implicit C linkage tests

From-SVN: r202573
parent a1e51df9
2013-09-13 Jacek Caban <jacek@codeweavers.com>
* config.gcc: Use new winnt-c.c target hooks
* config/t-winnt: New file
* config/winnt-c.c: New file
* doc/tm.texi.in: Document new hook
* doc/tm.texi: Regenerated
2013-09-13 Jan Hubicka <jh@suse.cz> 2013-09-13 Jan Hubicka <jh@suse.cz>
PR middle-end/58094 PR middle-end/58094
......
2013-09-13 Jacek Caban <jacek@codeweavers.com>
* c-target.def: New hook
2013-09-09 Paolo Carlini <paolo.carlini@oracle.com> 2013-09-09 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/43452 PR c++/43452
......
...@@ -102,5 +102,15 @@ DEFHOOK ...@@ -102,5 +102,15 @@ DEFHOOK
than just the compiler.", than just the compiler.",
const char *, (void), const char *, (void),
hook_constcharptr_void_null) hook_constcharptr_void_null)
DEFHOOK
(cxx_implicit_extern_c,
"Define this hook to add target-specific C++ implicit extern C functions.\
If this function returns true for the name of a file-scope function, that\
function implicitly gets extern \"C\" linkage rather than whatever language\
linkage the declaration would normally have. An example of such function\
is WinMain on Win32 targets.",
bool, (const char*),
NULL)
HOOK_VECTOR_END (C90_EMPTY_HACK) HOOK_VECTOR_END (C90_EMPTY_HACK)
...@@ -1526,6 +1526,9 @@ x86_64-*-cygwin*) ...@@ -1526,6 +1526,9 @@ x86_64-*-cygwin*)
i[34567]86-*-mingw* | x86_64-*-mingw*) i[34567]86-*-mingw* | x86_64-*-mingw*)
tm_file="${tm_file} i386/unix.h i386/bsd.h i386/gas.h dbxcoff.h i386/cygming.h" tm_file="${tm_file} i386/unix.h i386/bsd.h i386/gas.h dbxcoff.h i386/cygming.h"
xm_file=i386/xm-mingw32.h xm_file=i386/xm-mingw32.h
c_target_objs="${c_target_objs} winnt-c.o"
cxx_target_objs="${cxx_target_objs} winnt-c.o"
target_has_targetcm="yes"
case ${target} in case ${target} in
x86_64-*-* | *-w64-*) x86_64-*-* | *-w64-*)
need_64bit_isa=yes need_64bit_isa=yes
...@@ -1565,7 +1568,7 @@ i[34567]86-*-mingw* | x86_64-*-mingw*) ...@@ -1565,7 +1568,7 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
;; ;;
esac esac
tm_file="${tm_file} i386/mingw-stdint.h" tm_file="${tm_file} i386/mingw-stdint.h"
tmake_file="${tmake_file} i386/t-cygming t-slibgcc" tmake_file="${tmake_file} t-winnt i386/t-cygming t-slibgcc"
case ${target} in case ${target} in
x86_64-w64-*) x86_64-w64-*)
tmake_file="${tmake_file} i386/t-mingw-w64" tmake_file="${tmake_file} i386/t-mingw-w64"
......
# Copyright (C) 2013 Free Software Foundation, Inc.
#
# This file is part of GCC.
#
# GCC is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# GCC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
winnt-c.o: config/winnt-c.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(C_TARGET_H) $(C_TARGET_DEF_H)
$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \
$< $(OUTPUT_OPTION)
/* Default C-family target hooks initializer.
Copyright (C) 2013
Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "c-family/c-target.h"
#include "c-family/c-target-def.h"
static bool
winnt_implicit_extern_c (const char *ident)
{
return !strcmp(ident, "wmain")
|| !strcmp(ident, "DllMain")
|| !strcmp(ident, "WinMain")
|| !strcmp(ident, "wWinMain");
}
#undef TARGET_CXX_IMPLICIT_EXTERN_C
#define TARGET_CXX_IMPLICIT_EXTERN_C winnt_implicit_extern_c
struct gcc_targetcm targetcm = TARGETCM_INITIALIZER;
2013-09-13 Jacek Caban <jacek@codeweavers.com>
* decl.c: Use new cxx_implicit_extern_c hook
2013-09-12 Brooks Moses <bmoses@google.com> 2013-09-12 Brooks Moses <bmoses@google.com>
PR driver/42955 PR driver/42955
......
...@@ -44,6 +44,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -44,6 +44,7 @@ along with GCC; see the file COPYING3. If not see
#include "c-family/c-common.h" #include "c-family/c-common.h"
#include "c-family/c-objc.h" #include "c-family/c-objc.h"
#include "c-family/c-pragma.h" #include "c-family/c-pragma.h"
#include "c-family/c-target.h"
#include "diagnostic.h" #include "diagnostic.h"
#include "intl.h" #include "intl.h"
#include "debug.h" #include "debug.h"
...@@ -7457,7 +7458,9 @@ grokfndecl (tree ctype, ...@@ -7457,7 +7458,9 @@ grokfndecl (tree ctype,
|| (IDENTIFIER_LENGTH (declarator) > 10 || (IDENTIFIER_LENGTH (declarator) > 10
&& IDENTIFIER_POINTER (declarator)[0] == '_' && IDENTIFIER_POINTER (declarator)[0] == '_'
&& IDENTIFIER_POINTER (declarator)[1] == '_' && IDENTIFIER_POINTER (declarator)[1] == '_'
&& strncmp (IDENTIFIER_POINTER (declarator)+2, "builtin_", 8) == 0)) && strncmp (IDENTIFIER_POINTER (declarator)+2, "builtin_", 8) == 0)
|| (targetcm.cxx_implicit_extern_c
&& targetcm.cxx_implicit_extern_c(IDENTIFIER_POINTER (declarator))))
&& current_lang_name == lang_name_cplusplus && current_lang_name == lang_name_cplusplus
&& ctype == NULL_TREE && ctype == NULL_TREE
&& DECL_FILE_SCOPE_P (decl)) && DECL_FILE_SCOPE_P (decl))
......
...@@ -10651,6 +10651,10 @@ Define this hook to return the name of a header file to be included at the start ...@@ -10651,6 +10651,10 @@ Define this hook to return the name of a header file to be included at the start
This hook can be used together with a header provided by the system C library to implement ISO C requirements for certain macros to be predefined that describe properties of the whole implementation rather than just the compiler. This hook can be used together with a header provided by the system C library to implement ISO C requirements for certain macros to be predefined that describe properties of the whole implementation rather than just the compiler.
@end deftypefn @end deftypefn
@deftypefn {C Target Hook} bool TARGET_CXX_IMPLICIT_EXTERN_C (const char*@var{})
Define this hook to add target-specific C++ implicit extern C functions. If this function returns true for the name of a file-scope function, that function implicitly gets extern "C" linkage rather than whatever language linkage the declaration would normally have. An example of such function is WinMain on Win32 targets.
@end deftypefn
@defmac NO_IMPLICIT_EXTERN_C @defmac NO_IMPLICIT_EXTERN_C
Define this macro if the system header files support C++ as well as C@. Define this macro if the system header files support C++ as well as C@.
This macro inhibits the usual method of using system header files in This macro inhibits the usual method of using system header files in
......
...@@ -7985,6 +7985,8 @@ files @code{__STDC__} will always expand to 1. ...@@ -7985,6 +7985,8 @@ files @code{__STDC__} will always expand to 1.
@hook TARGET_C_PREINCLUDE @hook TARGET_C_PREINCLUDE
@hook TARGET_CXX_IMPLICIT_EXTERN_C
@defmac NO_IMPLICIT_EXTERN_C @defmac NO_IMPLICIT_EXTERN_C
Define this macro if the system header files support C++ as well as C@. Define this macro if the system header files support C++ as well as C@.
This macro inhibits the usual method of using system header files in This macro inhibits the usual method of using system header files in
......
2013-09-13 Jacek Caban <jacek@codeweavers.com>
* g++.dg/abi/main.C: Added implicit C linkage tests
2013-09-13 Kai Tietz <ktietz@redhat.com> 2013-09-13 Kai Tietz <ktietz@redhat.com>
gcc.target/i386/pr57848.c: New file. gcc.target/i386/pr57848.c: New file.
......
/* { dg-do compile } */
/* Check if entry points get implicit C linkage. If they don't, compiler will
* error on incompatible declarations */
int main();
extern "C" int main();
#ifdef __MINGW32__
int wmain();
extern "C" int wmain();
int DllMain();
extern "C" int DllMain();
int WinMain();
extern "C" int WinMain();
int wWinMain();
extern "C" int wWinMain();
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment