]> granicus.if.org Git - clang/commitdiff
Don't warn about function templates or function template specializations.
authorAnders Carlsson <andersca@mac.com>
Wed, 9 Dec 2009 03:44:46 +0000 (03:44 +0000)
committerAnders Carlsson <andersca@mac.com>
Wed, 9 Dec 2009 03:44:46 +0000 (03:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90943 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaCXX/warn-missing-prototypes.cpp

index 392360f5aa8a0053a9c99b215777e4db31df6705..617adfe36300aa8e84e0eec10958604650edbbc1 100644 (file)
@@ -3998,23 +3998,31 @@ static bool ShouldWarnAboutMissingPrototype(const FunctionDecl *FD) {
   // 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()) {
index 481547036e4c7b0a93debee784f546dd478081a0..079a83725223f924c84f23af154f81c965d5bf8b 100644 (file)
@@ -7,13 +7,20 @@ namespace NS {
 }
 
 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>();