Skip to content

Commit 0729ae4

Browse files
committed
[Clang] disallow use of attributes before extern template declarations
1 parent 257b727 commit 0729ae4

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ related warnings within the method body.
301301
particularly relevant for AMDGPU targets, where they map to corresponding IR
302302
metadata.
303303

304+
- Clang now disallows the use of attributes applied before an
305+
``extern template`` declaration (#GH79893).
306+
304307
Improvements to Clang's diagnostics
305308
-----------------------------------
306309

clang/lib/Parse/Parser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,7 @@ Parser::ParseExternalDeclaration(ParsedAttributes &Attrs,
10491049

10501050
case tok::kw_extern:
10511051
if (getLangOpts().CPlusPlus && NextToken().is(tok::kw_template)) {
1052+
ProhibitAttributes(Attrs);
10521053
// Extern templates
10531054
SourceLocation ExternLoc = ConsumeToken();
10541055
SourceLocation TemplateLoc = ConsumeToken();
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %clang_cc1 -std=c++17 -verify %s
2+
3+
template <class>
4+
struct S {};
5+
6+
[[deprecated]] extern template struct S<int>; // expected-error {{an attribute list cannot appear here}}

0 commit comments

Comments
 (0)