[cfe-commits] r134583 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiate.cpp test/SemaTemplate/member-inclass-init-value-dependent.cpp
Nick Lewycky
nicholas at mxc.ca
Wed Jul 6 19:20:13 PDT 2011
Author: nicholas
Date: Wed Jul 6 21:20:13 2011
New Revision: 134583
URL: http://llvm.org/viewvc/llvm-project?rev=134583&view=rev
Log:
In an in-class initialization, defer checks for value-dependent initialization
expressions.
Added:
cfe/trunk/test/SemaTemplate/member-inclass-init-value-dependent.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=134583&r1=134582&r2=134583&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Wed Jul 6 21:20:13 2011
@@ -1812,9 +1812,11 @@
ExprResult NewInit = SubstExpr(OldInit, TemplateArgs);
// If the initialization is no longer dependent, check it now.
- if ((OldField->getType()->isDependentType() || OldInit->isTypeDependent())
- && !NewField->getType()->isDependentType()
- && !NewInit.get()->isTypeDependent()) {
+ if ((OldField->getType()->isDependentType() || OldInit->isTypeDependent() ||
+ OldInit->isValueDependent()) &&
+ !NewField->getType()->isDependentType() &&
+ !NewInit.get()->isTypeDependent() &&
+ !NewInit.get()->isValueDependent()) {
// FIXME: handle list-initialization
SourceLocation EqualLoc = NewField->getLocation();
NewInit = PerformCopyInitialization(
Added: cfe/trunk/test/SemaTemplate/member-inclass-init-value-dependent.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/member-inclass-init-value-dependent.cpp?rev=134583&view=auto
==============================================================================
--- cfe/trunk/test/SemaTemplate/member-inclass-init-value-dependent.cpp (added)
+++ cfe/trunk/test/SemaTemplate/member-inclass-init-value-dependent.cpp Wed Jul 6 21:20:13 2011
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm-only %s
+// PR10290
+
+template<int Flags> struct foo {
+ int value = Flags && 0;
+};
+
+void test() {
+ foo<4> bar;
+}
+
More information about the cfe-commits
mailing list