[cfe-commits] r98729 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDecl.cpp test/Sema/warn-shadow.c

Douglas Gregor dgregor at apple.com
Wed Mar 17 09:03:44 PDT 2010


Author: dgregor
Date: Wed Mar 17 11:03:44 2010
New Revision: 98729

URL: http://llvm.org/viewvc/llvm-project?rev=98729&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/Sema/warn-shadow.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=98729&r1=98728&r2=98729&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Mar 17 11:03:44 2010
@@ -113,8 +113,7 @@
           "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

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=98729&r1=98728&r2=98729&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Mar 17 11:03:44 2010
@@ -2482,16 +2482,8 @@
   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();

Modified: cfe/trunk/test/Sema/warn-shadow.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-shadow.c?rev=98729&r1=98728&r2=98729&view=diff
==============================================================================
--- cfe/trunk/test/Sema/warn-shadow.c (original)
+++ cfe/trunk/test/Sema/warn-shadow.c Wed Mar 17 11:03:44 2010
@@ -16,5 +16,5 @@
     }
   }
 
-  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.
 }





More information about the cfe-commits mailing list