[cfe-commits] r142935 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td lib/Parse/ParseDeclCXX.cpp test/CXX/class.derived/p1.cpp
David Blaikie
dblaikie at gmail.com
Tue Oct 25 11:17:58 PDT 2011
Author: dblaikie
Date: Tue Oct 25 13:17:58 2011
New Revision: 142935
URL: http://llvm.org/viewvc/llvm-project?rev=142935&view=rev
Log:
Fix erroneous name-specifiers prior to decltypes better/correctly as per Doug's feedback.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/test/CXX/class.derived/p1.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=142935&r1=142934&r2=142935&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Tue Oct 25 13:17:58 2011
@@ -249,6 +249,8 @@
"C requires a comma prior to the ellipsis in a variadic function type">;
def err_unexpected_typedef_ident : Error<
"unexpected type name %0: expected identifier">;
+def err_unexpected_scope_on_base_decltype : Error<
+ "unexpected namespace scope prior to decltype">;
def err_expected_class_name : Error<"expected class name">;
def err_unspecified_vla_size_with_static : Error<
"'static' may not be used with an unspecified variable length array size">;
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=142935&r1=142934&r2=142935&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Tue Oct 25 13:17:58 2011
@@ -713,13 +713,20 @@
///
Parser::TypeResult Parser::ParseBaseTypeSpecifier(SourceLocation &BaseLoc,
SourceLocation &EndLocation) {
+ // Parse optional nested-name-specifier
+ CXXScopeSpec SS;
+ ParseOptionalCXXScopeSpecifier(SS, ParsedType(), /*EnteringContext=*/false);
+
+ BaseLoc = Tok.getLocation();
+
// Parse decltype-specifier
if (Tok.is(tok::kw_decltype)) {
+ if (SS.isNotEmpty())
+ Diag(SS.getBeginLoc(), diag::err_unexpected_scope_on_base_decltype)
+ << FixItHint::CreateRemoval(SS.getRange());
// Fake up a Declarator to use with ActOnTypeName.
DeclSpec DS(AttrFactory);
- BaseLoc = Tok.getLocation();
-
ParseDecltypeSpecifier(DS);
EndLocation = DS.getSourceRange().getEnd();
@@ -727,12 +734,6 @@
return Actions.ActOnTypeName(getCurScope(), DeclaratorInfo);
}
- // Parse optional nested-name-specifier
- CXXScopeSpec SS;
- ParseOptionalCXXScopeSpecifier(SS, ParsedType(), /*EnteringContext=*/false);
-
- BaseLoc = Tok.getLocation();
-
// Check whether we have a template-id that names a type.
if (Tok.is(tok::annot_template_id)) {
TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
Modified: cfe/trunk/test/CXX/class.derived/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class.derived/p1.cpp?rev=142935&r1=142934&r2=142935&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class.derived/p1.cpp (original)
+++ cfe/trunk/test/CXX/class.derived/p1.cpp Tue Oct 25 13:17:58 2011
@@ -31,7 +31,7 @@
struct Foo { Base foo(); };
Derived3<Foo> d;
- struct Derived4 : :: decltype(Base()) { }; // expected-error {{expected class name}}
+ struct Derived4 : :: decltype(Base()) { }; // expected-error {{unexpected namespace scope prior to decltype}}
- struct Derived5 : PR11216:: decltype(Base()) { }; // expected-error {{expected class name}}
+ struct Derived5 : PR11216:: decltype(Base()) { }; // expected-error {{unexpected namespace scope prior to decltype}}
}
More information about the cfe-commits
mailing list