[cfe-commits] r90943 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/warn-missing-prototypes.cpp

Anders Carlsson andersca at mac.com
Tue Dec 8 19:44:46 PST 2009


Author: andersca
Date: Tue Dec  8 21:44:46 2009
New Revision: 90943

URL: http://llvm.org/viewvc/llvm-project?rev=90943&view=rev
Log:
Don't warn about function templates or function template specializations.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/SemaCXX/warn-missing-prototypes.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=90943&r1=90942&r2=90943&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Dec  8 21:44:46 2009
@@ -3998,23 +3998,31 @@
   // Don't warn about invalid declarations.
   if (FD->isInvalidDecl())
     return false;
-  
+
   // Or declarations that aren't global.
   if (!FD->isGlobal())
     return false;
-  
+
   // Don't warn about C++ member functions.
   if (isa<CXXMethodDecl>(FD))
     return false;
-  
+
   // Don't warn about 'main'.
   if (FD->isMain())
     return false;
- 
+
   // Don't warn about inline functions.
   if (FD->isInlineSpecified())
     return false;
-  
+
+  // Don't warn about function templates.
+  if (FD->getDescribedFunctionTemplate())
+    return false;
+
+  // Don't warn about function template specializations.
+  if (FD->isFunctionTemplateSpecialization())
+    return false;
+
   bool MissingPrototype = true;
   for (const FunctionDecl *Prev = FD->getPreviousDeclaration();
        Prev; Prev = Prev->getPreviousDeclaration()) {

Modified: cfe/trunk/test/SemaCXX/warn-missing-prototypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-missing-prototypes.cpp?rev=90943&r1=90942&r2=90943&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/warn-missing-prototypes.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-missing-prototypes.cpp Tue Dec  8 21:44:46 2009
@@ -7,13 +7,20 @@
 }
 
 namespace {
-  // Should not warn about anonymous namespaces
+  // Don't warn about functions in anonymous namespaces.
   void f() { }
 }
 
 struct A {
-  // Should not warn about member functions.
+  // Don't warn about member functions.
   void f() { }
 };
 
-inline void g() { }
\ No newline at end of file
+// Don't warn about inline functions.
+inline void g() { }
+
+// Don't warn about function templates.
+template<typename> void h() { }
+
+// Don't warn when instantiating function templates.
+template void h<int>();





More information about the cfe-commits mailing list