[cfe-commits] r172285 - in /cfe/trunk: lib/Sema/SemaInit.cpp test/SemaCXX/cxx98-compat.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Fri Jan 11 17:05:20 PST 2013
Author: rsmith
Date: Fri Jan 11 19:05:20 2013
New Revision: 172285
URL: http://llvm.org/viewvc/llvm-project?rev=172285&view=rev
Log:
Only produce one -Wc++98-compat warning when initializing a reference from an init list with multiple elements.
Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/SemaCXX/cxx98-compat.cpp
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=172285&r1=172284&r2=172285&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Fri Jan 11 19:05:20 2013
@@ -4877,6 +4877,7 @@
if (S.getLangOpts().CPlusPlus11 && Entity.getType()->isReferenceType() &&
Args.size() == 1 && isa<InitListExpr>(Args[0]) &&
+ cast<InitListExpr>(Args[0])->getNumInits() == 1 &&
Entity.getKind() != InitializedEntity::EK_Parameter) {
// Produce a C++98 compatibility warning if we are initializing a reference
// from an initializer list. For parameters, we produce a better warning
Modified: cfe/trunk/test/SemaCXX/cxx98-compat.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx98-compat.cpp?rev=172285&r1=172284&r2=172285&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx98-compat.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx98-compat.cpp Fri Jan 11 19:05:20 2013
@@ -8,6 +8,8 @@
initializer_list(T*, size_t);
T *p;
size_t n;
+ T *begin();
+ T *end();
};
}
@@ -103,6 +105,11 @@
int xs[] = {1, 2, 3};
for (int &a : xs) { // expected-warning {{range-based for loop is incompatible with C++98}}
}
+ for (auto &b : {1, 2, 3}) {
+ // expected-warning at -1 {{range-based for loop is incompatible with C++98}}
+ // expected-warning at -2 {{'auto' type specifier is incompatible with C++98}}
+ // expected-warning at -3 {{initialization of initializer_list object is incompatible with C++98}}
+ }
}
struct InClassInit {
More information about the cfe-commits
mailing list