From: Douglas Gregor Date: Fri, 4 Feb 2011 13:09:01 +0000 (+0000) Subject: Before checking bitfield initialization, make sure that neither the X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=46ff3034d14aaa92b530e96480741f3d5d458cb8;p=clang 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 --- 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 ai; // expected-note{{in instantiation of}} } + +namespace PR8712 { + template + class B { + public: + B(const unsigned char i); + unsigned char value : (dim > 0 ? dim : 1); + }; + + template + inline B::B(const unsigned char i) : value(i) {} +}