Bug 29048 - [4.0/4.1/4.2/4.3 Regression] "`x' is private" error duplicated when scope specified
Summary: [4.0/4.1/4.2/4.3 Regression] "`x' is private" error duplicated when scope spe...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.2
: P2 minor
Target Milestone: 4.1.3
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on: 19375
Blocks:
  Show dependency treegraph
 
Reported: 2006-09-12 22:27 UTC by S. Davis Herring
Modified: 2008-02-12 19:28 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work: 3.3.3
Known to fail: 3.4.0 4.0.0 4.1.0 4.2.0
Last reconfirmed: 2007-08-06 14:46:30


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description S. Davis Herring 2006-09-12 22:27:11 UTC
Given file `ptest.cpp':

class A {int i;};
class B : public A {B() {A::i=0;}};

I get (with quotes replaced with ASCII and some bijective directory simplification)

$ g++ -v ptest.cpp
Reading specs from /opt/local/gcc402/bin/../lib/gcc/i686-pc-linux-gnu/4.0.2/specs
Target: i686-pc-linux-gnu
Configured with: /opt/build/gcc-4.0.2/configure --with-included-gettext --enable-libgcj --enable-__cxa_atexit --with-gmp=/usr/packages/libgmp41 --with-mpfr=/usr/packages/libmpfr22 --with-gmp-ldflags=-Wl,-rpath,/usr/packages/libgmp41/lib --with-mpfr-ldflags=-Wl,-rpath,/usr/packages/libmpfr22/lib --enable-languages=ada,c,c++,f95,java --datadir=/usr/packages/gcc402/share --with-gnu-as --with-as=/usr/packages/gcc402/i686-pc-linux-gnu/bin/as --with-gnu-ld --with-ld=/usr/packages/gcc402/i686-pc-linux-gnu/bin/ld --with-local-prefix=/usr/packages/gcc402 --with-gxx-include-dir=/usr/packages/gcc402/include/c++ --prefix=/usr/packages/gcc402
Thread model: posix
gcc version 4.0.2 (TWW)
 /opt/local/gcc402/bin/../libexec/gcc/i686-pc-linux-gnu/4.0.2/cc1plus -quiet -v -iprefix /opt/local/gcc402/bin/../lib/gcc/i686-pc-linux-gnu/4.0.2/ -D_GNU_SOURCE ptest.cpp -quiet -dumpbase ptest.cpp -mtune=pentiumpro -auxbase ptest -version -o /tmp/cccHYSJN.s
ignoring nonexistent directory "/opt/local/gcc402/bin/../lib/gcc/i686-pc-linux-gnu/4.0.2/../../../../i686-pc-linux-gnu/include"
ignoring duplicate directory "/usr/packages/gcc402/lib/gcc/i686-pc-linux-gnu/4.0.2/include"
ignoring nonexistent directory "/usr/packages/gcc402/lib/gcc/i686-pc-linux-gnu/4.0.2/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/local/gcc402/bin/../lib/gcc/i686-pc-linux-gnu/4.0.2/include
 /usr/packages/gcc402/include/c++
 /usr/packages/gcc402/include/c++/i686-pc-linux-gnu
 /usr/packages/gcc402/include/c++/backward
 /usr/packages/gcc402/include
 /usr/include
End of search list.
GNU C++ version 4.0.2 (TWW) (i686-pc-linux-gnu)
	compiled by GNU C version 4.0.2 (TWW).
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=128115
ptest.cpp: In constructor `B::B()':
ptest.cpp:1: error: `int A::i' is private
ptest.cpp:2: error: within this context
ptest.cpp:1: error: `int A::i' is private
ptest.cpp:2: error: within this context

The error is quite accurate, but it's given twice!  The error is only printed once if "A::" is omitted from the file.
Comment 1 Andrew Pinski 2006-09-12 22:32:01 UTC
Related to PR 19375.
Confirmed, a regression.
Comment 2 Steven Bosscher 2006-10-10 06:48:43 UTC
I'll look into this.
Comment 3 Steven Bosscher 2006-10-12 21:22:32 UTC
I thought it would simply be a matter of using TREE_NO_WARNING ... until I realized this was not a warning but an error.

Anyway, following the method of the fix for PR19375, I bootstrapped and tested this patch below, but since this is a language issue and my understanding of C++ is non-existing, I'm unassigning myself from this PR.

Index: semantics.c
===================================================================
--- semantics.c (revision 117672)
+++ semantics.c (working copy)
@@ -1559,8 +1559,12 @@ finish_qualified_id_expr (tree qualifyin
        transformation, as there is no "this" pointer.  */
     ;
   else if (TREE_CODE (expr) == FIELD_DECL)
-    expr = finish_non_static_data_member (expr, current_class_ref,
-                                         qualifying_class);
+    {
+      push_deferring_access_checks (dk_no_check);
+      expr = finish_non_static_data_member (expr, current_class_ref,
+                                           qualifying_class);
+      pop_deferring_access_checks ();
+    }
   else if (BASELINK_P (expr) && !processing_template_decl)
     {
       tree fns;
Comment 4 Gabriel Dos Reis 2007-02-03 20:09:37 UTC
won't fix in GCC-4.0.x.  Adjusting milestone.
Comment 5 Jason Merrill 2008-02-12 17:27:20 UTC
Subject: Bug 29048

Author: jason
Date: Tue Feb 12 17:26:34 2008
New Revision: 132261

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132261
Log:
        PR c++/29048
        * semantics.c (finish_qualified_id_expr): Avoid duplicate access
        check here, too.

Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/semantics.c

Comment 6 Jason Merrill 2008-02-12 19:26:12 UTC
Subject: Bug 29048

Author: jason
Date: Tue Feb 12 19:25:28 2008
New Revision: 132265

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132265
Log:
        PR c++/29048
        * semantics.c (finish_qualified_id_expr): Avoid duplicate access
        check here, too.

Added:
    trunk/gcc/testsuite/g++.dg/lookup/duperr1.C

Comment 7 Jason Merrill 2008-02-12 19:28:42 UTC
Fixed for 4.3.0, not worth fixing on earlier release branches.