struct A { A(int i) {} }; struct B { int i; }; struct C { B* p; }; int main() { C c; A(c.p->i); A(c.p.i); return 0; } gets you: ~/ootbc/members/src$ c++ foo.cc foo.cc: In function `int main()': foo.cc:13: error: expected primary-expression before '(' token foo.cc:13: error: `i' has not been declared foo.cc:13: error: request for member of non-aggregate type before ')' token when the actual problem is a wrong dereference level ("." instead of "->")
A related testcase works correctly (if we change A to a function instead): void A(int); struct B { int i; }; struct C { struct B* p; }; int main() { struct C c; A(c.p->i); A(c.p.i); return 0; } ---- pr17821.c:11: error: request for member `i' in non-class type `B*'
Plus this is a regression: 3.3 gives: pr17821.cc:13: error: request for member `i' in `c.C::p', which is of non-class
Subject: Bug 17821 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2004-10-10 05:02:54 Modified files: gcc/testsuite : ChangeLog gcc/cp : ChangeLog error.c init.c parser.c tree.c Added files: gcc/testsuite/g++.dg/init: new11.C gcc/testsuite/g++.dg/parse: error19.C error20.C gcc/testsuite/g++.dg/template: crash24.C Log message: PR c++/17867 * error.c (dump_expr): Correct handling of AGGR_INIT_EXPRs using a constructor. PR c++/17670 * init.c (build_new): Correct comments. * parser.c (cp_parser_new_expression): Use NULL_TREE for nelts in the non-array case. PR c++/17821 * parser.c (cp_parser_postfix_dot_deref_expression): If the pseduo-destructor-name production does not work, fall back to the ordinary production. PR c++/17826 * tree.c (cp_tree_equal): Handle a BASELINK. PR c++/17687 * g++.dg/parse/error19.C: New test. PR c++/17670 * g++.dg/init/new11.C: New test. PR c++/17821 * g++.dg/parse/error20.C: New test. PR c++/17826 * g++.dg/template/crash24.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4426&r2=1.4427 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4416&r2=1.4417 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/error.c.diff?cvsroot=gcc&r1=1.266&r2=1.267 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&r1=1.398&r2=1.399 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.261&r2=1.262 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/tree.c.diff?cvsroot=gcc&r1=1.413&r2=1.414 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/new11.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/error19.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/error20.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash24.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 17821 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: mmitchel@gcc.gnu.org 2004-10-10 05:28:32 Modified files: gcc/testsuite : ChangeLog gcc/cp : ChangeLog parser.c tree.c Added files: gcc/testsuite/g++.dg/parse: error20.C gcc/testsuite/g++.dg/template: crash24.C Log message: PR c++/17867 * error.c (dump_expr): Correct handling of AGGR_INIT_EXPRs using a constructor. PR c++/17670 * init.c (build_new): Correct comments. * parser.c (cp_parser_new_expression): Use NULL_TREE for nelts in the non-array case. PR c++/17821 * parser.c (cp_parser_postfix_dot_deref_expression): If the pseduo-destructor-name production does not work, fall back to the ordinary production. PR c++/17826 * tree.c (cp_tree_equal): Handle a BASELINK. PR c++/17687 * g++.dg/parse/error19.C: New test. PR c++/17670 * g++.dg/init/new11.C: New test. PR c++/17821 * g++.dg/parse/error20.C: New test. PR c++/17826 * g++.dg/template/crash24.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.281&r2=1.3389.2.282 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.165&r2=1.3892.2.166 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.157.2.42&r2=1.157.2.43 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/tree.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.360.4.9&r2=1.360.4.10 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/error20.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash24.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
Fixed in GCC 3.4.3.
Subject: Bug 17821 CVSROOT: /cvs/gcc Module name: gcc Changes by: nathan@gcc.gnu.org 2004-12-17 15:58:05 Modified files: gcc/cp : ChangeLog class.c cp-tree.h error.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/lookup: conv-5.C Log message: cp: PR c++/17821 * class.c (add_method): Do not push conversion operators into a binding level. * cp-tree.h (CLASSTYPE_PRIMARY_TEMPLATE_TYPE): Reformat. * error.c (dump_decl): <TYPE_DECL case> Remove extraneous braces. testsuite: PR c++/17821 * g++.dg/lookup/conv-5.C: New. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4539&r2=1.4540 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&r1=1.695&r2=1.696 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.1081&r2=1.1082 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/error.c.diff?cvsroot=gcc&r1=1.273&r2=1.274 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4773&r2=1.4774 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/conv-5.C.diff?cvsroot=gcc&r1=NONE&r2=1.1