Bug 28152

Summary: Diagnostic about wrong use _Complex prints __complex__
Product: gcc Reporter: Steven Bosscher <steven>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs, jsm28, manu
Priority: P3 Keywords: diagnostic, patch
Version: 4.2.0   
Target Milestone: ---   
URL: http://gcc.gnu.org/ml/gcc-patches/2008-10/msg00874.html
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2008-08-14 13:07:48
Bug Depends on: 14875    
Bug Blocks:    

Description Steven Bosscher 2006-06-24 14:01:14 UTC
$ cat t.c
int
main (void)
{
  _Complex float z;

  z = _Complex (1.90000007326203904e+19, 0.0);
  z = _Complex (1.0e+0, 0.0) / z;
$ ./cc1 -quiet t.c
t.c: In function 'main':
t.c:6: error: expected expression before '__complex__'
t.c:7: error: expected expression before '__complex__'
$ ./cc1 --version
GNU C version 4.2.0 20060624 (experimental) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.0.2 20050901 (prerelease) (SUSE Linux).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
$
Comment 1 Andrew Pinski 2006-06-28 21:18:44 UTC
Confirmed, we don't record in the preprocessor which keyword is used, _Complex is treated the same as __complex__.  There is another bug about a similar issue with "or" and |.
Comment 2 Andrew Pinski 2006-06-28 21:21:48 UTC
PR 14875 is the related bug.
Comment 3 Gabriel Dos Reis 2006-07-02 16:03:12 UTC
Subject: Re:  Diagnostic about wrong use _Complex prints __complex__

"pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| Confirmed, we don't record in the preprocessor which keyword is
| used, _Complex is treated the same as __complex__.

Indeed. However, we can approximate a fix by testing whether we're
compiling under C99, GNU99, or just C90, or C++.

-- gaby
Comment 4 Andrew Pinski 2006-07-02 16:11:47 UTC
(In reply to comment #3)
> Indeed. However, we can approximate a fix by testing whether we're
> compiling under C99, GNU99, or just C90, or C++.

That would not work as _Complex is accepted in GNU90 more and with the C++ front-end by default.
In fact "_Complex float t;" is accepted with the C++ front-end even with -pedantic which seems wrong and that would be a different but.
Comment 5 Gabriel Dos Reis 2006-07-02 16:37:22 UTC
Subject: Re:  Diagnostic about wrong use _Complex prints __complex__

"pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| (In reply to comment #3)
| > Indeed. However, we can approximate a fix by testing whether we're
| > compiling under C99, GNU99, or just C90, or C++.
| 
| That would not work as _Complex is accepted in GNU90 more and with the C++
| front-end by default.

Lookup the meaning of "approximation".

-- Gaby
Comment 6 Manuel López-Ibáñez 2008-08-14 13:03:25 UTC
Subject: Bug 28152

Author: manu
Date: Thu Aug 14 13:01:58 2008
New Revision: 139097

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=139097
Log:
2008-08-08  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

        PR c/28152
	* c-parser.c (c_lex_one_token): Do not store the canonical spelling
	for keywords.
testsuite/
	* gcc.dg/parser-pr28152.c: New.
	* gcc.dg/parser-pr28152-2.c: New.
	

Added:
    trunk/gcc/testsuite/gcc.dg/parser-pr28152-2.c
    trunk/gcc/testsuite/gcc.dg/parser-pr28152.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-parser.c
    trunk/gcc/testsuite/ChangeLog

Comment 7 Manuel López-Ibáñez 2008-08-14 13:07:47 UTC
This is FIXED for C but not for C++. Probably this is the same bug as 14875 but just in case, I keep open both.
Comment 8 Manuel López-Ibáñez 2009-02-07 20:54:30 UTC
Patch here:

http://gcc.gnu.org/ml/gcc-patches/2008-10/msg00874.html
Comment 9 Manuel López-Ibáñez 2009-05-04 12:48:10 UTC
Subject: Bug 28152

Author: manu
Date: Mon May  4 12:47:53 2009
New Revision: 147097

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=147097
Log:
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.


Added:
    trunk/gcc/testsuite/g++.dg/parse/parser-pr28152-2.C
    trunk/gcc/testsuite/g++.dg/parse/parser-pr28152.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog

Comment 10 Manuel López-Ibáñez 2009-05-04 12:49:53 UTC
FIXED in GCC 4.5