aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Lesser <blitzrakete@gmail.com>2019-05-05 12:15:17 +0000
committerNicolas Lesser <blitzrakete@gmail.com>2019-05-05 12:15:17 +0000
commit3e0c2a51a0e7acafc37b86ce9838c6e1400054d5 (patch)
treea65ae471e6f4d4f099d377fb6c1c4a964b0e0396
parent7985bcbf1b95421a000b3bd70298dfe7532a59db (diff)
[C++] Interpret unknown identifier in parameter clause as unknown type
instead of as parameter name without a type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@359979 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Parse/ParseDecl.cpp3
-rw-r--r--test/Parser/editor-placeholder-recovery.cpp2
-rw-r--r--test/SemaCXX/unknown-type-name.cpp4
3 files changed, 5 insertions, 4 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index f63fd56a89..f883ecc45f 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -2649,6 +2649,9 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
case tok::semi:
// This looks like a variable or function declaration. The type is
// probably missing. We're done parsing decl-specifiers.
+ // But only if we are not in a function prototype scope.
+ if (getCurScope()->isFunctionPrototypeScope())
+ break;
if (SS)
AnnotateScopeToken(*SS, /*IsNewAnnotation*/false);
return false;
diff --git a/test/Parser/editor-placeholder-recovery.cpp b/test/Parser/editor-placeholder-recovery.cpp
index d68e087d6f..62f5529906 100644
--- a/test/Parser/editor-placeholder-recovery.cpp
+++ b/test/Parser/editor-placeholder-recovery.cpp
@@ -64,7 +64,7 @@ void avoidPlaceholderErrors(Struct &obj) {
}
}
-void Struct::method(<#Struct &x#>, noSupressionHere) { // expected-error {{unknown type name 'noSupressionHere'}} expected-error {{C++ requires a type specifier for all declarations}}
+void Struct::method(<#Struct &x#>, noSupressionHere) { // expected-error {{unknown type name 'noSupressionHere'}}
#ifndef SUPPRESS
// expected-error@-2 {{editor placeholder in source file}}
#endif
diff --git a/test/SemaCXX/unknown-type-name.cpp b/test/SemaCXX/unknown-type-name.cpp
index 9086c9acc4..bacdee4b37 100644
--- a/test/SemaCXX/unknown-type-name.cpp
+++ b/test/SemaCXX/unknown-type-name.cpp
@@ -72,9 +72,7 @@ void f(int, T::type x, char) { } // expected-error{{missing 'typename'}}
int *p;
-// FIXME: We should assume that 'undeclared' is a type, not a parameter name
-// here, and produce an 'unknown type name' diagnostic instead.
-int f1(undeclared, int); // expected-error{{requires a type specifier}}
+int f1(undeclared, int); // expected-error{{unknown type name 'undeclared'}}
int f2(undeclared, 0); // expected-error{{undeclared identifier}}