OSDN Git Service

Fix PR c++/41020
authordodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 26 Oct 2009 14:40:16 +0000 (14:40 +0000)
committerdodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 26 Oct 2009 14:40:16 +0000 (14:40 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153552 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/extern-c-redecl2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/lookup/extern-c-redecl5.C [new file with mode: 0644]

index 3ce735b..467f078 100644 (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
index 5eb389f..c772ca5 100644 (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
index 0b33f98..e6e9250 100644 (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
diff --git a/gcc/testsuite/g++.dg/lookup/extern-c-redecl2.C b/gcc/testsuite/g++.dg/lookup/extern-c-redecl2.C
new file mode 100644 (file)
index 0000000..055148f
--- /dev/null
@@ -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;
+}
diff --git a/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C b/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C
new file mode 100644 (file)
index 0000000..00ff4a9
--- /dev/null
@@ -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;
+}
+
diff --git a/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C b/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C
new file mode 100644 (file)
index 0000000..9dfa54d
--- /dev/null
@@ -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 ();
+}
diff --git a/gcc/testsuite/g++.dg/lookup/extern-c-redecl5.C b/gcc/testsuite/g++.dg/lookup/extern-c-redecl5.C
new file mode 100644 (file)
index 0000000..031059f
--- /dev/null
@@ -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;
+}
+