diff options
author | Jason Merrill <jason@redhat.com> | 2009-07-14 14:16:03 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2009-07-14 14:16:03 -0400 |
commit | 8353dd9a26485ad8cdc603d98efd8e711f7d2154 (patch) | |
tree | 0b8b5bc66f8f98728e58252f4589aa8898afd0df | |
parent | 3deeb3ff03b0df2812a00d6713d4d026f0f2ea7e (diff) | |
download | gcc-8353dd9a26485ad8cdc603d98efd8e711f7d2154.zip gcc-8353dd9a26485ad8cdc603d98efd8e711f7d2154.tar.gz gcc-8353dd9a26485ad8cdc603d98efd8e711f7d2154.tar.bz2 |
re PR c++/37276 (Trouble with some (C99?) math builtins and namespace std)
PR c++/37276
* decl.c (decls_match): A non-extern-C declaration doesn't match
a builtin extern-C declaration.
From-SVN: r149638
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/lookup/builtin5.C | 16 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/other/error22.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Warray-bounds.C | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/compat/compat-common.h | 4 |
7 files changed, 41 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d43341b8..3197057 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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> diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d7a0e0d..e1b6678 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1fa70ed..75cd8c06 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 0000000..1bd67dc --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/builtin5.C @@ -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; +} diff --git a/gcc/testsuite/g++.dg/other/error22.C b/gcc/testsuite/g++.dg/other/error22.C index 8b7a9e9..225dcae 100644 --- a/gcc/testsuite/g++.dg/other/error22.C +++ b/gcc/testsuite/g++.dg/other/error22.C @@ -1,7 +1,7 @@ // PR c++/34394 // { dg-do compile } -extern double fabs (double); +extern "C" double fabs (double); void foo (double x) { diff --git a/gcc/testsuite/g++.dg/warn/Warray-bounds.C b/gcc/testsuite/g++.dg/warn/Warray-bounds.C index d53af52..61c7c5d 100644 --- a/gcc/testsuite/g++.dg/warn/Warray-bounds.C +++ b/gcc/testsuite/g++.dg/warn/Warray-bounds.C @@ -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"); } diff --git a/gcc/testsuite/gcc.dg/compat/compat-common.h b/gcc/testsuite/gcc.dg/compat/compat-common.h index 40d4e08..8a92ea3 100644 --- a/gcc/testsuite/gcc.dg/compat/compat-common.h +++ b/gcc/testsuite/gcc.dg/compat/compat-common.h @@ -47,5 +47,9 @@ #endif #endif +#ifdef __cplusplus +extern "C" void abort (void); +#else extern void abort (void); +#endif extern int fails; |