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
This commit is contained in:
Matt Austern 2004-12-09 21:07:01 +00:00 committed by Matt Austern
parent 5a19910e7c
commit f80f1bab38
8 changed files with 82 additions and 3 deletions

View File

@ -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.

View File

@ -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))

View File

@ -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

View File

@ -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"); }

View File

@ -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"); } }

View File

@ -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" }
}

View File

@ -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" }
}

View File

@ -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" }
}