[cfe-commits] r159404 - in /cfe/trunk: lib/Sema/SemaChecking.cpp test/SemaCXX/neon-vector-types.cpp
Douglas Gregor
dgregor at apple.com
Thu Jun 28 18:05:22 PDT 2012
Author: dgregor
Date: Thu Jun 28 20:05:22 2012
New Revision: 159404
URL: http://llvm.org/viewvc/llvm-project?rev=159404&view=rev
Log:
When a builtin that requires a constant is given a type- or
value-dependent expression, don't complain that it wasn't the constant
we wanted. Fixes <rdar://problem/11688587> and PR11074.
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/neon-vector-types.cpp
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=159404&r1=159403&r2=159404&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Jun 28 20:05:22 2012
@@ -405,6 +405,11 @@
#undef GET_NEON_IMMEDIATE_CHECK
};
+ // We can't check the value of a dependent argument.
+ if (TheCall->getArg(i)->isTypeDependent() ||
+ TheCall->getArg(i)->isValueDependent())
+ return false;
+
// Check that the immediate argument is actually a constant.
if (SemaBuiltinConstantArg(TheCall, i, Result))
return true;
@@ -1478,7 +1483,11 @@
// constant integers.
for (unsigned i = 1; i != NumArgs; ++i) {
Expr *Arg = TheCall->getArg(i);
-
+
+ // We can't check the value of a dependent argument.
+ if (Arg->isTypeDependent() || Arg->isValueDependent())
+ continue;
+
llvm::APSInt Result;
if (SemaBuiltinConstantArg(TheCall, i, Result))
return true;
@@ -1523,7 +1532,12 @@
// For compatibility check 0-3, llvm only handles 0 and 2.
bool Sema::SemaBuiltinObjectSize(CallExpr *TheCall) {
llvm::APSInt Result;
-
+
+ // We can't check the value of a dependent argument.
+ if (TheCall->getArg(1)->isTypeDependent() ||
+ TheCall->getArg(1)->isValueDependent())
+ return false;
+
// Check constant-ness first.
if (SemaBuiltinConstantArg(TheCall, 1, Result))
return true;
Modified: cfe/trunk/test/SemaCXX/neon-vector-types.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/neon-vector-types.cpp?rev=159404&r1=159403&r2=159404&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/neon-vector-types.cpp (original)
+++ cfe/trunk/test/SemaCXX/neon-vector-types.cpp Thu Jun 28 20:05:22 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify "-triple" "thumbv7-apple-ios3.0.0" %s
// rdar://9208404
typedef int MP4Err;
@@ -25,3 +25,20 @@
return 0;
}
+namespace rdar11688587 {
+ typedef float float32_t;
+ typedef __attribute__((neon_vector_type(4))) float32_t float32x4_t;
+
+ template<int I>
+ float test()
+ {
+ extern float32x4_t vec;
+ return __extension__ ({
+ float32x4_t __a = (vec);
+ (float32_t)__builtin_neon_vgetq_lane_f32(__a, I); // expected-error{{argument should be a value from 0 to 3}}
+ });
+ }
+
+ template float test<1>();
+ template float test<4>(); // expected-note{{in instantiation of function template specialization 'rdar11688587::test<4>' requested here}}
+}
More information about the cfe-commits
mailing list