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<


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<
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to