[PATCH] Disallowing just GNU-style attributes in certain positions
Aaron Ballman
aaron at aaronballman.com
Thu Jul 17 11:36:05 PDT 2014
GNU-style type attributes are not allowed in new expressions, such as:
auto *P = new int * __attribute__((attr));
We silently accept them in clang, but have a FIXME in the code to
address the issue. This patch is an initial stab at addressing the
issue, and I am looking for feedback on whether my approach is
reasonable or not. (It disables support for GNU attributes, but not
other vendor attributes which should remain supported.)
Note, the attached test case does not currently pass. It only checks
for one error diagnostic, but the actual diagnostics for that code
are:
..\llvm\tools\clang\test\SemaCXX\attr-gnu.cpp:4:22: error: an
attribute list cannot appear here
auto P = new int * __attribute__((vector_size(8))); // expected-error ...
^
..\llvm\tools\clang\test\SemaCXX\attr-gnu.cpp:4:21: error: expected
';' at end of declaration
auto P = new int * __attribute__((vector_size(8))); // expected-error ...
^
;
..\llvm\tools\clang\test\SemaCXX\attr-gnu.cpp:4:22: warning:
declaration does not declare anything [-Wmissing-declarations]
auto P = new int * __attribute__((vector_size(8))); // expected-error ...
^~~~~~~~~~~~~
1 warning and 2 errors generated.
The first diagnostic is obviously correct, but are the other two
reasonable diagnostics as well?
If the approach is reasonable, I'll clean the patch up, add more test
cases, etc. I mostly wanted to check my direction first. Thanks!
~Aaron
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TypeAttr.patch
Type: application/octet-stream
Size: 6388 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140717/0f5d12d4/attachment.obj>
More information about the cfe-commits
mailing list