r359979 - [C++] Interpret unknown identifier in parameter clause as unknown type
Nicolas Lesser via cfe-commits
cfe-commits at lists.llvm.org
Sun May 5 05:15:17 PDT 2019
Author: rakete1111
Date: Sun May 5 05:15:17 2019
New Revision: 359979
URL: http://llvm.org/viewvc/llvm-project?rev=359979&view=rev
Log:
[C++] Interpret unknown identifier in parameter clause as unknown type
instead of as parameter name without a type.
Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/Parser/editor-placeholder-recovery.cpp
cfe/trunk/test/SemaCXX/unknown-type-name.cpp
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=359979&r1=359978&r2=359979&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Sun May 5 05:15:17 2019
@@ -2649,6 +2649,9 @@ bool Parser::ParseImplicitInt(DeclSpec &
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;
Modified: cfe/trunk/test/Parser/editor-placeholder-recovery.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/editor-placeholder-recovery.cpp?rev=359979&r1=359978&r2=359979&view=diff
==============================================================================
--- cfe/trunk/test/Parser/editor-placeholder-recovery.cpp (original)
+++ cfe/trunk/test/Parser/editor-placeholder-recovery.cpp Sun May 5 05:15:17 2019
@@ -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 at -2 {{editor placeholder in source file}}
#endif
Modified: cfe/trunk/test/SemaCXX/unknown-type-name.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/unknown-type-name.cpp?rev=359979&r1=359978&r2=359979&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/unknown-type-name.cpp (original)
+++ cfe/trunk/test/SemaCXX/unknown-type-name.cpp Sun May 5 05:15:17 2019
@@ -72,9 +72,7 @@ void f(int, T::type x, char) { } // expe
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}}
More information about the cfe-commits
mailing list