================
@@ -0,0 +1,127 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,c-local -x c %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cpp-local -pedantic -x c++ 
-std=c++11 %s
+
+void foo() {
+  int i;
+  int a[10], b[10];
+
+  [[clang::code_align(8)]]
+  for (i = 0; i < 10; ++i) {  // this is OK
+    a[i] = b[i] = 0;
+  }
+  // expected-error@+1 {{'code_align' attribute only applies to 'for', 
'while', and 'do' statements}}
+  [[clang::code_align(4)]]
+  i = 7;
+  for (i = 0; i < 10; ++i) {
+    a[i] = b[i] = 0;
+  }
+
+  // expected-error@+1{{'code_align' attribute cannot be applied to a 
declaration}}
+  [[clang::code_align(12)]] int n[10];
+}
+
+void bar(int);
+#if __cplusplus >= 201103L
+// cpp-local-note@+2 {{declared here}}
+#endif
+void foo1(int A)
+{
+  // expected-error@+1 {{'code_align' attribute must be a constant power of 
two between 1 and 4096 inclusive}}
+  [[clang::code_align(0)]]
+  for(int I=0; I<128; ++I) { bar(I); }
+
+  // expected-error@+1{{'code_align' attribute must be a constant power of two 
between 1 and 4096 inclusive}}
+  [[clang::code_align(-4)]]
+  for(int I=0; I<128; ++I) { bar(I); }
+
+#if __cplusplus >= 201103L
+    // cpp-local-error@+4 {{integral constant expression must have integral or 
unscoped enumeration type, not 'double'}}
+#else
+    // c-local-error@+2 {{integer constant expression must have integer type, 
not 'double'}}
+#endif
----------------
smanna12 wrote:

> Rather than use `#if` to surround the comments, it's easier to understand if 
> you use a custom `-verify=` prefix that's specific to C++11 and later.

Thanks @AaronBallman for the suggestion about using custom 'verify'. I have 
updated test 
https://github.com/llvm/llvm-project/pull/70762/commits/4c40ce27e81ae40f05aeabb513881032c04feb92.

constexpr  and template only works with C++, so i have used '#if __cplusplus' 
to surround the C++ source codes otherwise it causes errors like "use of 
undeclared identifier 'constexpr" and "unknown type name 'template" with C flag 
in RUN line. 

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

Reply via email to