public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14875] New: No or in function names allowed
@ 2004-04-07 11:58 j dot werner at physik dot uni-stuttgart dot de
2004-04-07 12:25 ` [Bug c++/14875] " pinskia at gcc dot gnu dot org
` (6 more replies)
0 siblings, 7 replies; 16+ messages in thread
From: j dot werner at physik dot uni-stuttgart dot de @ 2004-04-07 11:58 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3082 bytes --]
The following code fails to compile using gcc-3.4:
Sample.hpp:
#ifndef __SAMPLE__
#define __SAMPLE__
using namespace std;
class Sample
{
public:
Sample::Sample();
void Sample::or(long Digital);
};
#endif
Sample.cpp:
#include "Sample.hpp"
Sample::Sample()
{
}
void Sample::or(long Digital)
{
}
joerg@uhldingen:~$ LANG=C g++-3.4 -v -save-temps Sample.cpp
Reading specs from /usr/lib/gcc/i486-linux/3.4.0/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr
--libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.4
--enable-shared --with-system-zlib --enable-nls --enable-threads=posix
--without-included-gettext --program-suffix=-3.4 --enable-__cxa_atexit
--enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm
--enable-java-awt=gtk --disable-werror i486-linux
Thread model: posix
gcc version 3.4.0 20040403 (prerelease) (Debian)
/usr/lib/gcc/i486-linux/3.4.0/cc1plus -E -quiet -v -D_GNU_SOURCE Sample.cpp
-mtune=i486 -o Sample.ii
ignoring nonexistent directory
"/usr/lib/gcc/i486-linux/3.4.0/../../../../i486-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/3.4
/usr/include/c++/3.4/i486-linux
/usr/include/c++/3.4/backward
/usr/local/include
/usr/lib/gcc/i486-linux/3.4.0/include
/usr/include
End of search list.
/usr/lib/gcc/i486-linux/3.4.0/cc1plus -fpreprocessed Sample.ii -quiet
-dumpbase Sample.cpp -mtune=i486 -auxbase Sample -version -o Sample.s
GNU C++ version 3.4.0 20040403 (prerelease) (Debian) (i486-linux)
compiled by GNU C version 3.4.0 20040403 (prerelease) (Debian).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64362
In file included from Sample.cpp:1:
Sample.hpp:11: error: expected unqualified-id before '||' token
Sample.hpp:11: error: abstract declarator `void' used as declaration
Sample.hpp:11: error: variable or field `type name' declared void
Sample.hpp:11: error: expected `;' before '||' token
Sample.cpp:7: error: expected unqualified-id before '||' token
Sample.cpp:7: error: expected init-declarator before '||' token
Sample.cpp:7: error: expected `,' or `;' before '||' token
Sample.ii:
# 1 "Sample.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "Sample.cpp"
# 1 "Sample.hpp" 1
using namespace std;
class Sample
{
public:
Sample::Sample();
void Sample::or(long Digital);
};
# 2 "Sample.cpp" 2
Sample::Sample()
{
}
void Sample::or(long Digital)
{
}
Is or in function names not allowed?
Greetings,
Jörg
--
Summary: No or in function names allowed
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: j dot werner at physik dot uni-stuttgart dot de
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14875
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/14875] No or in function names allowed
2004-04-07 11:58 [Bug c++/14875] New: No or in function names allowed j dot werner at physik dot uni-stuttgart dot de
@ 2004-04-07 12:25 ` pinskia at gcc dot gnu dot org
2004-04-07 13:19 ` giovannibajo at libero dot it
` (5 subsequent siblings)
6 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-07 12:25 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-04-07 12:25 -------
In C++ or is a keyword for |, so this is invalid.
Also the follow are keywords:
and &
xor ^
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14875
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/14875] No or in function names allowed
2004-04-07 11:58 [Bug c++/14875] New: No or in function names allowed j dot werner at physik dot uni-stuttgart dot de
2004-04-07 12:25 ` [Bug c++/14875] " pinskia at gcc dot gnu dot org
@ 2004-04-07 13:19 ` giovannibajo at libero dot it
2004-04-07 13:23 ` [Bug c++/14875] When using 'or' keyword, the error message speaks of a '||' token giovannibajo at libero dot it
` (4 subsequent siblings)
6 siblings, 0 replies; 16+ messages in thread
From: giovannibajo at libero dot it @ 2004-04-07 13:19 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-04-07 13:19 -------
Yes, but the diagnostic is totally confusing
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14875
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/14875] When using 'or' keyword, the error message speaks of a '||' token
2004-04-07 11:58 [Bug c++/14875] New: No or in function names allowed j dot werner at physik dot uni-stuttgart dot de
2004-04-07 12:25 ` [Bug c++/14875] " pinskia at gcc dot gnu dot org
2004-04-07 13:19 ` giovannibajo at libero dot it
@ 2004-04-07 13:23 ` giovannibajo at libero dot it
2004-04-07 13:31 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 16+ messages in thread
From: giovannibajo at libero dot it @ 2004-04-07 13:23 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-04-07 13:22 -------
Keeping this as a diagnostic enchancement: we should emit a proper error
message.
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |diagnostic
Last reconfirmed|0000-00-00 00:00:00 |2004-04-07 13:22:54
date| |
Summary|No or in function names |When using 'or' keyword, the
|allowed |error message speaks of a
| |'||' token
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14875
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/14875] When using 'or' keyword, the error message speaks of a '||' token
2004-04-07 11:58 [Bug c++/14875] New: No or in function names allowed j dot werner at physik dot uni-stuttgart dot de
` (2 preceding siblings ...)
2004-04-07 13:23 ` [Bug c++/14875] When using 'or' keyword, the error message speaks of a '||' token giovannibajo at libero dot it
@ 2004-04-07 13:31 ` pinskia at gcc dot gnu dot org
2004-04-08 18:34 ` bangerth at dealii dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-07 13:31 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-04-07 13:31 -------
Just for comparision here is what ICC 6.0 says:
pr14875.cc(5): warning #470: qualified name is not allowed in member declaration
Sample::Sample();
^
pr14875.cc(6): error: expected an identifier
void Sample::or(long Digital);
^
pr14875.cc(6): warning #470: qualified name is not allowed in member declaration
void Sample::or(long Digital);
^
pr14875.cc(6): error: expected a ";"
void Sample::or(long Digital);
^
compilation aborted for pr14875.cc (code 2)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14875
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/14875] When using 'or' keyword, the error message speaks of a '||' token
2004-04-07 11:58 [Bug c++/14875] New: No or in function names allowed j dot werner at physik dot uni-stuttgart dot de
` (3 preceding siblings ...)
2004-04-07 13:31 ` pinskia at gcc dot gnu dot org
@ 2004-04-08 18:34 ` bangerth at dealii dot org
2004-04-08 18:53 ` Zack Weinberg
2004-04-08 18:53 ` zack at codesourcery dot com
2004-04-08 19:54 ` gdr at integrable-solutions dot net
6 siblings, 1 reply; 16+ messages in thread
From: bangerth at dealii dot org @ 2004-04-08 18:34 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-04-08 18:34 -------
The problem is that the token is already converted by the preprocessor.
This is why the error message has the '||' token in it. So I assume there
is not so much the compiler can do anymore, since it doesn't even get to
see the original token.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14875
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/14875] When using 'or' keyword, the error message speaks of a '||' token
2004-04-07 11:58 [Bug c++/14875] New: No or in function names allowed j dot werner at physik dot uni-stuttgart dot de
` (4 preceding siblings ...)
2004-04-08 18:34 ` bangerth at dealii dot org
@ 2004-04-08 18:53 ` zack at codesourcery dot com
2004-04-08 19:54 ` gdr at integrable-solutions dot net
6 siblings, 0 replies; 16+ messages in thread
From: zack at codesourcery dot com @ 2004-04-08 18:53 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From zack at codesourcery dot com 2004-04-08 18:53 -------
Subject: Re: When using 'or' keyword, the error message
speaks of a '||' token
The preprocessor will have marked the token with the NAMED_OP flag,
it might be possible to expose that to the diagnostics.
zw
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14875
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/14875] When using 'or' keyword, the error message speaks of a '||' token
2004-04-07 11:58 [Bug c++/14875] New: No or in function names allowed j dot werner at physik dot uni-stuttgart dot de
` (5 preceding siblings ...)
2004-04-08 18:53 ` zack at codesourcery dot com
@ 2004-04-08 19:54 ` gdr at integrable-solutions dot net
6 siblings, 0 replies; 16+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-04-08 19:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gdr at integrable-solutions dot net 2004-04-08 19:53 -------
Subject: Re: When using 'or' keyword, the error message speaks of a '||' token
"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:
| The problem is that the token is already converted by the preprocessor.
| This is why the error message has the '||' token in it. So I assume there
| is not so much the compiler can do anymore, since it doesn't even get to
| see the original token.
I seem to recall that when Giovanni worked on these digraph thingies,
it was pointed out that our CPP is able to mark a pp-token whether it
is a digraph or not.
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14875
^ permalink raw reply [flat|nested] 16+ messages in thread
[parent not found: <bug-14875-8295@http.gcc.gnu.org/bugzilla/>]
* [Bug c++/14875] When using 'or' keyword, the error message speaks of a '||' token
[not found] <bug-14875-8295@http.gcc.gnu.org/bugzilla/>
@ 2007-01-28 2:41 ` manu at gcc dot gnu dot org
2007-01-28 4:11 ` gdr at cs dot tamu dot edu
` (5 subsequent siblings)
6 siblings, 0 replies; 16+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-01-28 2:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from manu at gcc dot gnu dot org 2007-01-28 02:41 -------
(In reply to comment #7)
> I seem to recall that when Giovanni worked on these digraph thingies,
> it was pointed out that our CPP is able to mark a pp-token whether it
> is a digraph or not.
>
Actually, it is marked as token->flags & NAMED_OP. This can be easily tested.
However, the way the C++ front-end handles parser errors makes that totally
useless. Once we reach c-common.c (c_parse_error), the actual cp_token is lost
and we only keep the type. Also, it seems that it should be using
cpp_token_as_text rather than cpp_type2name. However, the change does not seem
trivial at all.
Unless someone decides to fix the whole C++ parser error handling, this and PR
28152 won't be fixed.
Any brave volunteer?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14875
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/14875] When using 'or' keyword, the error message speaks of a '||' token
[not found] <bug-14875-8295@http.gcc.gnu.org/bugzilla/>
2007-01-28 2:41 ` manu at gcc dot gnu dot org
@ 2007-01-28 4:11 ` gdr at cs dot tamu dot edu
2007-02-01 12:16 ` manu at gcc dot gnu dot org
` (4 subsequent siblings)
6 siblings, 0 replies; 16+ messages in thread
From: gdr at cs dot tamu dot edu @ 2007-01-28 4:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from gdr at cs dot tamu dot edu 2007-01-28 04:11 -------
Subject: Re: When using 'or' keyword, the error message speaks of a '||' token
"manu at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:
| Unless someone decides to fix the whole C++ parser error handling,
| this and PR 28152 won't be fixed.
I would refrain from sweeping generalization like the above.
Diagnostics with carret do not necessary require "fixing" the parser;
and, yet they can be implemented in a way that resolves this issue.
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14875
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/14875] When using 'or' keyword, the error message speaks of a '||' token
[not found] <bug-14875-8295@http.gcc.gnu.org/bugzilla/>
2007-01-28 2:41 ` manu at gcc dot gnu dot org
2007-01-28 4:11 ` gdr at cs dot tamu dot edu
@ 2007-02-01 12:16 ` manu at gcc dot gnu dot org
2007-11-22 8:39 ` spiridenok at tut dot by
` (3 subsequent siblings)
6 siblings, 0 replies; 16+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-02-01 12:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from manu at gcc dot gnu dot org 2007-02-01 12:16 -------
(In reply to comment #9)
> Subject: Re: When using 'or' keyword, the error message speaks of a '||' token
>
> "manu at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:
>
> | Unless someone decides to fix the whole C++ parser error handling,
> | this and PR 28152 won't be fixed.
>
> I would refrain from sweeping generalization like the above.
> Diagnostics with carret do not necessary require "fixing" the parser;
> and, yet they can be implemented in a way that resolves this issue.
>
I am not talking about the parser itself but about the way it handles errors.
token->flags gets lost inside the machinery launched by a call to
cp_parse_error. So I would like to know how you think this can be implemented
(honestly!), perhaps I missed some other way to distinguish the 'or' token from
'||'.
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14875
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/14875] When using 'or' keyword, the error message speaks of a '||' token
[not found] <bug-14875-8295@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2007-02-01 12:16 ` manu at gcc dot gnu dot org
@ 2007-11-22 8:39 ` spiridenok at tut dot by
2009-02-07 20:29 ` manu at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 16+ messages in thread
From: spiridenok at tut dot by @ 2007-11-22 8:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from spiridenok at tut dot by 2007-11-22 08:39 -------
Since when are "or"/"and"/"xor" C++ keywords?
(In reply to comment #1)
> In C++ or is a keyword for |, so this is invalid.
>
> Also the follow are keywords:
> and &
> xor ^
--
spiridenok at tut dot by changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |spiridenok at tut dot by
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14875
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/14875] When using 'or' keyword, the error message speaks of a '||' token
[not found] <bug-14875-8295@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2007-11-22 8:39 ` spiridenok at tut dot by
@ 2009-02-07 20:29 ` manu at gcc dot gnu dot org
2009-04-22 15:32 ` manu at gcc dot gnu dot org
2009-04-22 15:33 ` manu at gcc dot gnu dot org
6 siblings, 0 replies; 16+ messages in thread
From: manu at gcc dot gnu dot org @ 2009-02-07 20:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from manu at gcc dot gnu dot org 2009-02-07 20:29 -------
Patch here:
http://gcc.gnu.org/ml/gcc-patches/2008-10/msg00971.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14875
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/14875] When using 'or' keyword, the error message speaks of a '||' token
[not found] <bug-14875-8295@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2009-02-07 20:29 ` manu at gcc dot gnu dot org
@ 2009-04-22 15:32 ` manu at gcc dot gnu dot org
2009-04-22 15:33 ` manu at gcc dot gnu dot org
6 siblings, 0 replies; 16+ messages in thread
From: manu at gcc dot gnu dot org @ 2009-04-22 15:32 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from manu at gcc dot gnu dot org 2009-04-22 15:32 -------
Subject: Bug 14875
Author: manu
Date: Wed Apr 22 15:32:18 2009
New Revision: 146589
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=146589
Log:
2009-04-22 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR c++/14875
* c-common.c (c_parse_error): Take a token_flags parameter.
Use token_type for the token type instead.
Pass token_flags to cpp_type2name.
* c-common.h (c_parse_error): Update declaration.
* c-parser.c (c_parser_error): Pass 0 as token flags.
libcpp/
* lex.c (cpp_type2name): Take a flags parameter. Call
cpp_named_operator2name for named operators and cpp_digraph2name
for digraphs.
(cpp_digraph2name): New.
(cpp_spell_token): Use it.
(cpp_output_token): Likewise.
* include/cpplib.h (cpp_type2name): Update declaration.
* init.c (cpp_named_operator2name): New.
* internal.h (cpp_named_operator2name): Declare.
cp/
* parser.c (cp_parser_error): Pass token->flags to c_parse_error.
testsuite/
* g++.dg/parse/parser-pr14875.C: New.
* g++.dg/parse/parser-pr14875-2.C: New.
* g++.dg/parse/error6.C: Update match string.
Added:
trunk/gcc/testsuite/g++.dg/parse/parser-pr14875-2.C
trunk/gcc/testsuite/g++.dg/parse/parser-pr14875.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-common.c
trunk/gcc/c-common.h
trunk/gcc/c-parser.c
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/parser.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/g++.dg/parse/error6.C
trunk/libcpp/ChangeLog
trunk/libcpp/include/cpplib.h
trunk/libcpp/init.c
trunk/libcpp/internal.h
trunk/libcpp/lex.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14875
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/14875] When using 'or' keyword, the error message speaks of a '||' token
[not found] <bug-14875-8295@http.gcc.gnu.org/bugzilla/>
` (5 preceding siblings ...)
2009-04-22 15:32 ` manu at gcc dot gnu dot org
@ 2009-04-22 15:33 ` manu at gcc dot gnu dot org
6 siblings, 0 replies; 16+ messages in thread
From: manu at gcc dot gnu dot org @ 2009-04-22 15:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #14 from manu at gcc dot gnu dot org 2009-04-22 15:33 -------
FIXED in GCC 4.5.
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14875
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2009-04-22 15:33 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-07 11:58 [Bug c++/14875] New: No or in function names allowed j dot werner at physik dot uni-stuttgart dot de
2004-04-07 12:25 ` [Bug c++/14875] " pinskia at gcc dot gnu dot org
2004-04-07 13:19 ` giovannibajo at libero dot it
2004-04-07 13:23 ` [Bug c++/14875] When using 'or' keyword, the error message speaks of a '||' token giovannibajo at libero dot it
2004-04-07 13:31 ` pinskia at gcc dot gnu dot org
2004-04-08 18:34 ` bangerth at dealii dot org
2004-04-08 18:53 ` Zack Weinberg
2004-04-08 18:53 ` zack at codesourcery dot com
2004-04-08 19:54 ` gdr at integrable-solutions dot net
[not found] <bug-14875-8295@http.gcc.gnu.org/bugzilla/>
2007-01-28 2:41 ` manu at gcc dot gnu dot org
2007-01-28 4:11 ` gdr at cs dot tamu dot edu
2007-02-01 12:16 ` manu at gcc dot gnu dot org
2007-11-22 8:39 ` spiridenok at tut dot by
2009-02-07 20:29 ` manu at gcc dot gnu dot org
2009-04-22 15:32 ` manu at gcc dot gnu dot org
2009-04-22 15:33 ` manu at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).