Commit 7ecfb66
authored
[Clang][Sema] Correctly look up primary template for variable template specializations (#80359)
Consider the following:
```
namespace N0 {
namespace N1 {
template<typename T>
int x1 = 0;
}
using namespace N1;
}
template<>
int N0::x1<int>;
```
According to [dcl.meaning.general] p3.3:
> - If the _declarator_ declares an explicit instantiation or a partial
or explicit specialization, the _declarator_ does not bind a name. If it
declares a class member, the terminal name of the _declarator-id_ is not
looked up; otherwise, **only those lookup results that are nominable in
`S` are considered when identifying any function template specialization
being declared**.
In particular, the requirement for lookup results to be nominal in the
lookup context of the terminal name of the _declarator-id_ only applies
to function template specializations -- not variable template
specializations. We currently reject the above declaration, but we do
(correctly) accept it if the using-directive is replaced with a `using`
declaration naming `N0::N1::x1`. This patch makes it so the above
specialization is (correctly) accepted.1 parent 7b08b43 commit 7ecfb66
File tree
5 files changed
+130
-19
lines changed- clang
- docs
- include/clang/Sema
- lib/Sema
- test/CXX/dcl.decl/dcl.meaning/dcl.meaning.general
5 files changed
+130
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
163 | 166 | | |
164 | 167 | | |
165 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8456 | 8456 | | |
8457 | 8457 | | |
8458 | 8458 | | |
8459 | | - | |
| 8459 | + | |
8460 | 8460 | | |
8461 | 8461 | | |
8462 | 8462 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7727 | 7727 | | |
7728 | 7728 | | |
7729 | 7729 | | |
7730 | | - | |
| 7730 | + | |
7731 | 7731 | | |
7732 | 7732 | | |
7733 | 7733 | | |
| |||
8070 | 8070 | | |
8071 | 8071 | | |
8072 | 8072 | | |
8073 | | - | |
8074 | | - | |
| 8073 | + | |
| 8074 | + | |
8075 | 8075 | | |
8076 | 8076 | | |
8077 | 8077 | | |
| |||
8086 | 8086 | | |
8087 | 8087 | | |
8088 | 8088 | | |
8089 | | - | |
| 8089 | + | |
| 8090 | + | |
8090 | 8091 | | |
8091 | 8092 | | |
8092 | 8093 | | |
8093 | 8094 | | |
8094 | 8095 | | |
8095 | 8096 | | |
8096 | 8097 | | |
8097 | | - | |
| 8098 | + | |
8098 | 8099 | | |
8099 | 8100 | | |
8100 | 8101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4601 | 4601 | | |
4602 | 4602 | | |
4603 | 4603 | | |
4604 | | - | |
4605 | | - | |
4606 | | - | |
| 4604 | + | |
| 4605 | + | |
| 4606 | + | |
4607 | 4607 | | |
4608 | 4608 | | |
4609 | 4609 | | |
| |||
4783 | 4783 | | |
4784 | 4784 | | |
4785 | 4785 | | |
4786 | | - | |
4787 | | - | |
4788 | | - | |
4789 | | - | |
4790 | | - | |
4791 | | - | |
4792 | | - | |
4793 | | - | |
4794 | | - | |
| 4786 | + | |
| 4787 | + | |
| 4788 | + | |
| 4789 | + | |
| 4790 | + | |
4795 | 4791 | | |
4796 | | - | |
4797 | 4792 | | |
4798 | 4793 | | |
4799 | 4794 | | |
| |||
Lines changed: 112 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
0 commit comments