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:
parent
842809179e
commit
a0ff862096
7 changed files with 95 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
21
gcc/testsuite/g++.dg/lookup/extern-c-redecl2.C
Normal file
21
gcc/testsuite/g++.dg/lookup/extern-c-redecl2.C
Normal 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;
|
||||
}
|
22
gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C
Normal file
22
gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C
Normal 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;
|
||||
}
|
||||
|
19
gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C
Normal file
19
gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C
Normal 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 ();
|
||||
}
|
18
gcc/testsuite/g++.dg/lookup/extern-c-redecl5.C
Normal file
18
gcc/testsuite/g++.dg/lookup/extern-c-redecl5.C
Normal 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;
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue