[PATCH] D26735: [OpenCL] Disable && (address of label) GNU extension for OpenCL

Egor Churaev via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 16 01:52:07 PST 2016


echuraev created this revision.
echuraev added a reviewer: cfe-commits.
Herald added a subscriber: yaxunl.

Patch by Guy Benyei


https://reviews.llvm.org/D26735

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  lib/Parse/ParseExpr.cpp
  test/SemaOpenCL/ampamp-gnu.cl


Index: test/SemaOpenCL/ampamp-gnu.cl
===================================================================
--- /dev/null
+++ test/SemaOpenCL/ampamp-gnu.cl
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+kernel void foo(global int *in) {
+  int a;
+  void *p = &&a; // expected-error {{OpenCL does not support address of label ('&&') GNU extension}}
+
+  void *hlbl_tbl[] = { &&label1 }; // expected-error {{OpenCL does not support address of label ('&&') GNU extension}}
+label1:
+  a = 0;
+}
Index: lib/Parse/ParseExpr.cpp
===================================================================
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -1104,6 +1104,9 @@
     if (Tok.isNot(tok::identifier))
       return ExprError(Diag(Tok, diag::err_expected) << tok::identifier);
 
+    if (getLangOpts().OpenCL)
+      return ExprError(Diag(Tok, diag::err_opencl_address_of_label));
+
     if (getCurScope()->getFnParent() == nullptr)
       return ExprError(Diag(Tok, diag::err_address_of_label_outside_fn));
     
Index: include/clang/Basic/DiagnosticParseKinds.td
===================================================================
--- include/clang/Basic/DiagnosticParseKinds.td
+++ include/clang/Basic/DiagnosticParseKinds.td
@@ -972,6 +972,8 @@
   "OpenCL extension %0 is core feature or supported optional core feature - ignoring">, InGroup<DiagGroup<"pedantic-core-features">>, DefaultIgnore;
 
 // OpenCL errors.
+def err_opencl_address_of_label : Error<
+  "OpenCL does not support address of label ('&&') GNU extension">;
 def err_opencl_taking_function_address_parser : Error<
   "taking address of function is not allowed">;
 def err_opencl_logical_exclusive_or : Error<


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26735.78147.patch
Type: text/x-patch
Size: 1712 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161116/687c75cb/attachment.bin>


More information about the cfe-commits mailing list