r224905 - Sema: Variable templates cannot be static bitfield members
David Majnemer
david.majnemer at gmail.com
Sun Dec 28 14:51:46 PST 2014
Author: majnemer
Date: Sun Dec 28 16:51:45 2014
New Revision: 224905
URL: http://llvm.org/viewvc/llvm-project?rev=224905&view=rev
Log:
Sema: Variable templates cannot be static bitfield members
We correctly forbid variables but not variable templates. Diagnose this
case instead of crashing.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=224905&r1=224904&r2=224905&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sun Dec 28 16:51:45 2014
@@ -2164,7 +2164,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S,
if (BitWidth) {
if (Member->isInvalidDecl()) {
// don't emit another diagnostic.
- } else if (isa<VarDecl>(Member)) {
+ } else if (isa<VarDecl>(Member) || isa<VarTemplateDecl>(Member)) {
// C++ 9.6p3: A bit-field shall not be a static member.
// "static member 'A' cannot be a bit-field"
Diag(Loc, diag::err_static_not_bitfield)
Modified: cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp?rev=224905&r1=224904&r2=224905&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp Sun Dec 28 16:51:45 2014
@@ -321,3 +321,9 @@ namespace in_nested_classes {
// TODO:
}
+namespace bitfield {
+struct S {
+ template <int I>
+ static int f : I; // expected-error {{static member 'f' cannot be a bit-field}}
+};
+}
More information about the cfe-commits
mailing list