re PR c++/28152 (Diagnostic about wrong use _Complex prints __complex__)
authorManuel López-Ibáñez <manu@gcc.gnu.org>
Mon, 4 May 2009 12:47:53 +0000 (12:47 +0000)
committerManuel López-Ibáñez <manu@gcc.gnu.org>
Mon, 4 May 2009 12:47:53 +0000 (12:47 +0000)
2009-05-04  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.

From-SVN: r147097

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/parser-pr28152-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/parse/parser-pr28152.C [new file with mode: 0644]

index 785dbb1..4a34132 100644 (file)
@@ -1,3 +1,11 @@
+2009-05-04  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
+
+       PR c++/28152
+       * 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.
+
 2009-05-01  Joseph Myers  <joseph@codesourcery.com>
 
        * cxx-pretty-print.c (is_destructor_name, pp_cxx_unqualified_id,
index 9829275..c691ef2 100644 (file)
@@ -418,11 +418,6 @@ cp_lexer_get_preprocessor_token (cp_lexer *lexer, cp_token *token)
          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
        {
@@ -16842,7 +16837,12 @@ cp_parser_attribute_list (cp_parser* parser)
 
          /* 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.  */
index 9fa40cb..842105c 100644 (file)
@@ -1,3 +1,9 @@
+2009-05-04  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
+
+       PR c++/28152
+       * g++.dg/parse/parser-pr28152.C: New.
+       * g++.dg/parse/parser-pr28152-2.C: New.
+
 2009-05-04  Joseph Myers  <joseph@codesourcery.com>
 
        * gcc.dg/attr-alias-5.c, gcc.dg/ucnid-7.c: New tests.
diff --git a/gcc/testsuite/g++.dg/parse/parser-pr28152-2.C b/gcc/testsuite/g++.dg/parse/parser-pr28152-2.C
new file mode 100644 (file)
index 0000000..bcccb94
--- /dev/null
@@ -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 } 
diff --git a/gcc/testsuite/g++.dg/parse/parser-pr28152.C b/gcc/testsuite/g++.dg/parse/parser-pr28152.C
new file mode 100644 (file)
index 0000000..5b3a25e
--- /dev/null
@@ -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 }