[cfe-commits] r152721 - in /cfe/trunk: lib/Parse/ParseCXXInlineMethods.cpp lib/Parse/ParseDecl.cpp test/SemaCXX/cxx0x-initializer-scalars.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Wed Mar 14 08:54:00 PDT 2012
Author: cornedbee
Date: Wed Mar 14 10:54:00 2012
New Revision: 152721
URL: http://llvm.org/viewvc/llvm-project?rev=152721&view=rev
Log:
Parse brace initializers as default arguments. PR12236.
Modified:
cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/SemaCXX/cxx0x-initializer-scalars.cpp
Modified: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp?rev=152721&r1=152720&r2=152721&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp (original)
+++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp Wed Mar 14 10:54:00 2012
@@ -319,7 +319,11 @@
Sema::PotentiallyEvaluatedIfUsed,
LM.DefaultArgs[I].Param);
- ExprResult DefArgResult(ParseAssignmentExpression());
+ ExprResult DefArgResult;
+ if (Tok.is(tok::l_brace))
+ DefArgResult = ParseBraceInitializer();
+ else
+ DefArgResult = ParseAssignmentExpression();
if (DefArgResult.isInvalid())
Actions.ActOnParamDefaultArgumentError(LM.DefaultArgs[I].Param);
else {
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=152721&r1=152720&r2=152721&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Mar 14 10:54:00 2012
@@ -4169,6 +4169,7 @@
/// parameter-declaration: [C99 6.7.5]
/// declaration-specifiers declarator
/// [C++] declaration-specifiers declarator '=' assignment-expression
+/// [C++11] initializer-clause
/// [GNU] declaration-specifiers declarator attributes
/// declaration-specifiers abstract-declarator[opt]
/// [C++] declaration-specifiers abstract-declarator[opt]
@@ -4280,7 +4281,11 @@
Sema::PotentiallyEvaluatedIfUsed,
Param);
- ExprResult DefArgResult(ParseAssignmentExpression());
+ ExprResult DefArgResult;
+ if (Tok.is(tok::l_brace))
+ DefArgResult = ParseBraceInitializer();
+ else
+ DefArgResult = ParseAssignmentExpression();
if (DefArgResult.isInvalid()) {
Actions.ActOnParamDefaultArgumentError(Param);
SkipUntil(tok::comma, tok::r_paren, true, true);
Modified: cfe/trunk/test/SemaCXX/cxx0x-initializer-scalars.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-initializer-scalars.cpp?rev=152721&r1=152720&r2=152721&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx0x-initializer-scalars.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-initializer-scalars.cpp Wed Mar 14 10:54:00 2012
@@ -96,6 +96,13 @@
(void) int({0}); // expected-error {{functional-style cast}}
new int({0}); // expected-error {{cannot initialize}}
}
+
+ void default_argument(int i = {}) {
+ }
+ struct DefaultArgument {
+ void default_argument(int i = {}) {
+ }
+ };
}
namespace PR12118 {
More information about the cfe-commits
mailing list