[Sema] Don't crash if array bound calculation overflowed constexpr array

We didn't correctly expect a QualifiedTypeLoc when faced with fixing a
variable array type into a constant array type.

Differential Revision: http://reviews.llvm.org/D8958

llvm-svn: 235251
This commit is contained in:
David Majnemer 2015-04-18 04:55:51 +00:00
parent 45951a6626
commit bc4cc14cd7
2 changed files with 4 additions and 0 deletions

View File

@ -4891,6 +4891,8 @@ static QualType TryToFixInvalidVariablyModifiedType(QualType T,
static void
FixInvalidVariablyModifiedTypeLoc(TypeLoc SrcTL, TypeLoc DstTL) {
SrcTL = SrcTL.getUnqualifiedLoc();
DstTL = DstTL.getUnqualifiedLoc();
if (PointerTypeLoc SrcPTL = SrcTL.getAs<PointerTypeLoc>()) {
PointerTypeLoc DstPTL = DstTL.castAs<PointerTypeLoc>();
FixInvalidVariablyModifiedTypeLoc(SrcPTL.getPointeeLoc(),

View File

@ -139,3 +139,5 @@ constexpr int f(ArrBad) { return 0; } // expected-error {{1st parameter type 'Ar
constexpr int arb(int n) {
int a[n]; // expected-error {{variable of non-literal type 'int [n]' cannot be defined in a constexpr function}}
}
constexpr long Overflow[ // expected-error {{constexpr variable cannot have non-literal type 'long const[(1 << 30) << 2]'}}
(1 << 30) << 2]{}; // expected-warning {{requires 34 bits to represent}}