diff mbox series

Invert sense of NO_IMPLICIT_EXTERN_C

Message ID 66067c72-c34d-2691-ae03-909a942d446c@acm.org
State New
Headers show
Series Invert sense of NO_IMPLICIT_EXTERN_C | expand

Commit Message

Nathan Sidwell June 25, 2018, 4:48 p.m. UTC
NO_IMPLICIT_EXTERN_C was introduced to tell the compiler that it didn't 
need to fake up 'extern "C" { ... }' around system header files.  Over 
the years more and more system headers have become C++-aware, leading to 
more targets defining this macro.

Unfortunately because of the sense of this macro, and that the 
requirement is based on the target-OS, whereas we partition the config 
directory by target-ARCH, it's become hard to know which targets still 
require the older functionality.

There have been a few questions over the past 2 decades to figure this 
out, but they didn;t progress.

This patch replaces the negative NO_IMPLICIT_EXTERN_C with the positive 
SYSTEM_IMPLICIT_EXTERN_C.  Targets that previously did not define 
NO_IMPLICIT_EXTERN_C now need to define SYSTEM_IMPLICIT_EXTERN_C.  I 
know of one such target -- AIX, and I'd be grateful this patch could be 
tried there.

Going through the config files was tricky, and I may well have missed 
something.  One suspicious file is config/sparc/openbsd64.h which did 
explicitly undef the macro, with the comment:

   /* Inherited from sp64-elf.  */

sp64-elf.h does define the macro, but the other bsd's also define it, 
which leaves me wondering if openbsd.h has bit rotted here.  Which leads 
me to another observation:

It's quite possible the extern "C" functionality is enabled on targets 
that no longer need it, because their observed behaviour would not be 
broken.  On the other hand, the failure mode of not defining its 
replacement (or alternatively mistakenly defining NO_IMPLICIT_EXTERN_C), 
would be immediate and obvious.  And the fix is also simple.

So, if you have a target that you think has C++-unaware system headers, 
please give this patch a spin and report.  Blessing from a GM after a 
few days out there would be nice :)

The lesson here is that when one has a transition, chose an enablement 
mechanism that makes it easy to tell when the transition is complete.

nathan

Comments

David Edelsohn June 26, 2018, 2:27 a.m. UTC | #1
On Mon, Jun 25, 2018 at 12:48 PM Nathan Sidwell <nathan@acm.org> wrote:
>
> NO_IMPLICIT_EXTERN_C was introduced to tell the compiler that it didn't
> need to fake up 'extern "C" { ... }' around system header files.  Over
> the years more and more system headers have become C++-aware, leading to
> more targets defining this macro.
>
> Unfortunately because of the sense of this macro, and that the
> requirement is based on the target-OS, whereas we partition the config
> directory by target-ARCH, it's become hard to know which targets still
> require the older functionality.
>
> There have been a few questions over the past 2 decades to figure this
> out, but they didn;t progress.
>
> This patch replaces the negative NO_IMPLICIT_EXTERN_C with the positive
> SYSTEM_IMPLICIT_EXTERN_C.  Targets that previously did not define
> NO_IMPLICIT_EXTERN_C now need to define SYSTEM_IMPLICIT_EXTERN_C.  I
> know of one such target -- AIX, and I'd be grateful this patch could be
> tried there.
>
> Going through the config files was tricky, and I may well have missed
> something.  One suspicious file is config/sparc/openbsd64.h which did
> explicitly undef the macro, with the comment:
>
>    /* Inherited from sp64-elf.  */
>
> sp64-elf.h does define the macro, but the other bsd's also define it,
> which leaves me wondering if openbsd.h has bit rotted here.  Which leads
> me to another observation:
>
> It's quite possible the extern "C" functionality is enabled on targets
> that no longer need it, because their observed behaviour would not be
> broken.  On the other hand, the failure mode of not defining its
> replacement (or alternatively mistakenly defining NO_IMPLICIT_EXTERN_C),
> would be immediate and obvious.  And the fix is also simple.
>
> So, if you have a target that you think has C++-unaware system headers,
> please give this patch a spin and report.  Blessing from a GM after a
> few days out there would be nice :)
>
> The lesson here is that when one has a transition, chose an enablement
> mechanism that makes it easy to tell when the transition is complete.

I tried the subset of the patch that directly affects AIX and saw no
ill effects.

Thanks, David
Nathan Sidwell July 3, 2018, 1:50 p.m. UTC | #2
could a global reviewer comment?  This touches a lot of target-specific 
config files.  David has kindly checked AIX is ok, the known target 
needing the functionality.

https://gcc.gnu.org/ml/gcc-patches/2018-06/msg01568.html

nathan

On 06/25/2018 12:48 PM, Nathan Sidwell wrote:
> NO_IMPLICIT_EXTERN_C was introduced to tell the compiler that it didn't 
> need to fake up 'extern "C" { ... }' around system header files.  Over 
> the years more and more system headers have become C++-aware, leading to 
> more targets defining this macro.
> 
> Unfortunately because of the sense of this macro, and that the 
> requirement is based on the target-OS, whereas we partition the config 
> directory by target-ARCH, it's become hard to know which targets still 
> require the older functionality.
> 
> There have been a few questions over the past 2 decades to figure this 
> out, but they didn;t progress.
> 
> This patch replaces the negative NO_IMPLICIT_EXTERN_C with the positive 
> SYSTEM_IMPLICIT_EXTERN_C.  Targets that previously did not define 
> NO_IMPLICIT_EXTERN_C now need to define SYSTEM_IMPLICIT_EXTERN_C.  I 
> know of one such target -- AIX, and I'd be grateful this patch could be 
> tried there.
> 
> Going through the config files was tricky, and I may well have missed 
> something.  One suspicious file is config/sparc/openbsd64.h which did 
> explicitly undef the macro, with the comment:
> 
>    /* Inherited from sp64-elf.  */
> 
> sp64-elf.h does define the macro, but the other bsd's also define it, 
> which leaves me wondering if openbsd.h has bit rotted here.  Which leads 
> me to another observation:
> 
> It's quite possible the extern "C" functionality is enabled on targets 
> that no longer need it, because their observed behaviour would not be 
> broken.  On the other hand, the failure mode of not defining its 
> replacement (or alternatively mistakenly defining NO_IMPLICIT_EXTERN_C), 
> would be immediate and obvious.  And the fix is also simple.
> 
> So, if you have a target that you think has C++-unaware system headers, 
> please give this patch a spin and report.  Blessing from a GM after a 
> few days out there would be nice :)
> 
> The lesson here is that when one has a transition, chose an enablement 
> mechanism that makes it easy to tell when the transition is complete.
> 
> nathan
>
Jeff Law July 4, 2018, 2:42 a.m. UTC | #3
On 07/03/2018 07:50 AM, Nathan Sidwell wrote:
> could a global reviewer comment?  This touches a lot of target-specific
> config files.  David has kindly checked AIX is ok, the known target
> needing the functionality.
> 
> https://gcc.gnu.org/ml/gcc-patches/2018-06/msg01568.html
So it's almost certain OpenBSD has bitrotted.

It's also likely extern C functionality is enabled on targets that don't
actually need it.  As you note, failure to have it would be immediate,
obvious and easy to fix.

I think we should go forward.  We can fault in any necessary fixes.

jeff
diff mbox series

Patch

2018-06-25  Nathan Sidwell  <nathan@acm.org>

	gcc/c-family/
	* c-lex.c (fe_file_change): Check SYSTEM_IMPLICIT_EXTERN_C not
	NO_IMPLICIT_EXTERN_C.

	gcc/cp/
	* cp/decl.c (decls_match): Check SYSTEM_IMPLICIT_EXTERN_C not
	NO_IMPLICIT_EXTERN_C.
	* cp/parser.c (cp_parser_parameter_declaration_clause): Likewise.

	gcc/
	Replace NO_IMPLICIT_EXTERN_C with SYSTEM_IMPLICIT_EXTERN_C.
	* doc/cpp.texi: Update comment.
	* doc/tm.texi: Rebuilt.
	* doc/tm.texi.in (NO_IMPLICIT_EXTERN_C): Replace with ...
	(SYSTEM_IMPLICIT_EXTERN_C): ... this, opposite sense.
	* doc/extend.texi (Backwards Compatibility): Clarify it is system
	headers affected by extern "C".
	* system.h: Poison NO_IMPLICIT_EXTERN_C.
	* config/alpha/alpha.h, config/arm/uclinux-elf.h,
	config/bfin/elf.h, config/cris/cris.h, config/darwin.h,
	config/dragonfly.h, config/freebsd.h, config/gnu-user.h,
	config/i386/cygming.h, config/i386/djgpp.h, config/i386/nto.h,
	config/ia64/hpux.h, config/lm32/lm32.h, config/lm32/uclinux-elf.h,
	config/lynx.h, config/mips/elf.h, config/mmix/mmix.h,
	config/netbsd.h, config/pa/pa-hpux.h, config/powerpcspe/sysv4.h,
	config/riscv/elf.h, config/rs6000/sysv4.h, config/rtems.h,
	config/s390/tpf.h, config/sh/newlib.h, config/sol2.h,
	config/sparc/openbsd64.h, config/sparc/sp-elf.h,
	config/sparc/sp64-elf.h, config/spu/spu.h,
	config/stormy16/stormy16.h, config/v850/v850.h,
	config/visium/visium.h, config/vx-common.h, config/xtensa/elf.h: Don't
	define NO_IMPLICIT_EXTERN_C.
	* config/rs6000/aix.h: Set SYSTEM_IMPLICIT_EXTERN_C.

Index: c-family/c-lex.c
===================================================================
--- c-family/c-lex.c	(revision 262020)
+++ c-family/c-lex.c	(working copy)
@@ -206,7 +206,7 @@  fe_file_change (const line_map_ordinary
 
 	  input_location = new_map->start_location;
 	  (*debug_hooks->start_source_file) (line, LINEMAP_FILE (new_map));
-#ifndef NO_IMPLICIT_EXTERN_C
+#ifdef SYSTEM_IMPLICIT_EXTERN_C
 	  if (c_header_level)
 	    ++c_header_level;
 	  else if (LINEMAP_SYSP (new_map) == 2)
@@ -219,7 +219,7 @@  fe_file_change (const line_map_ordinary
     }
   else if (new_map->reason == LC_LEAVE)
     {
-#ifndef NO_IMPLICIT_EXTERN_C
+#ifdef SYSTEM_IMPLICIT_EXTERN_C
       if (c_header_level && --c_header_level == 0)
 	{
 	  if (LINEMAP_SYSP (new_map) == 2)
Index: config/alpha/alpha.h
===================================================================
--- config/alpha/alpha.h	(revision 262020)
+++ config/alpha/alpha.h	(working copy)
@@ -922,7 +922,4 @@  extern long alpha_auto_offset;
 /* By default, turn on GDB extensions.  */
 #define DEFAULT_GDB_EXTENSIONS 1
 
-/* The system headers under Alpha systems are generally C++-aware.  */
-#define NO_IMPLICIT_EXTERN_C
-
 #define TARGET_SUPPORTS_WIDE_INT 1
Index: config/arm/uclinux-elf.h
===================================================================
--- config/arm/uclinux-elf.h	(revision 262020)
+++ config/arm/uclinux-elf.h	(working copy)
@@ -48,9 +48,6 @@ 
     }						\
   while (false)
 
-/* Do not assume anything about header files.  */
-#define NO_IMPLICIT_EXTERN_C
-
 /* The GNU C++ standard library requires that these macros be defined.  */
 #undef CPLUSPLUS_CPP_SPEC
 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
Index: config/bfin/elf.h
===================================================================
--- config/bfin/elf.h	(revision 262020)
+++ config/bfin/elf.h	(working copy)
@@ -70,5 +70,3 @@  asm (TEXT_SECTION_ASM_OP);
 #undef SUBTARGET_DRIVER_SELF_SPECS
 #define SUBTARGET_DRIVER_SELF_SPECS \
      "%{mfdpic:-msim} %{mid-shared-library:-msim}"
-
-#define NO_IMPLICIT_EXTERN_C
Index: config/cris/cris.h
===================================================================
--- config/cris/cris.h	(revision 262020)
+++ config/cris/cris.h	(working copy)
@@ -1030,8 +1030,6 @@  enum cris_symbol_type
 
 #define FUNCTION_MODE QImode
 
-#define NO_IMPLICIT_EXTERN_C
-
 /*
  * Local variables:
  * eval: (c-set-style "gnu")
Index: config/darwin.h
===================================================================
--- config/darwin.h	(revision 262020)
+++ config/darwin.h	(working copy)
@@ -43,9 +43,6 @@  see the files COPYING3 and COPYING.RUNTI
 #define DARWIN_X86 0
 #define DARWIN_PPC 0
 
-/* Don't assume anything about the header files.  */
-#define NO_IMPLICIT_EXTERN_C
-
 /* Suppress g++ attempt to link in the math library automatically. */
 #define MATH_LIBRARY ""
 
Index: config/dragonfly.h
===================================================================
--- config/dragonfly.h	(revision 262020)
+++ config/dragonfly.h	(working copy)
@@ -104,10 +104,6 @@  see the files COPYING3 and COPYING.RUNTI
 #undef  OBJECT_FORMAT_ELF
 #define OBJECT_FORMAT_ELF
 
-/* Don't assume anything about the header files.  */
-#undef  NO_IMPLICIT_EXTERN_C
-#define NO_IMPLICIT_EXTERN_C	1
-
 /* Follow DragonFly's standard headers (<machine/stdint.h>, etc...).  */
 
 #undef  WCHAR_TYPE
Index: config/freebsd.h
===================================================================
--- config/freebsd.h	(revision 262020)
+++ config/freebsd.h	(working copy)
@@ -68,10 +68,6 @@  along with GCC; see the file COPYING3.
 #undef  OBJECT_FORMAT_ELF
 #define OBJECT_FORMAT_ELF
 
-/* Don't assume anything about the header files.  */
-#undef  NO_IMPLICIT_EXTERN_C
-#define NO_IMPLICIT_EXTERN_C	1
-
 /* Follow FreeBSD's standard headers (<sys/_types.h> etc...).  */
 
 #undef  WCHAR_TYPE
Index: config/gnu-user.h
===================================================================
--- config/gnu-user.h	(revision 262020)
+++ config/gnu-user.h	(working copy)
@@ -26,9 +26,6 @@  a copy of the GCC Runtime Library Except
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-/* Don't assume anything about the header files.  */
-#define NO_IMPLICIT_EXTERN_C
-
 #undef ASM_APP_ON
 #define ASM_APP_ON "#APP\n"
 
Index: config/i386/cygming.h
===================================================================
--- config/i386/cygming.h	(revision 262020)
+++ config/i386/cygming.h	(working copy)
@@ -378,9 +378,6 @@  do {						\
 #endif
 #endif
 
-/* Don't assume anything about the header files.  */
-#define NO_IMPLICIT_EXTERN_C
-
 #undef PROFILE_HOOK
 #define PROFILE_HOOK(LABEL)						\
   if (MAIN_NAME_P (DECL_NAME (current_function_decl)))			\
Index: config/i386/djgpp.h
===================================================================
--- config/i386/djgpp.h	(revision 262020)
+++ config/i386/djgpp.h	(working copy)
@@ -23,9 +23,6 @@  along with GCC; see the file COPYING3.
 #undef PREFERRED_DEBUGGING_TYPE
 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
 
-/* Don't assume anything about the header files.  */
-#define NO_IMPLICIT_EXTERN_C
-
 #undef BSS_SECTION_ASM_OP
 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
 
Index: config/i386/nto.h
===================================================================
--- config/i386/nto.h	(revision 262020)
+++ config/i386/nto.h	(working copy)
@@ -98,8 +98,6 @@  crti.o%s \
 #undef WCHAR_TYPE_SIZE
 #define WCHAR_TYPE_SIZE BITS_PER_WORD
 
-#define NO_IMPLICIT_EXTERN_C 1
-
 #define TARGET_POSIX_IO
 
 #undef DBX_REGISTER_NUMBER
Index: config/ia64/hpux.h
===================================================================
--- config/ia64/hpux.h	(revision 262020)
+++ config/ia64/hpux.h	(working copy)
@@ -185,9 +185,6 @@  do {								\
 
 #define FLOAT_LIB_COMPARE_RETURNS_BOOL(MODE, COMPARISON) ((MODE) == TFmode)
 
-/* HP-UX headers are C++-compatible.  */
-#define NO_IMPLICIT_EXTERN_C
-
 /* HP-UX uses PROFILE_HOOK instead of FUNCTION_PROFILER but we need a
    FUNCTION_PROFILER defined because its use is not ifdefed.  When using
    PROFILE_HOOK, the profile call comes after the prologue.  */
Index: config/lm32/lm32.h
===================================================================
--- config/lm32/lm32.h	(revision 262020)
+++ config/lm32/lm32.h	(working copy)
@@ -516,8 +516,4 @@  do {
 
 #define FUNCTION_MODE SImode
 
-#ifndef NO_IMPLICIT_EXTERN_C
-#define NO_IMPLICIT_EXTERN_C
-#endif
-
 #define STORE_FLAG_VALUE 1
Index: config/lm32/uclinux-elf.h
===================================================================
--- config/lm32/uclinux-elf.h	(revision 262020)
+++ config/lm32/uclinux-elf.h	(working copy)
@@ -21,10 +21,6 @@ 
 /* elfos.h should have already been included.  Now just override
    any conflicting definitions and add any extras.  */
 
-/* Do not assume anything about header files.  */
-#undef NO_IMPLICIT_EXTERN_C
-#define NO_IMPLICIT_EXTERN_C
-
 /* The GNU C++ standard library requires that these macros be defined.  */
 #undef CPLUSPLUS_CPP_SPEC
 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
Index: config/lynx.h
===================================================================
--- config/lynx.h	(revision 262020)
+++ config/lynx.h	(working copy)
@@ -165,12 +165,6 @@  along with GCC; see the file COPYING3.
 # define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
 #endif
 
-/* We have C++ support in our system headers.  */
-
-#ifndef NO_IMPLICIT_EXTERN_C
-# define NO_IMPLICIT_EXTERN_C
-#endif
-
 #ifndef TARGET_POSIX_IO
 # define TARGET_POSIX_IO
 #endif
Index: config/mips/elf.h
===================================================================
--- config/mips/elf.h	(revision 262020)
+++ config/mips/elf.h	(working copy)
@@ -46,5 +46,3 @@  along with GCC; see the file COPYING3.
 
 #undef  ENDFILE_SPEC
 #define ENDFILE_SPEC "crtend%O%s crtn%O%s"
-
-#define NO_IMPLICIT_EXTERN_C 1
Index: config/mmix/mmix.h
===================================================================
--- config/mmix/mmix.h	(revision 262020)
+++ config/mmix/mmix.h	(working copy)
@@ -789,8 +789,6 @@  typedef struct { int regs; int lib; } CU
 
 #define FUNCTION_MODE QImode
 
-#define NO_IMPLICIT_EXTERN_C
-
 /* mmix-knuth-mmixware target has no support of C99 runtime */
 #undef TARGET_LIBC_HAS_FUNCTION
 #define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function
Index: config/netbsd.h
===================================================================
--- config/netbsd.h	(revision 262020)
+++ config/netbsd.h	(working copy)
@@ -149,10 +149,6 @@  along with GCC; see the file COPYING3.
 #undef TARGET_POSIX_IO
 #define TARGET_POSIX_IO
 
-/* Don't assume anything about the header files.  */
-#undef  NO_IMPLICIT_EXTERN_C
-#define NO_IMPLICIT_EXTERN_C    1
-
 /* Define some types that are the same on all NetBSD platforms,
    making them agree with <machine/ansi.h>.  */
 
Index: config/pa/pa-hpux.h
===================================================================
--- config/pa/pa-hpux.h	(revision 262020)
+++ config/pa/pa-hpux.h	(working copy)
@@ -102,10 +102,6 @@  along with GCC; see the file COPYING3.
   "%{mlinker-opt:-O} %{!shared:-u main} %{static:-a archive} %{g*:-a archive} %{shared:-b}"
 #endif
 
-/* hpux8 and later have C++ compatible include files, so do not
-   pretend they are `extern "C"'.  */
-#define NO_IMPLICIT_EXTERN_C
-
 /* hpux11 and earlier don't have fputc_unlocked, so we must inhibit the
    transformation of fputs_unlocked and fprintf_unlocked to fputc_unlocked.  */
 #define DONT_HAVE_FPUTC_UNLOCKED
Index: config/powerpcspe/sysv4.h
===================================================================
--- config/powerpcspe/sysv4.h	(revision 262020)
+++ config/powerpcspe/sysv4.h	(working copy)
@@ -23,10 +23,6 @@ 
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-/* Header files should be C++ aware in general.  */
-#undef  NO_IMPLICIT_EXTERN_C
-#define NO_IMPLICIT_EXTERN_C
-
 /* Yes!  We are ELF.  */
 #define	TARGET_OBJECT_FORMAT OBJECT_ELF
 
Index: config/riscv/elf.h
===================================================================
--- config/riscv/elf.h	(revision 262020)
+++ config/riscv/elf.h	(working copy)
@@ -32,5 +32,3 @@  along with GCC; see the file COPYING3.
 
 #undef  ENDFILE_SPEC
 #define ENDFILE_SPEC "crtend%O%s"
-
-#define NO_IMPLICIT_EXTERN_C 1
Index: config/rs6000/aix.h
===================================================================
--- config/rs6000/aix.h	(revision 262020)
+++ config/rs6000/aix.h	(working copy)
@@ -23,6 +23,9 @@ 
 #undef  TARGET_AIX
 #define TARGET_AIX 1
 
+/* System headers are not C++-aware.  */
+#define SYSTEM_IMPLICIT_EXTERN_C 1
+
 /* Linux64.h wants to redefine TARGET_AIX based on -m64, but it can't be used
    in the #if conditional in options-default.h, so provide another macro.  */
 #undef  TARGET_AIX_OS
Index: config/rs6000/sysv4.h
===================================================================
--- config/rs6000/sysv4.h	(revision 262020)
+++ config/rs6000/sysv4.h	(working copy)
@@ -23,10 +23,6 @@ 
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-/* Header files should be C++ aware in general.  */
-#undef  NO_IMPLICIT_EXTERN_C
-#define NO_IMPLICIT_EXTERN_C
-
 /* Yes!  We are ELF.  */
 #define	TARGET_OBJECT_FORMAT OBJECT_ELF
 
Index: config/rtems.h
===================================================================
--- config/rtems.h	(revision 262020)
+++ config/rtems.h	(working copy)
@@ -22,10 +22,6 @@ 
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-/* The system headers under RTEMS are C++-aware.  */
-#undef NO_IMPLICIT_EXTERN_C
-#define NO_IMPLICIT_EXTERN_C
-
 /*
  * Dummy start/end specification to let linker work as
  * needed by autoconf scripts using this compiler.
Index: config/s390/tpf.h
===================================================================
--- config/s390/tpf.h	(revision 262020)
+++ config/s390/tpf.h	(working copy)
@@ -30,7 +30,6 @@  along with GCC; see the file COPYING3.
 #define ASM_APP_ON "#APP\n"
 #undef ASM_APP_OFF
 #define ASM_APP_OFF "#NO_APP\n"
-#define NO_IMPLICIT_EXTERN_C
 #define TARGET_POSIX_IO
 
 #undef  SIZE_TYPE
Index: config/sh/newlib.h
===================================================================
--- config/sh/newlib.h	(revision 262020)
+++ config/sh/newlib.h	(working copy)
@@ -23,7 +23,3 @@  along with GCC; see the file COPYING3.
 
 #undef LIB_SPEC
 #define LIB_SPEC "-lc -lgloss"
-
-#undef  NO_IMPLICIT_EXTERN_C
-#define NO_IMPLICIT_EXTERN_C 1
-
Index: config/sol2.h
===================================================================
--- config/sol2.h	(revision 262020)
+++ config/sol2.h	(working copy)
@@ -423,9 +423,6 @@  along with GCC; see the file COPYING3.
    produce the same format.  */
 #define NM_FLAGS "-png"
 
-/* The system headers under Solaris 2 are C++-aware since 2.0.  */
-#define NO_IMPLICIT_EXTERN_C
-
 #define STDC_0_IN_SYSTEM_HEADERS 1
 
 /* Support Solaris-specific format checking for cmn_err.  */
Index: config/sparc/openbsd64.h
===================================================================
--- config/sparc/openbsd64.h	(revision 262020)
+++ config/sparc/openbsd64.h	(working copy)
@@ -41,9 +41,6 @@  along with GCC; see the file COPYING3.
     }						\
   while (0)
 
-/* Inherited from sp64-elf.  */
-#undef NO_IMPLICIT_EXTERN_C
-
 #undef ASM_SPEC
 #define ASM_SPEC "\
 -s %{" FPIE_OR_FPIC_SPEC ":-K PIC} \
Index: config/sparc/sp-elf.h
===================================================================
--- config/sparc/sp-elf.h	(revision 262020)
+++ config/sparc/sp-elf.h	(working copy)
@@ -18,9 +18,6 @@  You should have received a copy of the G
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-/* Don't assume anything about the header files.  */
-#define NO_IMPLICIT_EXTERN_C
-
 /* It's safe to pass -s always, even if -g is not used.  */
 #undef ASM_SPEC
 #define ASM_SPEC \
Index: config/sparc/sp64-elf.h
===================================================================
--- config/sparc/sp64-elf.h	(revision 262020)
+++ config/sparc/sp64-elf.h	(working copy)
@@ -27,9 +27,6 @@  along with GCC; see the file COPYING3.
 #undef SPARC_DEFAULT_CMODEL
 #define SPARC_DEFAULT_CMODEL CM_EMBMEDANY
 
-/* Don't assume anything about the header files.  */
-#define NO_IMPLICIT_EXTERN_C
-
 #undef ASM_SPEC
 #define ASM_SPEC "\
 -s %{" FPIE_OR_FPIC_SPEC ":-K PIC} \
Index: config/spu/spu.h
===================================================================
--- config/spu/spu.h	(revision 262020)
+++ config/spu/spu.h	(working copy)
@@ -483,8 +483,6 @@  do {									\
 
 #define FUNCTION_MODE QImode
 
-#define NO_IMPLICIT_EXTERN_C 1
-
 
 /* Address spaces.  */
 #define ADDR_SPACE_EA	1
Index: config/stormy16/stormy16.h
===================================================================
--- config/stormy16/stormy16.h	(revision 262020)
+++ config/stormy16/stormy16.h	(working copy)
@@ -476,5 +476,3 @@  enum reg_class
 #define Pmode HImode
 
 #define FUNCTION_MODE HImode
-
-#define NO_IMPLICIT_EXTERN_C
Index: config/v850/v850.h
===================================================================
--- config/v850/v850.h	(revision 262020)
+++ config/v850/v850.h	(working copy)
@@ -851,12 +851,6 @@  extern const char * GHS_current_section_
 
 #define TARGET_ASM_INIT_SECTIONS v850_asm_init_sections
 
-/* Define this so that the cc1plus will not think that system header files
-   need an implicit 'extern "C" { ... }' assumed.  This breaks testing C++
-   in a build directory where the libstdc++ header files are found via a
-   -isystem <path-to-build-dir>.  */
-#define NO_IMPLICIT_EXTERN_C
-
 #define ADJUST_INSN_LENGTH(INSN, LENGTH) \
   ((LENGTH) = v850_adjust_insn_length ((INSN), (LENGTH)))
 
Index: config/visium/visium.h
===================================================================
--- config/visium/visium.h	(revision 262020)
+++ config/visium/visium.h	(working copy)
@@ -1211,14 +1211,6 @@  do									\
    machines this should be `QImode'. */
 #define FUNCTION_MODE SImode
 
-/* `NO_IMPLICIT_EXTERN_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 C++, which is to pretend that the file's contents are
-   enclosed in `extern "C" {...}'. */
-#define NO_IMPLICIT_EXTERN_C
-
 /* Dividing the Output into Sections (Texts, Data, ...)
 
    An object file is divided into sections containing different types
Index: config/vx-common.h
===================================================================
--- config/vx-common.h	(revision 262020)
+++ config/vx-common.h	(working copy)
@@ -18,10 +18,6 @@  You should have received a copy of the G
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-/* VxWorks headers are C++-aware.  */
-#undef  NO_IMPLICIT_EXTERN_C
-#define NO_IMPLICIT_EXTERN_C
-
 /* Most of these will probably be overridden by subsequent headers.  We
    undefine them here just in case, and define VXWORKS_ versions of each,
    to be used in port-specific vxworks.h.  */
Index: config/xtensa/elf.h
===================================================================
--- config/xtensa/elf.h	(revision 262020)
+++ config/xtensa/elf.h	(working copy)
@@ -20,9 +20,6 @@  along with GCC; see the file COPYING3.
 
 #define TARGET_SECTION_TYPE_FLAGS xtensa_multibss_section_type_flags
 
-/* Don't assume anything about the header files.  */
-#define NO_IMPLICIT_EXTERN_C
-
 #undef ASM_APP_ON
 #define ASM_APP_ON "#APP\n"
 
Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 262020)
+++ cp/decl.c	(working copy)
@@ -967,7 +967,7 @@  decls_match (tree newdecl, tree olddecl,
 	{
 	  if (!prototype_p (f2) && DECL_EXTERN_C_P (olddecl)
 	      && (DECL_BUILT_IN (olddecl)
-#ifndef NO_IMPLICIT_EXTERN_C
+#ifdef SYSTEM_IMPLICIT_EXTERN_C
 		  || (DECL_IN_SYSTEM_HEADER (newdecl) && !DECL_CLASS_SCOPE_P (newdecl))
 		  || (DECL_IN_SYSTEM_HEADER (olddecl) && !DECL_CLASS_SCOPE_P (olddecl))
 #endif
@@ -977,7 +977,7 @@  decls_match (tree newdecl, tree olddecl,
 	      if (p1 == void_list_node)
 		TREE_TYPE (newdecl) = TREE_TYPE (olddecl);
 	    }
-#ifndef NO_IMPLICIT_EXTERN_C
+#ifdef SYSTEM_IMPLICIT_EXTERN_C
 	  else if (!prototype_p (f1)
 		   && (DECL_EXTERN_C_P (olddecl)
 		       && DECL_IN_SYSTEM_HEADER (olddecl)
Index: cp/parser.c
===================================================================
--- cp/parser.c	(revision 262020)
+++ cp/parser.c	(working copy)
@@ -21349,7 +21349,7 @@  cp_parser_parameter_declaration_clause (
   else if (token->type == CPP_CLOSE_PAREN)
     /* There are no parameters.  */
     {
-#ifndef NO_IMPLICIT_EXTERN_C
+#ifdef SYSTEM_IMPLICIT_EXTERN_C
       if (in_system_header_at (input_location)
 	  && current_class_type == NULL
 	  && current_lang_name == lang_name_c)
Index: doc/cpp.texi
===================================================================
--- doc/cpp.texi	(revision 262020)
+++ doc/cpp.texi	(working copy)
@@ -3735,7 +3735,7 @@  so certain warnings should be suppressed
 @item 4
 This indicates that the following text should be treated as being
 wrapped in an implicit @code{extern "C"} block.
-@c maybe cross reference NO_IMPLICIT_EXTERN_C
+@c maybe cross reference SYSTEM_IMPLICIT_EXTERN_C
 @end table
 
 As an extension, the preprocessor accepts linemarkers in non-assembler
Index: doc/extend.texi
===================================================================
--- doc/extend.texi	(revision 262020)
+++ doc/extend.texi	(working copy)
@@ -23450,7 +23450,7 @@  deprecated.   @xref{Deprecated Features}
 
 @item Implicit C language
 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
-scope to set the language.  On such systems, all header files are
+scope to set the language.  On such systems, all system header files are
 implicitly scoped inside a C language scope.  Also, an empty prototype
 @code{()} is treated as an unspecified number of arguments, rather
 than no arguments, as C++ demands.
Index: doc/tm.texi
===================================================================
--- doc/tm.texi	(revision 262020)
+++ doc/tm.texi	(working copy)
@@ -11149,11 +11149,10 @@  Define this hook to return the name of a
 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
-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
-C++, which is to pretend that the file's contents are enclosed in
-@samp{extern "C" @{@dots{}@}}.
+@defmac SYSTEM_IMPLICIT_EXTERN_C
+Define this macro if the system header files do not support C++@.
+This macro handles system header files by pretending that system
+header files are enclosed in @samp{extern "C" @{@dots{}@}}.
 @end defmac
 
 @findex #pragma
Index: doc/tm.texi.in
===================================================================
--- doc/tm.texi.in	(revision 262020)
+++ doc/tm.texi.in	(working copy)
@@ -7657,11 +7657,10 @@  files @code{__STDC__} will always expand
 
 @hook TARGET_CXX_IMPLICIT_EXTERN_C
 
-@defmac NO_IMPLICIT_EXTERN_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
-C++, which is to pretend that the file's contents are enclosed in
-@samp{extern "C" @{@dots{}@}}.
+@defmac SYSTEM_IMPLICIT_EXTERN_C
+Define this macro if the system header files do not support C++@.
+This macro handles system header files by pretending that system
+header files are enclosed in @samp{extern "C" @{@dots{}@}}.
 @end defmac
 
 @findex #pragma
Index: system.h
===================================================================
--- system.h	(revision 262020)
+++ system.h	(working copy)
@@ -1025,7 +1025,7 @@  extern void fancy_abort (const char *, i
 	LIBGCC2_LONG_DOUBLE_TYPE_SIZE STRUCT_VALUE			   \
 	EH_FRAME_IN_DATA_SECTION TARGET_FLT_EVAL_METHOD_NON_DEFAULT	   \
 	JCR_SECTION_NAME TARGET_USE_JCR_SECTION SDB_DEBUGGING_INFO	   \
-	SDB_DEBUG
+	SDB_DEBUG NO_IMPLICIT_EXTERN_C
 
 /* Hooks that are no longer used.  */
  #pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE	\