aboutsummaryrefslogtreecommitdiff
path: root/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
commit07fc1ba7553f2f5bf26984091197311decd9028e (patch)
treef68851c0a290f161d2c0c9054da9763dbb9dc703 /test/FixIt/fixit-cxx11-attributes.cpp
parent589dae7d52043af6085967fae0c31d32365de229 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171757 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/FixIt/fixit-cxx11-attributes.cpp')
-rw-r--r--test/FixIt/fixit-cxx11-attributes.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/FixIt/fixit-cxx11-attributes.cpp b/test/FixIt/fixit-cxx11-attributes.cpp
new file mode 100644
index 0000000000..7c8efcb8ec
--- /dev/null
+++ b/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}
+}