re PR c++/41020 (Can't declare an extern "C" friend of a builtin function)

Fix PR c++/41020

gcc/cp/ChangeLog:

	PR c++/41020
	* decl.c (decls_match): Use DECL_IS_BUILTIN instead of
	DECL_BUILT_IN.

gcc/testsuite/ChangeLog:
	PR c++/41020
	* g++.dg/lookup/extern-c-redecl2.C: New test.
	* g++.dg/lookup/extern-c-redecl3.C: Likewise.
	* g++.dg/lookup/extern-c-redecl4.C: Likewise.
	* g++.dg/lookup/extern-c-redecl5.C: Likewise.

From-SVN: r153552
This commit is contained in:
Dodji Seketeli 2009-10-26 14:40:16 +00:00 committed by Dodji Seketeli
parent 842809179e
commit a0ff862096
7 changed files with 95 additions and 1 deletions

View file

@ -1,3 +1,9 @@
2009-10-26 Dodji Seketeli <dodji@redhat.com>
PR c++/41020
* decl.c (decls_match): Use DECL_IS_BUILTIN instead of
DECL_BUILT_IN.
2009-10-23 Dodji Seketeli <dodji@redhat.com>
PR c++/40808

View file

@ -935,7 +935,7 @@ decls_match (tree newdecl, tree olddecl)
#ifdef NO_IMPLICIT_EXTERN_C
/* A new declaration doesn't match a built-in one unless it
is also extern "C". */
if (DECL_BUILT_IN (olddecl)
if (DECL_IS_BUILTIN (olddecl)
&& DECL_EXTERN_C_P (olddecl) && !DECL_EXTERN_C_P (newdecl))
return 0;
#endif

View file

@ -1,3 +1,11 @@
2009-10-26 Dodji Seketeli <dodji@redhat.com>
PR c++/41020
* g++.dg/lookup/extern-c-redecl2.C: New test.
* g++.dg/lookup/extern-c-redecl3.C: Likewise.
* g++.dg/lookup/extern-c-redecl4.C: Likewise.
* g++.dg/lookup/extern-c-redecl5.C: Likewise.
2009-10-26 Michael Matz <matz@suse.de>
PR tree-optimization/41783

View file

@ -0,0 +1,21 @@
// Contributed by Dodji Seketeli <dodji@redhat.com>
// Origin PR c++/41020
// { dg-do compile }
extern "C"
{
int fork (void);
}
class frok
{
int this_errno;
friend int fork (void);
};
extern "C" int
fork (void)
{
frok grouped;
return grouped.this_errno;
}

View file

@ -0,0 +1,22 @@
// Contributed by Dodji Seketeli <dodji@redhat.com>
// Origin: PR c++/41020
// { dg-do compile }
// { dg-final { scan-assembler-not "call\[\t \]+_Z4forkv" } }
// { dg-final { scan-assembler "call\[\t \]+fork" } }
extern "C" int fork (void);
void
foo ()
{
extern int fork (void);
fork ();
}
extern "C"
int
fork (void)
{
return 0;
}

View file

@ -0,0 +1,19 @@
// Contributed by Dodji Seketeli <dodji@redhat.com>
// Origin: PR c++/41020
// Avoid the "-ansi -pedantic" option
// { dg-options "" }
// { dg-do compile }
// { dg-final { scan-assembler "call\[\t \]+_Z4forkv" } }
class frok
{
int this_errno;
friend int fork (void);
};
void
foo ()
{
fork ();
}

View file

@ -0,0 +1,18 @@
// Contributed by Dodji Seketeli <dodji@redhat.com>
// Origin: PR c++/41020
// { dg-do compile }
class frok
{
int this_errno;
friend int fork (void); // { dg-error "previous declaration .*?C++. linkage" }
};
extern "C" int
fork (void) // { dg-error "conflicts with new declaration .*?C. linkage" }}
{
frok grouped;
return grouped.this_errno;
}