]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/37276 (Trouble with some (C99?) math builtins and namespace std)
authorJason Merrill <jason@redhat.com>
Tue, 14 Jul 2009 18:16:03 +0000 (14:16 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 14 Jul 2009 18:16:03 +0000 (14:16 -0400)
PR c++/37276
* decl.c (decls_match): A non-extern-C declaration doesn't match
a builtin extern-C declaration.

From-SVN: r149638

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/builtin5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/other/error22.C
gcc/testsuite/g++.dg/warn/Warray-bounds.C
gcc/testsuite/gcc.dg/compat/compat-common.h

index d43341b8f6e95aa2a9660a227451f76e90cc7de1..31970570601c5647aa84692ee328d091506cf3e1 100644 (file)
@@ -1,5 +1,9 @@
 2009-07-14  Jason Merrill  <jason@redhat.com>
 
+       PR c++/37276
+       * decl.c (decls_match): A non-extern-C declaration doesn't match
+       a builtin extern-C declaration.
+
        PR c++/40746
        * name-lookup.c (qualified_lookup_using_namespace): Don't stop
        looking in used namespaces just because we found something on
@@ -8,8 +12,6 @@
        PR c++/40740
        * semantics.c (perform_koenig_lookup): Handle empty template args.
 
-2009-07-13  Jason Merrill  <jason@redhat.com>
-
        * call.c (build_over_call): Use can_trust_pointer_alignment.
 
 2009-07-14  Dodji Seketeli  <dodji@redhat.com>
index d7a0e0d9693099fc31a9ddb8ba26a06bbd6fb3ee..e1b6678ea2d037f8ddcf3f207b8b7803a98645f8 100644 (file)
@@ -932,6 +932,14 @@ decls_match (tree newdecl, tree olddecl)
                && DECL_EXTERN_C_P (olddecl)))
        return 0;
 
+#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)
+         && DECL_EXTERN_C_P (olddecl) && !DECL_EXTERN_C_P (newdecl))
+       return 0;
+#endif
+
       if (TREE_CODE (f1) != TREE_CODE (f2))
        return 0;
 
index 1fa70edf74d9f7648ec78cbd578dde87ad484425..75cd8c0632deb0954ad7b9b12b72e4f79f7b641c 100644 (file)
@@ -1,5 +1,11 @@
 2009-07-14  Jason Merrill  <jason@redhat.com>
 
+       PR c++/37276
+       * g++.dg/lookup/builtin5.C: New.
+       * g++.dg/other/error22.C: Add missing extern "C".
+       * g++.dg/warn/Warray-bounds.C: Likewise.
+       * gcc.dg/compat/compat-common.h: Likewise.
+
        PR c++/40746
        * g++.dg/lookup/using20.C: New.
 
diff --git a/gcc/testsuite/g++.dg/lookup/builtin5.C b/gcc/testsuite/g++.dg/lookup/builtin5.C
new file mode 100644 (file)
index 0000000..1bd67dc
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/37276
+
+// { dg-final { scan-assembler "_ZSt5atanhd" } }
+
+namespace std
+{
+  inline double
+  atanh(double __x)
+  { return __builtin_atanh(__x); }
+}
+
+int main()
+{
+  std::atanh(.3);
+  return 0;
+}
index 8b7a9e9371473f0aeb2213093b3443fd844158f3..225dcae8214d9527238b2ad7922e538d03b48b46 100644 (file)
@@ -1,7 +1,7 @@
 // PR c++/34394
 // { dg-do compile }
 
-extern double fabs (double);
+extern "C" double fabs (double);
 
 void foo (double x)
 {
index d53af52148605fef7bbb1626f2907367cfd021c2..61c7c5d8e32ea91c4dc97555d53cbbbc31dadf07 100644 (file)
@@ -3,8 +3,9 @@
 
 int a[10];
 
+extern "C" __SIZE_TYPE__ strlen(const char *s);
+
 static inline int n(void) {
-    __SIZE_TYPE__ strlen(const char *s);
     return strlen("12345");
 }
 
index 40d4e08f9f179c7efaa7767724ba19eae4677bf6..8a92ea3e606a8e975e3240b4b3744a7d798046b9 100644 (file)
@@ -47,5 +47,9 @@
 #endif
 #endif
 
+#ifdef __cplusplus
+extern "C" void abort (void);
+#else
 extern void abort (void);
+#endif
 extern int fails;