aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Austern <austern@apple.com>2004-12-09 21:07:01 +0000
committerMatt Austern <austern@gcc.gnu.org>2004-12-09 21:07:01 +0000
commitf80f1bab3860f8a933d5319f668a29ea9edf54fe (patch)
tree816f18bec22c7dd80290aa745fb494c38dac8877
parent5a19910e7cdbc5f2d169c7303cf48128ac2370b1 (diff)
downloadgcc-f80f1bab3860f8a933d5319f668a29ea9edf54fe.zip
gcc-f80f1bab3860f8a933d5319f668a29ea9edf54fe.tar.gz
gcc-f80f1bab3860f8a933d5319f668a29ea9edf54fe.tar.bz2
re PR c++/18514 (Alternate "asm" name ignored for redeclared builtin function imported into namespace std)
PR c++/18514 * name-lookup.c (do_nonmember_using_decl): A real function declaration takes precedence over an anticipated declaration. * g++.dg/ext/builtin1.C: New * g++.dg/ext/builtin2.C: New * g++.dg/ext/builtin3.C: New * g++.dg/ext/builtin4.C: New * g++.dg/ext/builtin5.C: New From-SVN: r91972
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/name-lookup.c12
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/g++.dg/ext/builtin1.C10
-rw-r--r--gcc/testsuite/g++.dg/ext/builtin2.C13
-rw-r--r--gcc/testsuite/g++.dg/ext/builtin3.C13
-rw-r--r--gcc/testsuite/g++.dg/ext/builtin4.C10
-rw-r--r--gcc/testsuite/g++.dg/ext/builtin5.C12
8 files changed, 82 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 26f4a48..83fac5a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2004-12-09 Matt Austern <austern@apple.com>
+
+ PR c++/18514
+ * name-lookup.c (do_nonmember_using_decl): A real function
+ declaration takes precedence over an anticipated declaration.
+
2004-12-09 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
* parser.c (cp_parser_member_declaration): Fix comment typo.
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index cfd3890..eb60421 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -2064,10 +2064,16 @@ do_nonmember_using_decl (tree scope, tree name, tree oldval, tree oldtype,
are the same extern "C" functions, that's ok. */
if (decls_match (new_fn, old_fn))
{
- /* If the OLD_FN was a builtin, there is now a
- real declaration. */
+ /* If the OLD_FN was a builtin, we've seen a real
+ declaration in another namespace. Use it instead.
+ Set tmp1 to NULL so we can use the existing
+ OVERLOAD logic at the end of this inner loop.
+ */
if (DECL_ANTICIPATED (old_fn))
- DECL_ANTICIPATED (old_fn) = 0;
+ {
+ gcc_assert (! DECL_ANTICIPATED (new_fn));
+ tmp1 = NULL;
+ }
break;
}
else if (!DECL_ANTICIPATED (old_fn))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index cc4f1ae..3a733f7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2004-12-09 Matt Austern <austern@apple.com>
+
+ PR c++/18514
+ * g++.dg/ext/builtin1.C: New
+ * g++.dg/ext/builtin2.C: New
+ * g++.dg/ext/builtin3.C: New
+ * g++.dg/ext/builtin4.C: New
+ * g++.dg/ext/builtin5.C: New
+
2004-12-09 Andrew Pinski <pinskia@physics.uc.edu>
PR tree-opt/18904
diff --git a/gcc/testsuite/g++.dg/ext/builtin1.C b/gcc/testsuite/g++.dg/ext/builtin1.C
new file mode 100644
index 0000000..8a53fd6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/builtin1.C
@@ -0,0 +1,10 @@
+// Test whether alternate 'asm' name is applied correctly to
+// builtin in global namespace
+
+// { dg-do compile }
+// { dg-options "" }
+// { dg-final { scan-assembler "fancy_printf" } }
+
+extern "C" int printf(char*, ...) __asm("_fancy_printf");
+
+void foo() { printf("abc"); }
diff --git a/gcc/testsuite/g++.dg/ext/builtin2.C b/gcc/testsuite/g++.dg/ext/builtin2.C
new file mode 100644
index 0000000..c741c0b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/builtin2.C
@@ -0,0 +1,13 @@
+// PR c++/18514
+// Test whether alternate 'asm' name is applied correctly to
+// builtin imported into namespace std.
+
+// { dg-do compile }
+// { dg-options "" }
+// { dg-final { scan-assembler "fancy_printf" } }
+
+extern "C" int printf(char*, ...) __asm("_fancy_printf");
+
+namespace std { using ::printf; }
+
+namespace std { void foo() { printf("abc"); } }
diff --git a/gcc/testsuite/g++.dg/ext/builtin3.C b/gcc/testsuite/g++.dg/ext/builtin3.C
new file mode 100644
index 0000000..3d06dd7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/builtin3.C
@@ -0,0 +1,13 @@
+// Verify that declaring builtin in namespace std doesn't give us
+// declaration in global namespace
+
+// { dg-do compile }
+// { dg-options "" }
+
+namespace std {
+extern "C" int printf(char*, ...);
+}
+
+void foo() {
+ printf("abc"); // { dg-error "not declared" }
+}
diff --git a/gcc/testsuite/g++.dg/ext/builtin4.C b/gcc/testsuite/g++.dg/ext/builtin4.C
new file mode 100644
index 0000000..7d6c473
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/builtin4.C
@@ -0,0 +1,10 @@
+// Verify that builtin is used when declared in global namespace
+
+// { dg-do compile }
+// { dg-options "-Wall" }
+
+extern "C" int printf(const char*,...);
+
+void foo() {
+ printf("%d"); // { dg-warning "too few arguments" }
+}
diff --git a/gcc/testsuite/g++.dg/ext/builtin5.C b/gcc/testsuite/g++.dg/ext/builtin5.C
new file mode 100644
index 0000000..2601a12
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/builtin5.C
@@ -0,0 +1,12 @@
+// Verify that builtin is used when declared in namespace std
+
+// { dg-do compile }
+// { dg-options "-Wall" }
+
+namespace std {
+ extern "C" int printf(const char*,...);
+}
+
+void foo() {
+ std::printf("%d"); // { dg-warning "too few arguments" }
+}