-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Clang][Sema] Diagnose declarative nested-name-specifiers naming alia…
…s templates (#80842) According to [expr.prim.id.qual] p3: > The _nested-name-specifier_ `::` nominates the global namespace. A _nested-name-specifier_ with a _computed-type-specifier_ nominates the type denoted by the _computed-type-specifier_, which shall be a class or enumeration type. **If a _nested-name-specifier_ `N` is declarative and has a _simple-template-id_ with a template argument list `A` that involves a template parameter, let `T` be the template nominated by `N` without `A`. `T` shall be a class template.** Meaning, the out-of-line definition of `A::f` in the following example is ill-formed: ``` template<typename T> struct A { void f(); }; template<typename T> using B = A<T>; template<typename T> void B<T>::f() { } // error: a declarative nested name specifier cannot name an alias template ``` This patch diagnoses such cases as an extension (in group `alias-template-in-declaration-name`).
- Loading branch information
1 parent
c625b99
commit fb615cf
Showing
5 changed files
with
61 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// RUN: %clang_cc1 -verify %s | ||
|
||
template<typename T> | ||
struct A { | ||
void f(); | ||
}; | ||
|
||
template<typename T> | ||
using B = A<T>; | ||
|
||
template<typename T> | ||
void B<T>::f() { } // expected-warning {{a declarative nested name specifier cannot name an alias template}} | ||
|
||
template<> | ||
void B<int>::f() { } // ok, template argument list of simple-template-id doesn't involve template parameters | ||
|
||
namespace N { | ||
|
||
template<typename T> | ||
struct D { | ||
void f(); | ||
}; | ||
|
||
template<typename T> | ||
using E = D<T>; | ||
} | ||
|
||
template<typename T> | ||
void N::E<T>::f() { } // expected-warning {{a declarative nested name specifier cannot name an alias template}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters