Remove warning about shadowing a built-in; built-ins aren't actually

considered to be a part of the translation unit unless they're named
in a way that brings them into existence.

llvm-svn: 98729
This commit is contained in:
Douglas Gregor 2010-03-17 16:03:44 +00:00
parent 4ad3da2843
commit 319aa6c4b5
3 changed files with 3 additions and 12 deletions

View File

@ -113,8 +113,7 @@ def warn_decl_shadow :
"local variable|"
"variable in %2|"
"static data member of %2|"
"field of %2|"
"global built-in function}1">,
"field of %2}1">,
InGroup<Shadow>, DefaultIgnore;
// C++ using declarations

View File

@ -2482,16 +2482,8 @@ void Sema::DiagnoseShadow(NamedDecl* D, const LookupResult& R) {
DeclarationName Name = D->getDeclName();
// Return if lookup has no result.
if (R.getResultKind() != LookupResult::Found) {
// Emit warning for built-in shadowing.
if (Name.getAsIdentifierInfo() &&
Name.getAsIdentifierInfo()->getBuiltinID())
Diag(D->getLocation(), diag::warn_decl_shadow)
<< Name
<< 4 // global builtin
<< Context.getTranslationUnitDecl();
if (R.getResultKind() != LookupResult::Found)
return;
}
// Return if not variable decl.
NamedDecl* ShadowedDecl = R.getFoundDecl();

View File

@ -16,5 +16,5 @@ void foo() {
}
}
int __sync_fetch_and_add; // expected-warning {{declaration shadows a global built-in function}}
int sin; // okay; 'sin' has not been declared, even though it's a builtin.
}