summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2012-10-31 08:55:43 +0000
committerDodji Seketeli <dodji@gcc.gnu.org>2012-10-31 09:55:43 +0100
commite82b2e880c2a70ac8dbcb6c36df0e89c92207e60 (patch)
tree61626b5c962af926be3f6e96b3f80958e0255a68
parentd578e863b08e64789f767c95f85acd10dc477bdf (diff)
downloadgcc-e82b2e880c2a70ac8dbcb6c36df0e89c92207e60.tar.gz
PR c++/54955 - Fail to parse alignas expr at the beginning of a declaration
In this PR, g++ embarrassingly fails to parse the simple alignas expression below: alignas(double) int f; even though the simple-declaration production in Clause 7 suggests otherwise. Fixed thus and tested on x86_64-unknown-linux-gnu against trunk. gcc/cp PR c++/54955 * parser.c (cp_nth_tokens_can_be_std_attribute_p): Recognize the 'Alignas' keyword as the beginning of a c++11 attribute specifier. Update the comment of the function. (cp_next_tokens_can_be_gnu_attribute_p): Update the comment of the function. gcc/testsuite/ PR c++/54955 * g++.dg/cpp0x/gen-attrs-48-2.C: New test. From-SVN: r193029
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/parser.c11
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/gen-attrs-48-2.C4
4 files changed, 24 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1eb1fe4f2c1..a1abdde3f3d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2012-10-31 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/54955
+ * parser.c (cp_nth_tokens_can_be_std_attribute_p): Recognize the
+ 'Alignas' keyword as the beginning of a c++11 attribute specifier.
+ Update the comment of the function.
+ (cp_next_tokens_can_be_gnu_attribute_p): Update the comment of the
+ function.
+
2012-10-29 Jonathan Wakely <jwakely.gcc@gmail.com>
PR c++/54930
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 940356377a0..f2642aba33a 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -20324,7 +20324,7 @@ cp_next_tokens_can_be_gnu_attribute_p (cp_parser *parser)
}
/* Return TRUE iff the next tokens in the stream are possibly the
- beginning of a standard C++-11 attribute. */
+ beginning of a standard C++-11 attribute specifier. */
static bool
cp_next_tokens_can_be_std_attribute_p (cp_parser *parser)
@@ -20333,7 +20333,7 @@ cp_next_tokens_can_be_std_attribute_p (cp_parser *parser)
}
/* Return TRUE iff the next Nth tokens in the stream are possibly the
- beginning of a standard C++-11 attribute. */
+ beginning of a standard C++-11 attribute specifier. */
static bool
cp_nth_tokens_can_be_std_attribute_p (cp_parser *parser, size_t n)
@@ -20341,9 +20341,10 @@ cp_nth_tokens_can_be_std_attribute_p (cp_parser *parser, size_t n)
cp_token *token = cp_lexer_peek_nth_token (parser->lexer, n);
return (cxx_dialect >= cxx0x
- && token->type == CPP_OPEN_SQUARE
- && (token = cp_lexer_peek_nth_token (parser->lexer, n + 1))
- && token->type == CPP_OPEN_SQUARE);
+ && ((token->type == CPP_KEYWORD && token->keyword == RID_ALIGNAS)
+ || (token->type == CPP_OPEN_SQUARE
+ && (token = cp_lexer_peek_nth_token (parser->lexer, n + 1))
+ && token->type == CPP_OPEN_SQUARE)));
}
/* Return TRUE iff the next Nth tokens in the stream are possibly the
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ac09b8ada55..10f98bc76c0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-10-31 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/54955
+ * g++.dg/cpp0x/gen-attrs-48-2.C: New test.
+
2012-10-31 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/19105
diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-48-2.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-48-2.C
new file mode 100644
index 00000000000..3cc58976b03
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-48-2.C
@@ -0,0 +1,4 @@
+// Origin: PR c++/54955
+// { dg-do compile { target c++11 } }
+
+alignas(double) int f;