This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PR c++/28152 Diagnostic about wrong use _Complex prints __complex__
- From: "Manuel López-Ibáñez" <lopezibanez at gmail dot com>
- To: "Gcc Patch List" <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 21 Oct 2008 17:47:12 +0200
- Subject: Re: PR c++/28152 Diagnostic about wrong use _Complex prints __complex__
- References: <6c33472e0808221726o23dd7645j58b41e170443ec33@mail.gmail.com>
I updated the patch to a recent revision, bootstrapped and regression
tested again.
OK for trunk?
Manuel.
2008/8/23 Manuel López-Ibáñez <lopezibanez@gmail.com>:
> Bootstrapped and regression tested on x86_64-unknown-linux-gnu with
> --enable-languages=all,ada
>
> OK for trunk?
>
> 2008-08-22 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
>
> PR c++/28152
> cp/
> * parser.c (cp_lexer_get_preprocessor_token): Do not store the
> canonical spelling for keywords.
> (cp_parser_attribute_list): Use the canonical spelling for
> keywords in attributes.
> testsuite/
> * g++.dg/parse/parser-pr28152.C: New.
> * g++.dg/parse/parser-pr28152-2.C: New.
> * g++.dg/ext/attrib34.C: New.
>
Index: gcc/testsuite/g++.dg/parse/parser-pr28152-2.C
===================================================================
--- gcc/testsuite/g++.dg/parse/parser-pr28152-2.C (revision 0)
+++ gcc/testsuite/g++.dg/parse/parser-pr28152-2.C (revision 0)
@@ -0,0 +1,13 @@
+/* PR 28152: error messages should mention __complex__ */
+/* { dg-do compile } */
+/* { dg-options "" } */
+int
+main (void)
+{
+ __complex__ float z;
+
+ z = __complex__ (1.90000007326203904e+19, 0.0); // { dg-error "expected primary-expression before '__complex__'" }
+ // { dg-error "expected .;. before .__complex__." "" { target *-*-* } 9 }
+ z = __complex__ (1.0e+0, 0.0) / z; // { dg-error "expected primary-expression before '__complex__'" }
+ // { dg-error "expected .;. before '__complex__'" "" { target *-*-* } 11 }
+ // { dg-error "at end of input" "" { target *-*-* } 11 }
Index: gcc/testsuite/g++.dg/parse/parser-pr28152.C
===================================================================
--- gcc/testsuite/g++.dg/parse/parser-pr28152.C (revision 0)
+++ gcc/testsuite/g++.dg/parse/parser-pr28152.C (revision 0)
@@ -0,0 +1,13 @@
+/* PR 28152: error messages should mention _Complex */
+/* { dg-do compile } */
+/* { dg-options "" } */
+int
+main (void)
+{
+ _Complex float z;
+
+ z = _Complex (1.90000007326203904e+19, 0.0); // { dg-error "expected primary-expression before '_Complex'" }
+ // { dg-error "expected .;. before ._Complex." "" { target *-*-* } 9 }
+ z = _Complex (1.0e+0, 0.0) / z; // { dg-error "expected primary-expression before '_Complex'" }
+ // { dg-error "expected .;. before '_Complex'" "" { target *-*-* } 11 }
+ // { dg-error "at end of input" "" { target *-*-* } 11 }
Index: gcc/cp/parser.c
===================================================================
--- gcc/cp/parser.c (revision 141240)
+++ gcc/cp/parser.c (working copy)
@@ -421,15 +421,10 @@ cp_lexer_get_preprocessor_token (cp_lexe
{
/* Mark this token as a keyword. */
token->type = CPP_KEYWORD;
/* Record which keyword. */
token->keyword = C_RID_CODE (token->u.value);
- /* Update the value. Some keywords are mapped to particular
- entities, rather than simply having the value of the
- corresponding IDENTIFIER_NODE. For example, `__const' is
- mapped to `const'. */
- token->u.value = ridpointers[token->keyword];
}
else
{
if (warn_cxx0x_compat
&& C_RID_CODE (token->u.value) >= RID_FIRST_CXX0X
@@ -16671,11 +16666,16 @@ cp_parser_attribute_list (cp_parser* par
/* Consume the token. */
token = cp_lexer_consume_token (parser->lexer);
/* Save away the identifier that indicates which attribute
this is. */
- identifier = token->u.value;
+ identifier = (token->type == CPP_KEYWORD)
+ /* For keywords, use the canonical spelling, not the
+ parsed identifier. */
+ ? ridpointers[(int) token->keyword]
+ : token->u.value;
+
attribute = build_tree_list (identifier, NULL_TREE);
/* Peek at the next token. */
token = cp_lexer_peek_token (parser->lexer);
/* If it's an `(', then parse the attribute arguments. */