Bug 85731 - [8/9 Regression] Inner class method declaration changes meaning of outer template class template method
Summary: [8/9 Regression] Inner class method declaration changes meaning of outer temp...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.1.0
: P3 normal
Target Milestone: 8.2
Assignee: Jason Merrill
URL:
Keywords: rejects-valid
: 86195 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-05-10 12:22 UTC by Jaak Ristioja
Modified: 2018-06-19 13:57 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 7.3.0
Known to fail: 8.1.0
Last reconfirmed: 2018-05-14 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jaak Ristioja 2018-05-10 12:22:52 UTC
The following code compiles with GCC 7.3.0 and earlier, but errors with GCC 8.1.0 and trunk.

    template <typename T>
    struct Outer {
        struct Inner;
        template <int I> static void f();
    };

    template <typename T>
    struct Outer<T>::Inner {
        decltype(Outer<T>::f<42>()) f();
    };

    int main() { Outer<int>::Inner().f(); }


<source>: In instantiation of 'struct Outer<int>::Inner':
<source>:12:36:   required from here
<source>:8:28: error: declaration of 'decltype (f<42>()) Outer<T>::Inner::f() [with T = int; decltype (f<42>()) = void]' [-fpermissive]
     struct Outer<T>::Inner {
                            ^
<source>:4:38: error: changes meaning of 'f' from 'static void Outer<T>::f() [with int I = I; T = int]' [-fpermissive]
         template <int I> static void f();
                                      ^
Comment 1 Jonathan Wakely 2018-05-14 14:02:54 UTC
Started with r251438

            PR c++/81236 - ICE with template-id in generic lambda
    
            * semantics.c (finish_id_expression): Remove special dependent case.
            Avoid some later pieces when dependent.
            (finish_qualified_id_expr): Do normal BASELINK handling in a
            template.  Always build a SCOPE_REF for a destructor BIT_NOT_EXPR.
            (parsing_default_capturing_generic_lambda_in_template): Remove.
            * parser.c (cp_parser_postfix_dot_deref_expression): Always give an
            error for types that will never be complete.
            * mangle.c (write_expression): Add sanity check.
            * tree.c (build_qualified_name): Add sanity check.
            (cp_walk_subtrees): Walk into the class context of a BASELINK.
            * lambda.c (add_capture): Improve diagnostic for generic lambda
            capture failure.
            * call.c (build_new_method_call_1): Print the right constructor
            name.
Comment 2 Jason Merrill 2018-06-05 11:27:45 UTC
Author: jason
Date: Tue Jun  5 11:27:12 2018
New Revision: 261196

URL: https://gcc.gnu.org/viewcvs?rev=261196&root=gcc&view=rev
Log:
	PR c++/85731 - wrong error with qualified-id in template.

	* semantics.c (finish_qualified_id_expr): build_qualified_name
	for unbound names in the current class.

Added:
    trunk/gcc/testsuite/g++.dg/template/qualified-id7.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/semantics.c
Comment 3 Jason Merrill 2018-06-05 11:27:47 UTC
Author: jason
Date: Tue Jun  5 11:27:15 2018
New Revision: 261197

URL: https://gcc.gnu.org/viewcvs?rev=261197&root=gcc&view=rev
Log:
	PR c++/85731 - wrong error with qualified-id in template.

	* semantics.c (finish_qualified_id_expr): build_qualified_name
	for unbound names in the current class.

Added:
    branches/gcc-8-branch/gcc/testsuite/g++.dg/template/qualified-id7.C
Modified:
    branches/gcc-8-branch/gcc/cp/ChangeLog
    branches/gcc-8-branch/gcc/cp/semantics.c
Comment 4 Jason Merrill 2018-06-05 11:28:20 UTC
Fixed.
Comment 5 Jonathan Wakely 2018-06-19 13:57:54 UTC
*** Bug 86195 has been marked as a duplicate of this bug. ***