From: Douglas Gregor Date: Tue, 22 Jun 2010 23:13:52 +0000 (+0000) Subject: Teach Type::isRealType() that vector types are never real types. All X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4b1317264037732fff3653ac6f494b124c726e1b;p=clang Teach Type::isRealType() that vector types are never real types. All of the callers of isRealType() already assumed this, and one of them (increment/decrement) mistakenly permitted increments of vector types because of it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106596 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index a8ead6d46b..af4b7eb3a6 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -585,8 +585,6 @@ bool Type::isRealType() const { BT->getKind() <= BuiltinType::LongDouble; if (const TagType *TT = dyn_cast(CanonicalType)) return TT->getDecl()->isEnum() && TT->getDecl()->isDefinition(); - if (const VectorType *VT = dyn_cast(CanonicalType)) - return VT->getElementType()->isRealType(); return false; } diff --git a/test/Sema/ext_vector_casts.c b/test/Sema/ext_vector_casts.c index be09903e00..7b7b0caf0a 100644 --- a/test/Sema/ext_vector_casts.c +++ b/test/Sema/ext_vector_casts.c @@ -45,3 +45,7 @@ static void test() { } typedef __attribute__(( ext_vector_type(2) )) float2 vecfloat2; // expected-error{{invalid vector type 'float2'}} + +void inc(float2 f2) { + f2++; // expected-error{{cannot increment value of type 'float2'}} +}