[cfe-commits] r153026 - in /cfe/trunk: lib/Parse/ParseDecl.cpp test/SemaCXX/cxx98-compat.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Sun Mar 18 15:25:47 PDT 2012
Author: cornedbee
Date: Sun Mar 18 17:25:45 2012
New Revision: 153026
URL: http://llvm.org/viewvc/llvm-project?rev=153026&view=rev
Log:
Add the missing compatibility warning for braced initializers as default arguments.
Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/SemaCXX/cxx98-compat.cpp
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=153026&r1=153025&r2=153026&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Sun Mar 18 17:25:45 2012
@@ -4282,9 +4282,10 @@
Param);
ExprResult DefArgResult;
- if (Tok.is(tok::l_brace))
+ if (getLangOpts().CPlusPlus0x && Tok.is(tok::l_brace)) {
+ Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
DefArgResult = ParseBraceInitializer();
- else
+ } else
DefArgResult = ParseAssignmentExpression();
if (DefArgResult.isInvalid()) {
Actions.ActOnParamDefaultArgumentError(Param);
Modified: cfe/trunk/test/SemaCXX/cxx98-compat.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx98-compat.cpp?rev=153026&r1=153025&r2=153026&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx98-compat.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx98-compat.cpp Sun Mar 18 17:25:45 2012
@@ -39,7 +39,8 @@
[]{}(); // expected-warning {{lambda expressions are incompatible with C++98}}
}
-int InitList() {
+int InitList(int i = {}) { // expected-warning {{generalized initializer lists are incompatible with C++98}} \
+ // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}}
(void)new int {}; // expected-warning {{generalized initializer lists are incompatible with C++98}} \
// expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}}
(void)int{}; // expected-warning {{generalized initializer lists are incompatible with C++98}} \
More information about the cfe-commits
mailing list