diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -6502,6 +6502,7 @@ Desugar, Attributed, Parens, + Array, Pointer, BlockPointer, Reference, @@ -6522,6 +6523,10 @@ } else if (isa(Ty)) { T = cast(Ty)->getInnerType(); Stack.push_back(Parens); + } else if (isa(Ty) || isa(Ty) || + isa(Ty)) { + T = cast(Ty)->getElementType(); + Stack.push_back(Array); } else if (isa(Ty)) { T = cast(Ty)->getPointeeType(); Stack.push_back(Pointer); @@ -6599,6 +6604,27 @@ case MacroQualified: return wrap(C, cast(Old)->getUnderlyingType(), I); + case Array: { + if (const auto *CAT = dyn_cast(Old)) { + QualType New = wrap(C, CAT->getElementType(), I); + return C.getConstantArrayType(New, CAT->getSize(), CAT->getSizeExpr(), + CAT->getSizeModifier(), + CAT->getIndexTypeCVRQualifiers()); + } + + if (const auto *VAT = dyn_cast(Old)) { + QualType New = wrap(C, VAT->getElementType(), I); + return C.getVariableArrayType( + New, VAT->getSizeExpr(), VAT->getSizeModifier(), + VAT->getIndexTypeCVRQualifiers(), VAT->getBracketsRange()); + } + + const auto *IAT = cast(Old); + QualType New = wrap(C, IAT->getElementType(), I); + return C.getIncompleteArrayType(New, IAT->getSizeModifier(), + IAT->getIndexTypeCVRQualifiers()); + } + case Pointer: { QualType New = wrap(C, cast(Old)->getPointeeType(), I); return C.getPointerType(New); diff --git a/clang/test/CodeGen/attr-noreturn.c b/clang/test/CodeGen/attr-noreturn.c new file mode 100644 --- /dev/null +++ b/clang/test/CodeGen/attr-noreturn.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -S -emit-llvm %s -o - | FileCheck %s + +typedef void (*fptrs_t[4])(void); +fptrs_t p __attribute__((noreturn)); + +void __attribute__((noreturn)) f() { + p[0](); +} +// CHECK: call +// CHECK-NEXT: unreachable diff --git a/clang/test/Sema/attr-noreturn.c b/clang/test/Sema/attr-noreturn.c --- a/clang/test/Sema/attr-noreturn.c +++ b/clang/test/Sema/attr-noreturn.c @@ -42,3 +42,34 @@ } typedef void (*Fun)(void) __attribute__ ((noreturn(2))); // expected-error {{'noreturn' attribute takes no arguments}} + + +typedef void fn_t(void); + +fn_t *fp __attribute__((noreturn)); +void __attribute__((noreturn)) f6(int i) { + fp(); +} + +fn_t *fps[4] __attribute__((noreturn)); +void __attribute__((noreturn)) f7(int i) { + fps[i](); +} + +extern fn_t *ifps[] __attribute__((noreturn)); +void __attribute__((noreturn)) f8(int i) { + ifps[i](); +} + +void __attribute__((noreturn)) f9(int n) { + extern int g9(int, fn_t **); + fn_t *fp[n] __attribute__((noreturn)); + int i = g9(n, fp); + fp[i](); +} + +typedef fn_t *fptrs_t[4]; +fptrs_t ps __attribute__((noreturn)); +void __attribute__((noreturn)) f10(int i) { + ps[i](); +}