Skip to content

[clang] error recovery not recognizing out-of-line definition #142087

Open
@mizvekov

Description

@mizvekov

Consider: https://compiler-explorer.com/z/eqb4oqWqP

template<class T> class A;

template<class T>
typename A<T>::Z A<T>::X = 0;    // #1

template<class T>
typename A<T>::Z A<T>::X::Y = 0; // #2

We recognize that #1 is an out-of-line definition attempt, and produce a sensible diagnostic that A has no definition.

Now add one more component to the nested name specifier, as in #2, and now clang tries a name lookup into A<T>, and complains it can't find X, even though there is no definition at all.

This is otherwise a valid out of line definition for an example like: https://compiler-explorer.com/z/Wh84qvaY4

template<class T> class A {
    class X {
        static int Y;
    };
    using Z = int;
};

template<class T>
typename A<T>::Z A<T>::X::Y = 0;

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions