aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Parse/ParseDeclCXX.cpp9
-rw-r--r--test/Parser/cxx-class.cpp7
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp
index c31c55ba5b..050b1b19c4 100644
--- a/lib/Parse/ParseDeclCXX.cpp
+++ b/lib/Parse/ParseDeclCXX.cpp
@@ -1849,9 +1849,9 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
if (DefinitionKind) {
if (!DeclaratorInfo.isFunctionDeclarator()) {
- Diag(Tok, diag::err_func_def_no_params);
+ Diag(DeclaratorInfo.getIdentifierLoc(), diag::err_func_def_no_params);
ConsumeBrace();
- SkipUntil(tok::r_brace, true);
+ SkipUntil(tok::r_brace, /*StopAtSemi*/false);
// Consume the optional ';'
if (Tok.is(tok::semi))
@@ -1860,12 +1860,13 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
}
if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) {
- Diag(Tok, diag::err_function_declared_typedef);
+ Diag(DeclaratorInfo.getIdentifierLoc(),
+ diag::err_function_declared_typedef);
// This recovery skips the entire function body. It would be nice
// to simply call ParseCXXInlineMethodDef() below, however Sema
// assumes the declarator represents a function, not a typedef.
ConsumeBrace();
- SkipUntil(tok::r_brace, true);
+ SkipUntil(tok::r_brace, /*StopAtSemi*/false);
// Consume the optional ';'
if (Tok.is(tok::semi))
diff --git a/test/Parser/cxx-class.cpp b/test/Parser/cxx-class.cpp
index 1c0d862b30..36f08d52d5 100644
--- a/test/Parser/cxx-class.cpp
+++ b/test/Parser/cxx-class.cpp
@@ -54,6 +54,13 @@ public; // expected-error{{expected ':'}}
int i;
};
+class F {
+ int F1 { return 1; } // expected-error{{function definition does not declare parameters}}
+ void F2 {} // expected-error{{function definition does not declare parameters}}
+ typedef int F3() { return 0; } // expected-error{{function definition declared 'typedef'}}
+ typedef void F4() {} // expected-error{{function definition declared 'typedef'}}
+};
+
// PR11109 must appear at the end of the source file
class pr11109r3 { // expected-note{{to match this '{'}}
public // expected-error{{expected ':'}} expected-error{{expected '}'}} expected-error{{expected ';' after class}}