]> granicus.if.org Git - clang/commitdiff
Sema: Variable templates cannot be static bitfield members
authorDavid Majnemer <david.majnemer@gmail.com>
Sun, 28 Dec 2014 22:51:45 +0000 (22:51 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Sun, 28 Dec 2014 22:51:45 +0000 (22:51 +0000)
We correctly forbid variables but not variable templates.  Diagnose this
case instead of crashing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224905 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/cxx1y-variable-templates_in_class.cpp

index 5737901ec6f65a8f8ad9569b776e83fb5a17a3a2..a57a9206fbb728945d9403f33cfebb74a88a24a7 100644 (file)
@@ -2164,7 +2164,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
     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)
index f6f77f01007af3d23c530b75f26014c467cd2f13..93a2095c9b8ce9437c386a7d3cf2578c81dbce74 100644 (file)
@@ -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}}
+};
+}