r190441 - Ignore noreturn when checking function template specializations

Reid Kleckner reid at kleckner.net
Tue Sep 10 15:21:37 PDT 2013


Author: rnk
Date: Tue Sep 10 17:21:37 2013
New Revision: 190441

URL: http://llvm.org/viewvc/llvm-project?rev=190441&view=rev
Log:
Ignore noreturn when checking function template specializations

As requested when applying the same logic to calling conventions.

Reviewers: rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D1634

Added:
    cfe/trunk/test/SemaTemplate/function-template-specialization-noreturn.cpp
Modified:
    cfe/trunk/lib/Sema/SemaTemplate.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=190441&r1=190440&r2=190441&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Tue Sep 10 17:21:37 2013
@@ -6415,12 +6415,15 @@ bool Sema::CheckFunctionTemplateSpeciali
         }
       }
 
-      // Ignore differences in calling convention until decl merging.
+      // Ignore differences in calling convention and noreturn until decl
+      // merging.
       const FunctionProtoType *TmplFT =
           TmplFD->getType()->castAs<FunctionProtoType>();
-      if (FPT->getCallConv() != TmplFT->getCallConv()) {
+      if (FPT->getCallConv() != TmplFT->getCallConv() ||
+          FPT->getNoReturnAttr() != TmplFT->getNoReturnAttr()) {
         FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
         EPI.ExtInfo = EPI.ExtInfo.withCallingConv(TmplFT->getCallConv());
+        EPI.ExtInfo = EPI.ExtInfo.withNoReturn(TmplFT->getNoReturnAttr());
         FT = Context.getFunctionType(FPT->getResultType(), FPT->getArgTypes(),
                                      EPI);
       }

Added: cfe/trunk/test/SemaTemplate/function-template-specialization-noreturn.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/function-template-specialization-noreturn.cpp?rev=190441&view=auto
==============================================================================
--- cfe/trunk/test/SemaTemplate/function-template-specialization-noreturn.cpp (added)
+++ cfe/trunk/test/SemaTemplate/function-template-specialization-noreturn.cpp Tue Sep 10 17:21:37 2013
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Split from function-template-specialization.cpp because the noreturn warning
+// requires analysis-based warnings, which the other errors in that test case
+// disable.
+
+template <int N> void __attribute__((noreturn)) f3() { __builtin_unreachable(); }
+template <> void f3<1>() { } // expected-warning {{function declared 'noreturn' should not return}}





More information about the cfe-commits mailing list