[PATCH] Ignore noreturn when checking function template specializations

Richard Smith richard at metafoo.co.uk
Tue Sep 10 15:16:11 PDT 2013


LGTM, thanks.


On Tue, Sep 10, 2013 at 3:12 PM, Reid Kleckner <rnk at google.com> wrote:

>     - Split out noreturn specialization test case to test the warning.
>
> Hi rsmith,
>
> http://llvm-reviews.chandlerc.com/D1634
>
> CHANGE SINCE LAST DIFF
>   http://llvm-reviews.chandlerc.com/D1634?vs=4155&id=4180#toc
>
> Files:
>   lib/Sema/SemaTemplate.cpp
>   test/SemaTemplate/function-template-specialization-noreturn.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-noreturn.cpp
> ===================================================================
> --- /dev/null
> +++ test/SemaTemplate/function-template-specialization-noreturn.cpp
> @@ -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}}
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130910/cea512e8/attachment.html>


More information about the cfe-commits mailing list