diff options
author | Michael Han <fragmentshaders@gmail.com> | 2013-01-24 16:46:58 +0000 |
---|---|---|
committer | Michael Han <fragmentshaders@gmail.com> | 2013-01-24 16:46:58 +0000 |
commit | 99315932997a23aa5132d041b8a241d9ec0e8745 (patch) | |
tree | c3a639009c749aa16d546db5cb65d8d41379bd48 /clang/test/SemaCXX/cxx11-attr-print.cpp | |
parent | 1c4e323fdd043402524a85985e068b355eecfad2 (diff) | |
download | bcm5719-llvm-99315932997a23aa5132d041b8a241d9ec0e8745.tar.gz bcm5719-llvm-99315932997a23aa5132d041b8a241d9ec0e8745.zip |
PR14922: when printing an attribute, use the real syntax of the attribute (GNU, C++11, MS Declspec) instead of hardcoded GNU syntax.
Introduce a spelling index to Attr class, which is an index into the attribute spelling list of an attribute defined in Attr.td.
This index will determine the actual spelling used by an attribute, as it incorporates both the syntax and naming of the attribute.
When constructing an attribute AST node, the spelling index is computed based on attribute kind, scope (if it's a C++11 attribute), and
name, then passed to Attr that will use the index to print itself.
Thanks to Richard Smith for the idea and review.
llvm-svn: 173358
Diffstat (limited to 'clang/test/SemaCXX/cxx11-attr-print.cpp')
-rw-r--r-- | clang/test/SemaCXX/cxx11-attr-print.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/cxx11-attr-print.cpp b/clang/test/SemaCXX/cxx11-attr-print.cpp new file mode 100644 index 00000000000..985d9a44fef --- /dev/null +++ b/clang/test/SemaCXX/cxx11-attr-print.cpp @@ -0,0 +1,50 @@ +// RUN: %clang_cc1 -std=c++11 -ast-print %s | FileCheck %s +// FIXME: align attribute print + +// CHECK: int x __attribute__((aligned(4, 0))); +int x __attribute__((aligned(4))); + +// CHECK: int y __attribute__((align(4, 0))); +int y __attribute__((align(4))); + +// CHECK: gnu::aligned(4, 0)]]; +int z [[gnu::aligned(4)]]; + +// CHECK: __attribute__((deprecated("warning"))); +int a __attribute__((deprecated("warning"))); + +// CHECK: gnu::deprecated("warning")]]; +int b [[gnu::deprecated("warning")]]; + +// CHECK: void foo() __attribute__((const)); +void foo() __attribute__((const)); + +// CHECK: void bar() __attribute__((__const)); +void bar() __attribute__((__const)); + +// CHECK: int f1() __attribute__((warn_unused_result)); +int f1() __attribute__((warn_unused_result)); + +// CHECK: clang::warn_unused_result]]; +int f2 [[clang::warn_unused_result]] (); + +// CHECK: gnu::warn_unused_result]]; +int f3 [[gnu::warn_unused_result]] (); + +// FIXME: ast-print need to print C++11 +// attribute after function declare-id. +// CHECK: noreturn]]; +void f4 [[noreturn]] (); + +// CHECK: std::noreturn]]; +void f5 [[std::noreturn]] (); + +// CHECK: __attribute__((gnu_inline)); +inline void f6() __attribute__((gnu_inline)); + +// CHECK: gnu::gnu_inline]]; +inline void f7 [[gnu::gnu_inline]] (); + +// arguments printing +// CHECK: __attribute__((format("printf", 2, 3))); +void f8 (void *, const char *, ...) __attribute__ ((format (printf, 2, 3))); |