================
@@ -2472,13 +2473,23 @@ bool
Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
NewDefaultLoc = NewTypeParm->getDefaultArgumentLoc();
SawDefaultArgument = true;
- if (!OldTypeParm->getOwningModule())
----------------
Qayyum-Ahmed wrote:
That would fix the null dereference, but treating “not imported” as always a
redefinition would regress header modules. In
crash-instantiated-in-scope-cxx-modules6.cpp, co.h contains a forward
declaration and later the full definition of template <typename Promise = void>
struct coroutine_handle; both with the same default. This is valid for local
header modules, but using only getImportedOwningModule() would treat the second
declaration as a same-TU redefinition and incorrectly diagnose it.
We therefore need to distinguish the local header-module case so identical
defaults are allowed there, while still keeping the GMF strict and only calling
getFullModuleName() when the previous declaration actually comes from an
imported module.
See this snippet from crash-instantiated-in-scope-cxx-modules6.cpp:
[https://github.com/llvm/llvm-project/blob/main/clang/test/Headers/crash-instantiated-in-scope-cxx-modules6.cpp#L78-L87](url)
https://github.com/llvm/llvm-project/pull/185237
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits