[PATCH] D41179: [Sema] Diagnose template specializations with C linkage

Roger Ferrer Ibanez via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 13 11:34:34 PST 2017


rogfer01 added inline comments.


================
Comment at: lib/Sema/SemaTemplate.cpp:7021
+  // C++ [temp]p6:
+  //   A template, a template explicit specialization, and a class template
+  //   partial specialization shall not have C linkage.
----------------
miyuki wrote:
> rogfer01 wrote:
> > Can you add a test for a partial specialization? Your test for the class case only includes an explicit specialization.
> > 
> > ```lang=cpp
> > template <typename T>
> > struct A { };
> > 
> > extern "C" { 
> > 
> > template <typename T>   // I'd expect a diagnostic around here
> > struct A<T*>
> > {
> > };
> > 
> > }
> > ```
> Currently the location used for template specialization-related diagnostics is on the next line, e.g.:
> 
> ```
> /work/llvm/src/tools/clang/test/SemaTemplate/class-template-spec.cpp:242:10: error: templates must have C++ linkage
>   struct C<T*> {};
>          ^
> ```
> 
> Do we want to use a different location for this particular diagnostic?
Oh sorry, I was not precise when I put that example. I don't think it should be different in this case.


https://reviews.llvm.org/D41179





More information about the cfe-commits mailing list