[PATCH] Ignore noreturn when checking function template specializations

Reid Kleckner rnk at google.com
Mon Sep 9 20:21:05 PDT 2013


Hi rsmith,

As requested when applying the same logic to calling conventions.

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

Files:
  lib/Sema/SemaTemplate.cpp
  test/SemaTemplate/function-template-specialization.cpp

Index: lib/Sema/SemaTemplate.cpp
===================================================================
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -6415,12 +6415,15 @@
         }
       }
 
-      // 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);
       }
Index: test/SemaTemplate/function-template-specialization.cpp
===================================================================
--- test/SemaTemplate/function-template-specialization.cpp
+++ test/SemaTemplate/function-template-specialization.cpp
@@ -56,3 +56,6 @@
   template<>
   static void Bar(const long& input) {}  // expected-error{{explicit specialization of 'Bar' in class scope}}
 };
+
+template <int N> void __attribute__((noreturn)) f3() { __builtin_unreachable(); }
+template <> void f3<1>() { }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1634.1.patch
Type: text/x-patch
Size: 1519 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130909/d068cda4/attachment.bin>


More information about the cfe-commits mailing list