aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-02-04 13:09:01 +0000
committerDouglas Gregor <dgregor@apple.com>2011-02-04 13:09:01 +0000
commit46ff3034d14aaa92b530e96480741f3d5d458cb8 (patch)
treeb4a98b2a1e64022d0fe355828a137a71f8bd4153
parentfdc13a00a0077383eabf6d994de10203568415bb (diff)
Before checking bitfield initialization, make sure that neither the
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
-rw-r--r--lib/Sema/SemaChecking.cpp7
-rw-r--r--test/SemaTemplate/instantiate-field.cpp12
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 24ce72032c..24dcfb62a1 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -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);
diff --git a/test/SemaTemplate/instantiate-field.cpp b/test/SemaTemplate/instantiate-field.cpp
index d825cd7cc6..a148ee4e55 100644
--- a/test/SemaTemplate/instantiate-field.cpp
+++ b/test/SemaTemplate/instantiate-field.cpp
@@ -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) {}
+}