diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -358,6 +358,9 @@ } def : Creator<[{ + auto *Previous = cast(declaration)->getCanonicalDecl(); + if (Previous && Previous->getTypeForDecl()) + return Previous->getTypeForDecl()->getCanonicalTypeInternal(); return ctx.getTypeDeclType(cast(declaration)); }]>; } diff --git a/clang/test/Modules/Inputs/odr_using_dependent_name/X.cppm b/clang/test/Modules/Inputs/odr_using_dependent_name/X.cppm new file mode 100644 --- /dev/null +++ b/clang/test/Modules/Inputs/odr_using_dependent_name/X.cppm @@ -0,0 +1,3 @@ +module; +#include "foo.h" +export module X; diff --git a/clang/test/Modules/Inputs/odr_using_dependent_name/foo.h b/clang/test/Modules/Inputs/odr_using_dependent_name/foo.h new file mode 100644 --- /dev/null +++ b/clang/test/Modules/Inputs/odr_using_dependent_name/foo.h @@ -0,0 +1,9 @@ +template +struct bar { + using Ty = int; +}; +template +struct foo : public bar { + using typename bar::Ty; + void baz(Ty); +}; diff --git a/clang/test/Modules/odr_using_dependent_name.cppm b/clang/test/Modules/odr_using_dependent_name.cppm new file mode 100644 --- /dev/null +++ b/clang/test/Modules/odr_using_dependent_name.cppm @@ -0,0 +1,9 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t +// RUN: %clang -std=c++20 %S/Inputs/odr_using_dependent_name/X.cppm --precompile -o %t/X.pcm +// RUN: %clang -std=c++20 -I%S/Inputs/odr_using_dependent_name -fprebuilt-module-path=%t %s --precompile -c +// expected-no-diagnostics +module; +#include "foo.h" +export module Y; +import X;