gcc/gcc46-pr46890.patch
Jakub Jelinek 759d90703d 4.6.0-0.2
2011-01-22 11:26:14 +01:00

111 lines
2.3 KiB
Diff

2010-12-17 Nathan Froyd <froydnj@codesourcery.com>
PR c++/46890
* parser.c (cp_parser_class_specifier): Add RID_TYPEDEF to
lookahead logic and fix setting of want_semicolon.
* g++.dg/pr46890.C: New test.
* g++.dg/parse/semicolon.C: Add new cases.
--- gcc/cp/parser.c
+++ gcc/cp/parser.c
@@ -16959,17 +16959,16 @@ cp_parser_class_specifier (cp_parser* parser)
static const <type> var = ...; */
case CPP_KEYWORD:
if (keyword_is_storage_class_specifier (token->keyword)
- || keyword_is_type_qualifier (token->keyword))
+ || keyword_is_type_qualifier (token->keyword)
+ || token->keyword == RID_TYPEDEF)
{
cp_token *lookahead = cp_lexer_peek_nth_token (parser->lexer, 2);
- if (lookahead->type == CPP_KEYWORD
- && !keyword_begins_type_specifier (lookahead->keyword))
- want_semicolon = false;
- else if (lookahead->type == CPP_NAME)
- /* Handling user-defined types here would be nice, but
- very tricky. */
- want_semicolon = false;
+ /* Handling user-defined types here would be nice, but very
+ tricky. */
+ want_semicolon
+ = (lookahead->type == CPP_KEYWORD
+ && keyword_begins_type_specifier (lookahead->keyword));
}
break;
default:
--- gcc/testsuite/g++.dg/parse/semicolon3.C
+++ gcc/testsuite/g++.dg/parse/semicolon3.C
@@ -62,6 +62,48 @@ autotest (void)
return ok10.a;
}
+struct OK11
+{
+ int a;
+} // no complaints
+ const *ok11_var;
+
+struct OK12
+{
+ int a;
+} // no complaints
+ const &ok12_var = *(new OK12());
+
+struct OK13
+{
+ int a;
+} // no complaints
+ static *ok13_var;
+
+class OK14
+{
+ struct OK14sub
+ {
+ int a;
+ } // no complaints
+ static &ok14_var;
+};
+
+class OK15
+{
+ int a;
+} typedef tOK15;
+
+class OK16
+{
+ int a;
+} typedef *pOK16;
+
+class OK17
+{
+ int a;
+} typedef &rOK16;
+
struct E1
{
int a;
@@ -196,6 +238,13 @@ class E17
mutable int i;
} // { dg-error "after class definition" }
+class E18
+{
+ int a;
+} // { dg-error "after class definition" }
+
+typedef int E18int;
+
/* This was the original test from the PR. */
class C0
--- gcc/testsuite/g++.dg/pr46890.C
+++ gcc/testsuite/g++.dg/pr46890.C
@@ -0,0 +1,6 @@
+// PR c++/46890
+// { dg-do compile }
+
+struct MdatResource {
+const char *mdatAlloc;
+} const *_resource;