summaryrefslogtreecommitdiffstats
path: root/clang/test/FixIt/fixit-cxx11-attributes.cpp
diff options
context:
space:
mode:
authorMichael Han <fragmentshaders@gmail.com>2013-01-07 16:57:11 +0000
committerMichael Han <fragmentshaders@gmail.com>2013-01-07 16:57:11 +0000
commit309af291ef228f33be38fb7660d471e273945155 (patch)
treea30009295c011f548022605824b4dd79c9caa69a /clang/test/FixIt/fixit-cxx11-attributes.cpp
parente68cf2722501e2a49ac039e36db93edf27b6cb40 (diff)
downloadbcm5719-llvm-309af291ef228f33be38fb7660d471e273945155.tar.gz
bcm5719-llvm-309af291ef228f33be38fb7660d471e273945155.zip
Add fixit hints for misplaced C++11 attributes around class specifiers.
Following r168626, in class declaration or definition, there are a combination of syntactic locations where C++11 attributes could appear, and among those the only valid location permitted by standard is between class-key and class-name. So for those attributes appear at wrong locations, fixit is used to move them to expected location and we recover by applying them to the class specifier. llvm-svn: 171757
Diffstat (limited to 'clang/test/FixIt/fixit-cxx11-attributes.cpp')
-rw-r--r--clang/test/FixIt/fixit-cxx11-attributes.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/clang/test/FixIt/fixit-cxx11-attributes.cpp b/clang/test/FixIt/fixit-cxx11-attributes.cpp
new file mode 100644
index 00000000000..7c8efcb8ec7
--- /dev/null
+++ b/clang/test/FixIt/fixit-cxx11-attributes.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -x c++ -std=c++11 -fixit %t
+// RUN: %clang_cc1 -Wall -pedantic -x c++ -std=c++11 %t
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+namespace ClassSpecifier {
+ class [[]] [[]]
+ attr_after_class_name_decl [[]] [[]]; // expected-error {{an attribute list cannot appear here}}
+ // CHECK: fix-it:{{.*}}:{9:5-9:5}
+ // CHECK: fix-it:{{.*}}:{9:32-9:41}
+
+ class [[]] [[]]
+ attr_after_class_name_definition [[]] [[]] [[]]{}; // expected-error {{an attribute list cannot appear here}}
+ // CHECK: fix-it:{{.*}}:{14:4-14:4}
+ // CHECK: fix-it:{{.*}}:{14:37-14:51}
+
+ class base {};
+ class [[]] [[]] final_class
+ alignas(float) [[]] final // expected-error {{an attribute list cannot appear here}}
+ alignas(float) [[]] [[]] alignas(float): base{}; // expected-error {{an attribute list cannot appear here}}
+ // CHECK: fix-it:{{.*}}:{19:19-19:19}
+ // CHECK: fix-it:{{.*}}:{20:5-20:25}
+ // CHECK: fix-it:{{.*}}:{19:19-19:19}
+ // CHECK: fix-it:{{.*}}:{21:5-21:44}
+
+ class [[]] [[]] final_class_another
+ [[]] [[]] alignas(16) final // expected-error {{an attribute list cannot appear here}}
+ [[]] [[]] alignas(16) [[]]{}; // expected-error {{an attribute list cannot appear here}}
+ // CHECK: fix-it:{{.*}}:{27:19-27:19}
+ // CHECK: fix-it:{{.*}}:{28:5-28:27}
+ // CHECK: fix-it:{{.*}}:{27:19-27:19}
+ // CHECK: fix-it:{{.*}}:{29:5-29:31}
+}
OpenPOWER on IntegriCloud