[Bug c++/84789] [6/7/8 Regression] ICE with broken variable declaration in template class

2018-03-22 Thread aoliva at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84789

--- Comment #6 from Alexandre Oliva  ---
Author: aoliva
Date: Fri Mar 23 01:19:14 2018
New Revision: 258792

URL: https://gcc.gnu.org/viewcvs?rev=258792=gcc=rev
Log:
[PR c++/84789] do not fail to resolve typename into template-independent

Although resolve_typename_type always takes a template-dependent
type-id, and it usually resolves it to another template-dependent
type-id, it is not correct to require the latter: in declarators,
template-dependent scopes may turn out to name template-independent
types, as in the pr84789-2.C and pr84789-3.C testcases.

The ill-formed testcase pr84789.C trips the same too-strict assert,
and also gets fixed by removing the assertion on the simplified scope.
However, whereas when the dependent type cannot be resolved, we get an
error that suggests 'typename' is missing:

pr84789.C:12:3: error: need ‘typename’ before ‘typename B::A::I::I’
because ‘typename B::A::I’ is a dependent scope
   B::A::I::I i;
   ^~~~

when it can, we got errors that did not point at that possibility,
which may be confusing:

pr84789.C:9:15: error: ‘A::I’ {aka ‘int’} is not a class type
   B::A::I::I i; // { dg-error "typename" }
   ^
pr84789.C:9:15: error: ‘I’ in ‘A::I’ {aka ‘int’} does not name a type

Changing the parser diagnostic code that reports an invalid type name
so that it does not attempt to reparse the name as a declarator gets
us the superior diagnostic of a missing 'typename' keyword.


for  gcc/cp/ChangeLog

PR c++/84789
* pt.c (resolve_typename_type): Drop assert that stopped
simplification to template-independent types.  Add assert to
verify the initial scope is template dependent.
* parser.c (cp_parser_parse_and_diagnose_invalid_type_name):
Reparse the id expression as a type-name, not a declarator.

for  gcc/testsuite/ChangeLog

PR c++/84789
* g++.dg/template/pr84789.C: New.
* g++.dg/template/pr84789-2.C: New.
* g++.dg/template/pr84789-3.C: New.
* g++.dg/parse/dtor11.C: Accept alternate error message.

Added:
trunk/gcc/testsuite/g++.dg/template/pr84789-2.C
trunk/gcc/testsuite/g++.dg/template/pr84789-3.C
trunk/gcc/testsuite/g++.dg/template/pr84789.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/parser.c
trunk/gcc/cp/pt.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/g++.dg/parse/dtor11.C

[Bug c++/84789] [6/7/8 Regression] ICE with broken variable declaration in template class

2018-03-16 Thread aoliva at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84789

Alexandre Oliva  changed:

   What|Removed |Added

   Keywords||patch

--- Comment #5 from Alexandre Oliva  ---
Patch posted, unchanged
https://gcc.gnu.org/ml/gcc-patches/2018-03/msg00823.html

[Bug c++/84789] [6/7/8 Regression] ICE with broken variable declaration in template class

2018-03-15 Thread aoliva at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84789

Alexandre Oliva  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |aoliva at gcc dot 
gnu.org

--- Comment #4 from Alexandre Oliva  ---
Created attachment 43672
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43672=edit
candidate patch

Here's the patch I'm testing

[Bug c++/84789] [6/7/8 Regression] ICE with broken variable declaration in template class

2018-03-14 Thread aoliva at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84789

Alexandre Oliva  changed:

   What|Removed |Added

 CC||aoliva at gcc dot gnu.org

--- Comment #3 from Alexandre Oliva  ---
I started looking into this, but I haven't got very far yet.  The problem,
AFAICT, is that we are resolving B::A to struct A, and then it doesn't look
template-dependent any more.  It's a mistake: we can't resolve B::A within
C during parsing, we can't assume that B won't be specialized to
something that doesn't have A as a base class, but rather as a nested type or
typedef or whatever.
If nobody beats me to it, I'll get back to this after getting some sleep.

[Bug c++/84789] [6/7/8 Regression] ICE with broken variable declaration in template class

2018-03-12 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84789

--- Comment #2 from Marek Polacek  ---
Started with r238696.

[Bug c++/84789] [6/7/8 Regression] ICE with broken variable declaration in template class

2018-03-12 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84789

Marek Polacek  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-03-12
 CC||mpolacek at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #1 from Marek Polacek  ---
Confirmed.

[Bug c++/84789] [6/7/8 Regression] ICE with broken variable declaration in template class

2018-03-12 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84789

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2
Version|unknown |8.0.1
   Target Milestone|--- |6.5