diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 2fac0dca4025..6f344f66914c 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -4282,9 +4282,10 @@ void Parser::ParseParameterDeclarationClause( 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); diff --git a/clang/test/SemaCXX/cxx98-compat.cpp b/clang/test/SemaCXX/cxx98-compat.cpp index 903932c1897c..211f11cc5977 100644 --- a/clang/test/SemaCXX/cxx98-compat.cpp +++ b/clang/test/SemaCXX/cxx98-compat.cpp @@ -39,7 +39,8 @@ void Lambda() { []{}(); // 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}} \