[cfe-commits] r124866 - in /cfe/trunk: lib/Sema/SemaChecking.cpp test/SemaTemplate/instantiate-field.cpp

Douglas Gregor dgregor at apple.com
Fri Feb 4 05:09:01 PST 2011


Author: dgregor
Date: Fri Feb  4 07:09:01 2011
New Revision: 124866

URL: http://llvm.org/viewvc/llvm-project?rev=124866&view=rev
Log:
Before checking bitfield initialization, make sure that neither the
bit-field width nor the initializer value are type- or
value-dependent. Fixes PR8712.

Modified:
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/test/SemaTemplate/instantiate-field.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=124866&r1=124865&r2=124866&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Feb  4 07:09:01 2011
@@ -2643,6 +2643,13 @@
   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);

Modified: cfe/trunk/test/SemaTemplate/instantiate-field.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-field.cpp?rev=124866&r1=124865&r2=124866&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-field.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-field.cpp Fri Feb  4 07:09:01 2011
@@ -90,3 +90,15 @@
 
   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) {}
+}





More information about the cfe-commits mailing list