mirror of https://github.com/microsoft/clang.git
Fix crash on noreturn conversion in unprototyped function type. Thanks to Keith
Walker for spotting the bug. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284673 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9dc238026d
commit
562d964f19
|
@ -1432,7 +1432,7 @@ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType,
|
|||
const auto *FromFn = cast<FunctionType>(CanFrom);
|
||||
FunctionType::ExtInfo FromEInfo = FromFn->getExtInfo();
|
||||
|
||||
const auto *ToFn = dyn_cast<FunctionProtoType>(CanTo);
|
||||
const auto *ToFn = cast<FunctionType>(CanTo);
|
||||
FunctionType::ExtInfo ToEInfo = ToFn->getExtInfo();
|
||||
|
||||
bool Changed = false;
|
||||
|
@ -1445,7 +1445,7 @@ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType,
|
|||
|
||||
// Drop 'noexcept' if not present in target type.
|
||||
if (const auto *FromFPT = dyn_cast<FunctionProtoType>(FromFn)) {
|
||||
const auto *ToFPT = dyn_cast<FunctionProtoType>(ToFn);
|
||||
const auto *ToFPT = cast<FunctionProtoType>(ToFn);
|
||||
if (FromFPT->isNothrow(Context) && !ToFPT->isNothrow(Context)) {
|
||||
FromFn = cast<FunctionType>(
|
||||
Context.getFunctionType(FromFPT->getReturnType(),
|
||||
|
|
|
@ -4,13 +4,24 @@
|
|||
typedef void (*Fn_noret)(void) __attribute__((noreturn));
|
||||
typedef void (*Fn_ret)(void);
|
||||
|
||||
typedef void (*Fn_noret_noproto)() __attribute__((noreturn));
|
||||
typedef void (*Fn_ret_noproto)();
|
||||
|
||||
void foo(void);
|
||||
void foo_noret(void) __attribute__((noreturn));
|
||||
|
||||
void foo_noproto();
|
||||
void foo_noret_noproto() __attribute__((noreturn));
|
||||
|
||||
void test() {
|
||||
Fn_noret fn2 = &foo; // expected-warning {{incompatible function pointer types initializing 'Fn_noret'}}
|
||||
Fn_noret fn3 = &foo_noret;
|
||||
Fn_ret fn4 = &foo_noret;
|
||||
Fn_ret fn5 = &foo;
|
||||
|
||||
Fn_noret_noproto fn6 = &foo_noproto; // expected-warning {{incompatible function pointer types initializing 'Fn_noret_noproto'}}
|
||||
Fn_noret_noproto fn7 = &foo_noret_noproto;
|
||||
Fn_ret_noproto fn8 = &foo_noret_noproto;
|
||||
Fn_ret_noproto fn9 = &foo_noproto;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue