Skip to content

Commit b10d359

Browse files
committed
Fix the non-termplate case
1 parent f22b065 commit b10d359

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

clang/lib/AST/Decl.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3285,9 +3285,8 @@ bool FunctionDecl::isImmediateEscalating() const {
32853285
return true;
32863286

32873287
if (auto *CD = dyn_cast<CXXConstructorDecl>(this);
3288-
CD && CD->isInheritingConstructor() &&
3289-
CD->getInheritedConstructor().getConstructor()->isImmediateEscalating())
3290-
return true;
3288+
CD && CD->isInheritingConstructor())
3289+
return CD->getInheritedConstructor().getConstructor();
32913290

32923291
// - a function that results from the instantiation of a templated entity
32933292
// defined with the constexpr specifier.

clang/test/SemaCXX/cxx2b-consteval-propagate.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -501,19 +501,30 @@ namespace GH112677 {
501501

502502
class ConstEval {
503503
public:
504-
consteval ConstEval(int); // expected-note {{declared here}}
504+
consteval ConstEval(int); // expected-note 2{{declared here}}
505505
};
506506

507-
struct B {
507+
struct TemplateCtor {
508508
ConstEval val;
509509
template <class Anything = int> constexpr
510-
B(int arg) : val(arg) {} // expected-note {{undefined constructor 'ConstEval'}}
510+
TemplateCtor(int arg) : val(arg) {} // expected-note {{undefined constructor 'ConstEval'}}
511511
};
512-
struct C : B {
513-
using B::B; // expected-note {{in call to 'B<int>(0)'}}
512+
struct C : TemplateCtor {
513+
using TemplateCtor::TemplateCtor; // expected-note {{in call to 'TemplateCtor<int>(0)'}}
514514
};
515515

516516
C c(0); // expected-note{{in implicit initialization for inherited constructor of 'C'}}
517-
// expected-error@-1 {{call to immediate function 'GH112677::C::B' is not a constant expression}}
517+
// expected-error@-1 {{call to immediate function 'GH112677::C::TemplateCtor' is not a constant expression}}
518+
519+
struct SimpleCtor { constexpr SimpleCtor(int) {}};
520+
struct D : SimpleCtor {
521+
int y = 10;
522+
ConstEval x = y; // expected-note {{undefined constructor 'ConstEval'}}
523+
using SimpleCtor::SimpleCtor;
524+
//expected-note@-1 {{'SimpleCtor' is an immediate constructor because the default initializer of 'x' contains a call to a consteval constructor 'ConstEval' and that call is not a constant expression}}
525+
};
526+
527+
D d(0); // expected-note {{in implicit initialization for inherited constructor of 'D'}}
528+
// expected-error@-1 {{call to immediate function 'GH112677::D::SimpleCtor' is not a constant expression}}
518529

519530
}

0 commit comments

Comments
 (0)