[cfe-commits] r152721 - in /cfe/trunk: lib/Parse/ParseCXXInlineMethods.cpp lib/Parse/ParseDecl.cpp test/SemaCXX/cxx0x-initializer-scalars.cpp
Richard Smith
richard at metafoo.co.uk
Thu Mar 15 18:42:10 PDT 2012
On Thu, Mar 15, 2012 at 6:04 PM, Eli Friedman <eli.friedman at gmail.com>wrote:
> On Wed, Mar 14, 2012 at 8:54 AM, Sebastian Redl
> <sebastian.redl at getdesigned.at> wrote:
> > 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();
>
> With this change, we accept "int f(int a = {1});" in C++98 mode
> without a warning. That seems wrong.
We should also produce a -Wc++98-compat warning for this in C++11 mode.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120315/69df1a59/attachment.html>
More information about the cfe-commits
mailing list