
There were two assertions in DefaultArgStorage::setInherited previously. It requires the DefaultArgument is either empty or an argument value. It would crash if it has a pointer refers to the previous declaration or contains a chain to the previous declaration. But there are edge cases could hit them actually. One is InheritDefaultArguments.cppm that I found recently. Another one is pr31469.cpp, which was created fives years ago. This patch tries to fix the two failures by handling full cases in DefaultArgStorage::setInherited. This is guaranteed to not introduce any breaking change since it lives in the path we wouldn't touch before. And the added assertions for sameness should keep the correctness. Reviewed By: v.g.vassilev Differential Revision: https://reviews.llvm.org/D128974
35 lines
608 B
C++
35 lines
608 B
C++
// RUN: rm -rf %t
|
|
// RUN: split-file %s %t
|
|
// RUN: cd %t
|
|
//
|
|
// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface -o %t/A.pcm
|
|
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use.cppm -verify -fsyntax-only
|
|
|
|
//--- foo.h
|
|
template <typename T, typename U = int>
|
|
class Templ;
|
|
|
|
template <typename T, typename U>
|
|
class Templ {
|
|
public:
|
|
Templ(T t) {}
|
|
};
|
|
|
|
template <typename T>
|
|
Templ(T t) -> Templ<T, int>;
|
|
|
|
//--- A.cppm
|
|
module;
|
|
#include "foo.h"
|
|
export module A;
|
|
|
|
//--- Use.cppm
|
|
// expected-no-diagnostics
|
|
module;
|
|
#include "foo.h"
|
|
export module X;
|
|
import A;
|
|
void foo() {
|
|
Templ t(0);
|
|
}
|