[PATCH] D15858: Warn undeclared identifiers in CUDA kernel calls
Jason Henline via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 6 11:56:46 PST 2016
jhen updated this revision to Diff 44143.
jhen added a comment.
- Assert setConfig only called once
http://reviews.llvm.org/D15858
Files:
include/clang/AST/ExprCXX.h
test/SemaCUDA/kernel-call.cu
Index: test/SemaCUDA/kernel-call.cu
===================================================================
--- test/SemaCUDA/kernel-call.cu
+++ test/SemaCUDA/kernel-call.cu
@@ -23,4 +23,6 @@
int (*fp)(int) = h2;
fp<<<1, 1>>>(42); // expected-error {{must have void return type}}
+
+ g1<<<undeclared, 1>>>(42); // expected-error {{use of undeclared identifier 'undeclared'}}
}
Index: include/clang/AST/ExprCXX.h
===================================================================
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -155,6 +155,7 @@
class CUDAKernelCallExpr : public CallExpr {
private:
enum { CONFIG, END_PREARG };
+ bool IsConfigSet = false;
public:
CUDAKernelCallExpr(ASTContext &C, Expr *fn, CallExpr *Config,
@@ -171,7 +172,19 @@
return cast_or_null<CallExpr>(getPreArg(CONFIG));
}
CallExpr *getConfig() { return cast_or_null<CallExpr>(getPreArg(CONFIG)); }
- void setConfig(CallExpr *E) { setPreArg(CONFIG, E); }
+
+ /// \brief Sets the kernel configuration expression.
+ ///
+ /// Note that this method can only be called once per class instance.
+ void setConfig(CallExpr *E) {
+ assert(
+ !IsConfigSet &&
+ "CUDAKernelCallExpr.setConfig can only be called once per instance.");
+ setPreArg(CONFIG, E);
+ setInstantiationDependent(isInstantiationDependent() ||
+ E->isInstantiationDependent());
+ IsConfigSet = true;
+ }
static bool classof(const Stmt *T) {
return T->getStmtClass() == CUDAKernelCallExprClass;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15858.44143.patch
Type: text/x-patch
Size: 1550 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160106/37716918/attachment.bin>
More information about the cfe-commits
mailing list