public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/20420] New: Unrecognized double declarations
@ 2005-03-11 9:47 wolfgang dot roehrl at de dot gi-de dot com
2005-03-11 14:51 ` [Bug c++/20420] " bangerth at dealii dot org
2005-03-12 6:19 ` [Bug c++/20420] Incorrectly Accepts " lerdsuwa at gcc dot gnu dot org
0 siblings, 2 replies; 11+ messages in thread
From: wolfgang dot roehrl at de dot gi-de dot com @ 2005-03-11 9:47 UTC (permalink / raw)
To: gcc-bugs
Dear all,
I would like to post a bug report for the GNU C/C++ compiler 3.3-e500.
We use the compiler to generate code for a PowerPC processor.
Used invokation line for the GNU C++ compiler:
ccppc -c -x c++ -ansi -Wall -Werror -mcpu=8540 -fverbose-asm -mbig
-fmerge-templates -mmultiple -mno-string -mstrict-align -O3
-fno-exceptions -fno-rtti -fno-builtin-printf
-I<different include paths>
-D<differen #define's>
K.CPP -oK.O
// file K.CPP
class B
{
protected:
enum E { E1, E2, E3 };
struct S { int i; E e; };
};
class D : private B
{
public:
using B::E;
using B::S;
private:
enum E {};
struct S {};
};
The compiler does not complain about the double declarations of enum E and
struct S. (By the way, the Comeau online compiler recognizes the doubly
declared items.)
Kind regards
W. Roehrl
--
Summary: Unrecognized double declarations
Product: gcc
Version: 3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: wolfgang dot roehrl at de dot gi-de dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: sparc-sun-solaris2.5.1
GCC host triplet: i386-pc-mingw32
GCC target triplet: powerpc-wrs-vxworks
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20420
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/20420] Unrecognized double declarations
2005-03-11 9:47 [Bug c++/20420] New: Unrecognized double declarations wolfgang dot roehrl at de dot gi-de dot com
@ 2005-03-11 14:51 ` bangerth at dealii dot org
2005-03-12 6:19 ` [Bug c++/20420] Incorrectly Accepts " lerdsuwa at gcc dot gnu dot org
1 sibling, 0 replies; 11+ messages in thread
From: bangerth at dealii dot org @ 2005-03-11 14:51 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2005-03-11 14:50 -------
Confirmed, with all gcc versions I have on my system. Here's what icc says:
g/x> icc -Xc -ansi -c x.cc
x.cc(15): error: "E" has already been declared in the current scope
enum E {};
^
x.cc(16): error: "S" has already been declared in the current scope
struct S {};
^
compilation aborted for x.cc (code 2)
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |accepts-invalid
Known to fail| |2.95.3 3.2.3 3.3.1 3.3.4
| |3.4.3 4.0.0
Last reconfirmed|0000-00-00 00:00:00 |2005-03-11 14:50:52
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20420
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/20420] Incorrectly Accepts double declarations
2005-03-11 9:47 [Bug c++/20420] New: Unrecognized double declarations wolfgang dot roehrl at de dot gi-de dot com
2005-03-11 14:51 ` [Bug c++/20420] " bangerth at dealii dot org
@ 2005-03-12 6:19 ` lerdsuwa at gcc dot gnu dot org
1 sibling, 0 replies; 11+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2005-03-12 6:19 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From lerdsuwa at gcc dot gnu dot org 2005-03-12 06:18 -------
It's xref_tag/push_tag bug.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |lerdsuwa at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2005-03-11 14:50:52 |2005-03-12 06:18:58
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20420
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/20420] Incorrectly Accepts double declarations
[not found] <bug-20420-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2012-08-23 9:44 ` paolo at gcc dot gnu.org
@ 2012-08-23 9:53 ` paolo.carlini at oracle dot com
3 siblings, 0 replies; 11+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-08-23 9:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20420
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #10 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-08-23 09:53:40 UTC ---
Fixed for 4.8.0.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/20420] Incorrectly Accepts double declarations
[not found] <bug-20420-4@http.gcc.gnu.org/bugzilla/>
2012-08-21 19:26 ` paolo.carlini at oracle dot com
2012-08-22 0:01 ` paolo.carlini at oracle dot com
@ 2012-08-23 9:44 ` paolo at gcc dot gnu.org
2012-08-23 9:53 ` paolo.carlini at oracle dot com
3 siblings, 0 replies; 11+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-08-23 9:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20420
--- Comment #9 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-08-23 09:44:12 UTC ---
Author: paolo
Date: Thu Aug 23 09:44:08 2012
New Revision: 190618
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190618
Log:
/cp
2012-08-23 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/20420
* name-lookup.c (supplement_binding_1): Handle specially enums
only in class templates.
(validate_nonmember_using_decl): Enforce 7.3.3/10 about duplicate
using declarations at function scope.
/testsuite
2012-08-23 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/20420
* g++.dg/lookup/using53.C: New.
Added:
trunk/gcc/testsuite/g++.dg/lookup/using53.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/name-lookup.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/20420] Incorrectly Accepts double declarations
[not found] <bug-20420-4@http.gcc.gnu.org/bugzilla/>
2012-08-21 19:26 ` paolo.carlini at oracle dot com
@ 2012-08-22 0:01 ` paolo.carlini at oracle dot com
2012-08-23 9:44 ` paolo at gcc dot gnu.org
2012-08-23 9:53 ` paolo.carlini at oracle dot com
3 siblings, 0 replies; 11+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-08-22 0:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20420
--- Comment #8 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-08-22 00:01:27 UTC ---
For Comment #4: the validate_nonmember_using_decl call at the beginning of
do_local_using_decl returns NULL_TREE for the second using declaration, but we
ignore that and return without error. That doesn't seem right for VAR_DECLs.
This combo patchlet passes testing:
Index: name-lookup.c
===================================================================
--- name-lookup.c (revision 190569)
+++ name-lookup.c (working copy)
@@ -441,7 +441,8 @@ supplement_binding_1 (cxx_binding *binding, tree d
template in order to handle late matching of underlying
type on an opaque-enum-declaration followed by an
enum-specifier. */
- || (TREE_CODE (TREE_TYPE (target_decl)) == ENUMERAL_TYPE
+ || (processing_template_decl
+ && TREE_CODE (TREE_TYPE (target_decl)) == ENUMERAL_TYPE
&& TREE_CODE (TREE_TYPE (target_bval)) == ENUMERAL_TYPE
&& (dependent_type_p (ENUM_UNDERLYING_TYPE
(TREE_TYPE (target_decl)))
@@ -2581,7 +2582,11 @@ do_local_using_decl (tree decl, tree scope, tree n
decl = validate_nonmember_using_decl (decl, scope, name);
if (decl == NULL_TREE)
- return;
+ {
+ if (TREE_CODE (orig_decl) == VAR_DECL)
+ error ("%qD is already declared in this scope", name);
+ return;
+ }
if (building_stmt_list_p ()
&& at_function_scope_p ())
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/20420] Incorrectly Accepts double declarations
[not found] <bug-20420-4@http.gcc.gnu.org/bugzilla/>
@ 2012-08-21 19:26 ` paolo.carlini at oracle dot com
2012-08-22 0:01 ` paolo.carlini at oracle dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 11+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-08-21 19:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20420
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
CC|gcc-bugs at gcc dot gnu.org |
AssignedTo|unassigned at gcc dot |paolo.carlini at oracle dot
|gnu.org |com
Known to fail| |
--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-08-21 19:25:05 UTC ---
Currently, the original testcase is *almost* handled correctly - we need
something like the below to avoid an ICE with enums - but we still accept the
snippet in Comment #4: I just checked and apparently per C++11 too we should
reject it. Looking a bit into this, maybe for now I will end up submitting only
the patchlet.
Index: name-lookup.c
===================================================================
--- name-lookup.c (revision 190569)
+++ name-lookup.c (working copy)
@@ -441,7 +441,8 @@ supplement_binding_1 (cxx_binding *binding, tree d
template in order to handle late matching of underlying
type on an opaque-enum-declaration followed by an
enum-specifier. */
- || (TREE_CODE (TREE_TYPE (target_decl)) == ENUMERAL_TYPE
+ || (processing_template_decl
+ && TREE_CODE (TREE_TYPE (target_decl)) == ENUMERAL_TYPE
&& TREE_CODE (TREE_TYPE (target_bval)) == ENUMERAL_TYPE
&& (dependent_type_p (ENUM_UNDERLYING_TYPE
(TREE_TYPE (target_decl)))
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/20420] Incorrectly Accepts double declarations
[not found] <bug-20420-7154@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2006-09-12 4:00 ` bangerth at dealii dot org
@ 2006-09-12 7:44 ` andrew dot stubbs at st dot com
3 siblings, 0 replies; 11+ messages in thread
From: andrew dot stubbs at st dot com @ 2006-09-12 7:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from andrew dot stubbs at st dot com 2006-09-12 07:44 -------
Subject: Re: Incorrectly Accepts double declarations
bangerth at dealii dot org wrote:
> No, that code is definitely legal and unobjectionable. Just as having two
> extern declarations of the same variable in the same scope (or two forward
> declarations of a function) is not a problem.
Not according to the C++ standard. Section 7.3.3 clause 8 explicitly
outlaws this example.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20420
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/20420] Incorrectly Accepts double declarations
[not found] <bug-20420-7154@http.gcc.gnu.org/bugzilla/>
2005-10-22 13:58 ` lerdsuwa at gcc dot gnu dot org
2006-09-11 21:45 ` amylaar at gcc dot gnu dot org
@ 2006-09-12 4:00 ` bangerth at dealii dot org
2006-09-12 7:44 ` andrew dot stubbs at st dot com
3 siblings, 0 replies; 11+ messages in thread
From: bangerth at dealii dot org @ 2006-09-12 4:00 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from bangerth at dealii dot org 2006-09-12 04:00 -------
(In reply to comment #4)
> I suppose this is the same basic problem?
No, that code is definitely legal and unobjectionable. Just as having two
extern declarations of the same variable in the same scope (or two forward
declarations of a function) is not a problem.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20420
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/20420] Incorrectly Accepts double declarations
[not found] <bug-20420-7154@http.gcc.gnu.org/bugzilla/>
2005-10-22 13:58 ` lerdsuwa at gcc dot gnu dot org
@ 2006-09-11 21:45 ` amylaar at gcc dot gnu dot org
2006-09-12 4:00 ` bangerth at dealii dot org
2006-09-12 7:44 ` andrew dot stubbs at st dot com
3 siblings, 0 replies; 11+ messages in thread
From: amylaar at gcc dot gnu dot org @ 2006-09-11 21:45 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from amylaar at gcc dot gnu dot org 2006-09-11 21:45 -------
I suppose this is the same basic problem?
namespace N
{
int i;
}
void
f ()
{
using N::i;
using N::i;
}
--
amylaar at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail|2.95.3 3.2.3 3.3.1 3.3.4 |2.95.3 3.2.3 3.3.1 3.3.4
|3.4.3 4.0.0 |3.4.3 4.0.0 4.2.0
Last reconfirmed|2006-01-20 00:58:45 |2006-09-11 21:45:13
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20420
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/20420] Incorrectly Accepts double declarations
[not found] <bug-20420-7154@http.gcc.gnu.org/bugzilla/>
@ 2005-10-22 13:58 ` lerdsuwa at gcc dot gnu dot org
2006-09-11 21:45 ` amylaar at gcc dot gnu dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 11+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2005-10-22 13:58 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from lerdsuwa at gcc dot gnu dot org 2005-10-22 13:58 -------
Won't work on it for a long while.
--
lerdsuwa at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|lerdsuwa at gcc dot gnu dot |unassigned at gcc dot gnu
|org |dot org
Status|ASSIGNED |NEW
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20420
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2012-08-23 9:53 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-11 9:47 [Bug c++/20420] New: Unrecognized double declarations wolfgang dot roehrl at de dot gi-de dot com
2005-03-11 14:51 ` [Bug c++/20420] " bangerth at dealii dot org
2005-03-12 6:19 ` [Bug c++/20420] Incorrectly Accepts " lerdsuwa at gcc dot gnu dot org
[not found] <bug-20420-7154@http.gcc.gnu.org/bugzilla/>
2005-10-22 13:58 ` lerdsuwa at gcc dot gnu dot org
2006-09-11 21:45 ` amylaar at gcc dot gnu dot org
2006-09-12 4:00 ` bangerth at dealii dot org
2006-09-12 7:44 ` andrew dot stubbs at st dot com
[not found] <bug-20420-4@http.gcc.gnu.org/bugzilla/>
2012-08-21 19:26 ` paolo.carlini at oracle dot com
2012-08-22 0:01 ` paolo.carlini at oracle dot com
2012-08-23 9:44 ` paolo at gcc dot gnu.org
2012-08-23 9:53 ` paolo.carlini at oracle dot com
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).