[PATCH] D120881: [Clang] Diagnose invalid member variable with template parameters
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 3 05:14:08 PST 2022
aaron.ballman added a comment.
Thanks for looking into this, that's a rather amusing bug.
================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:3398-3399
+ if (isInstField &&
+ D.getName().getKind() == UnqualifiedIdKind::IK_TemplateId) {
+ Diag(D.getIdentifierLoc(), diag::err_member_with_template_arguments)
----------------
No need to look at `isInstField`, it's already tested above on line 3365.
================
Comment at: clang/test/SemaCXX/class.cpp:219
+struct S {
+ int i<0>; // expected-error {{member 'i' cannot have template arguments}}
+ int j<int>; // expected-error {{member 'j' cannot have template arguments}}
----------------
Can you also add test cases for:
```
static int k<12>;
void f<12>();
```
To make sure we diagnose it the same way, both in a non-template class and within a templated class.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120881/new/
https://reviews.llvm.org/D120881
More information about the cfe-commits
mailing list