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

Mikhail Maltsev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 13 10:14:45 PST 2017


miyuki 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.
----------------
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?


https://reviews.llvm.org/D41179





More information about the cfe-commits mailing list