Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 219cffc

Browse files
committed
Change warning about incomplete parsing of C++ default arg to error and provide a test case; thanks Doug!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110603 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent d91de2b commit 219cffc

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

include/clang/Basic/DiagnosticParseKinds.td

+2-2
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ def err_destructor_tilde_identifier : Error<
271271
"expected a class name after '~' to name a destructor">;
272272
def err_destructor_template_id : Error<
273273
"destructor name %0 does not refer to a template">;
274-
def warn_default_arg_unparsed : Warning<
275-
"parsing of default argument is incomplete">;
274+
def err_default_arg_unparsed : Error<
275+
"unexpected end of default argument expression">;
276276

277277
// C++ derived classes
278278
def err_dup_virtual : Error<"duplicate 'virtual' in base specifier">;

lib/Parse/ParseCXXInlineMethods.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,8 @@ void Parser::ParseLexedMethodDeclarations(ParsingClass &Class) {
145145
else {
146146
if (Tok.is(tok::cxx_defaultarg_end))
147147
ConsumeToken();
148-
else {
149-
// Warn that there are tokens from the default arg that we left
150-
// unparsed. This actually indicates a bug in clang but we avoid
151-
// asserting because we want the parser robust.
152-
Diag(Tok.getLocation(), diag::warn_default_arg_unparsed);
153-
}
148+
else
149+
Diag(Tok.getLocation(), diag::err_default_arg_unparsed);
154150
Actions.ActOnParamDefaultArgument(LM.DefaultArgs[I].Param, EqualLoc,
155151
move(DefArgResult));
156152
}

test/Parser/cxx-default-args.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ class C {
1010
typedef struct Inst {
1111
void m(int x=0);
1212
} *InstPtr;
13+
14+
struct X {
15+
void f(int x = 1:); // expected-error {{unexpected end of default argument expression}}
16+
};

0 commit comments

Comments
 (0)