<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Abbreviated function template in extern "C" block generates error with bad location"
href="https://bugs.llvm.org/show_bug.cgi?id=47042">47042</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Abbreviated function template in extern "C" block generates error with bad location
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++2a
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>hstong@ca.ibm.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>When producing an error message about an abbreviated function template
appearing in an extern "C" block, Clang does not appear to have a proper
diagnostic location to refer to (notice the first line of the actual output
listed below).
Note: The error message itself appears to stem from words in [temp.pre] that
prohibit C language linkage for templates, although [dcl.link] doesn't apply C
language linkage to templates in the first place.
Compiler Explorer link: <a href="https://godbolt.org/z/GPcoMe">https://godbolt.org/z/GPcoMe</a>
### SOURCE (<stdin>):
extern "C" {
void g(auto) {}
void g(void) { g(42); }
}
### COMPILER INVOCATION:
clang++ -cc1 -fsyntax-only -std=c++20 -Wall -Wextra -pedantic-errors -xc++ -
### ACTUAL OUTPUT:
error: templates must have C++ linkage
<stdin>:1:1: note: extern "C" language linkage specification begins here
extern "C" {
^
<stdin>:3:18: error: no matching function for call to 'g'
void g(void) { g(42); }
^
<stdin>:3:8: note: candidate function not viable: requires 0 arguments, but 1
was provided
void g(void) { g(42); }
^
2 errors generated.
### EXPECTED OUTPUT:
(first error should point to the declarator-id of the abbreviated function
template)
### COMPILER VERSION INFO (clang++ -v):
clang version 12.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
f92e0d9384763913a745cbe9c757fbb40691dcd1)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/wandbox/clang-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>