]> granicus.if.org Git - clang/commitdiff
Before checking bitfield initialization, make sure that neither the
authorDouglas Gregor <dgregor@apple.com>
Fri, 4 Feb 2011 13:09:01 +0000 (13:09 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 4 Feb 2011 13:09:01 +0000 (13:09 +0000)
bit-field width nor the initializer value are type- or
value-dependent. Fixes PR8712.

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

lib/Sema/SemaChecking.cpp
test/SemaTemplate/instantiate-field.cpp

index 24ce72032cef00d413d03daa995d83ff9790061e..24dcfb62a1f157566c0395221b49bd49bdf8d82d 100644 (file)
@@ -2643,6 +2643,13 @@ bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init,
   if (Bitfield->getType()->isBooleanType())
     return false;
 
+  // Ignore value- or type-dependent expressions.
+  if (Bitfield->getBitWidth()->isValueDependent() ||
+      Bitfield->getBitWidth()->isTypeDependent() ||
+      Init->isValueDependent() ||
+      Init->isTypeDependent())
+    return false;
+
   Expr *OriginalInit = Init->IgnoreParenImpCasts();
 
   llvm::APSInt Width(32);
index d825cd7cc613c4ca7654faca714ea0eb8f5613cd..a148ee4e55ed925564c99ec8205ae68e1470036d 100644 (file)
@@ -90,3 +90,15 @@ namespace PR7355 {
 
   A<int> ai; // expected-note{{in instantiation of}}
 }
+
+namespace PR8712 {
+  template <int dim>
+  class B {
+  public:
+    B(const unsigned char i);
+    unsigned char value : (dim > 0 ? dim : 1);
+  };
+
+  template <int dim>
+  inline B<dim>::B(const unsigned char i) : value(i) {}
+}