[cfe-commits] r153995 - in /cfe/trunk: lib/Sema/SemaInit.cpp test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp
Douglas Gregor
dgregor at apple.com
Tue Apr 3 21:06:51 PDT 2012
Author: dgregor
Date: Tue Apr 3 23:06:51 2012
New Revision: 153995
URL: http://llvm.org/viewvc/llvm-project?rev=153995&view=rev
Log:
Dependent-sequence initialization of a single element can be direct
list-initialization. Loosen an over-eager assertion to fix PR12453.
Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=153995&r1=153994&r2=153995&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Apr 3 23:06:51 2012
@@ -4807,7 +4807,8 @@
move(Args));
}
assert(Kind.getKind() == InitializationKind::IK_Copy ||
- Kind.isExplicitCast());
+ Kind.isExplicitCast() ||
+ Kind.getKind() == InitializationKind::IK_DirectList);
return ExprResult(Args.release()[0]);
}
Modified: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp?rev=153995&r1=153994&r2=153995&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp Tue Apr 3 23:06:51 2012
@@ -1,5 +1,17 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
void f0() {
int &ir = { 17 }; // expected-error{{reference to type 'int' cannot bind to an initializer list}}
}
+
+namespace PR12453 {
+ template<typename T>
+ void f(int i) {
+ T x{i}; // expected-error{{non-constant-expression cannot be narrowed from type 'int' to 'float' in initializer list}} \
+ // expected-note{{override this message by inserting an explicit cast}}
+ T y{i}; // expected-error{{non-constant-expression cannot be narrowed from type 'int' to 'float' in initializer list}} \
+ // expected-note{{override this message by inserting an explicit cast}}
+ }
+
+ template void f<float>(int); // expected-note{{in instantiation of function template specialization 'PR12453::f<float>' requested here}}
+}
More information about the cfe-commits
mailing list