================
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify %s
+
+// expected-error@+1{{'clang::sycl_external' attribute only applies to 
functions}}
+[[clang::sycl_external]] int a;
+
+
+// expected-error@+2{{'clang::sycl_external' attribute only applies to 
functions}}
+struct s {
+[[clang::sycl_external]] int b;
+};
+
+// expected-error@+1{{'clang::sycl_external' attribute takes no arguments}}
+[[clang::sycl_external(3)]] void bar() {}
+
+// FIXME: The first declaration of a function is required to have the 
attribute.
+// The attribute may be optionally present on subsequent declarations
+int foo(int c);
+
+[[clang::sycl_external]] void foo();
----------------
tahonermann wrote:

These examples are all grammatically correct because the tokens form a valid 
[_attribute-specifier_](https://eel.is/c++draft/dcl.attr#nt:attribute-specifier)
 and are placed in a grammatically correct position in each declaration. The 
only part of the syntax that would be grammatically specific to `sycl_external` 
would be the syntax of its arguments; if it took any. I think it is reasonable 
to keep (invalid) examples like `bar()` that exercise arguments here since, if 
the attribute were extended to accept an argument, this would be the right 
place to validate them. I think these are good examples to test in this file:
```
[[clang::sycl_external()]] void bad1();
[[clang::sycl_external(,)]] void bad2();
[[clang::sycl_external(3)]] void bad3();
[[clang::sycl_external(4,)]] void bad4();
```

The `a` and `b` examples exercise appertainment and I think would best be 
placed in a `sycl-external-attr-appertainment.cpp` test.

The `foo()` example is redundant; similar declarations are validated by 
`sycl-external-attr.cpp`.

https://github.com/llvm/llvm-project/pull/140282
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to