Skip to content

Commit e517ff6

Browse files
committed
[CLANG] Added more tests, removed range assert
1 parent 4d0a4f0 commit e517ff6

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

clang/lib/Parse/ParseStmt.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,11 @@ StmtResult Parser::ParseStatementOrDeclarationAfterAttributes(
263263
GNUAttrs);
264264
}
265265
if (CXX11Attrs.Range.getBegin().isValid()) {
266-
// The caller must guarantee that the CXX11Attrs appear before the
267-
// GNUAttrs, and we rely on that here.
268-
assert(GNUAttrs.Range.getBegin().isInvalid() ||
269-
GNUAttrs.Range.getBegin() > CXX11Attrs.Range.getBegin());
270-
DeclStart = CXX11Attrs.Range.getBegin();
266+
// Order of C++11 and GNU attributes is may be arbitrary.
267+
DeclStart = GNUAttrs.Range.getBegin().isInvalid()
268+
? CXX11Attrs.Range.getBegin()
269+
: std::min(CXX11Attrs.Range.getBegin(),
270+
GNUAttrs.Range.getBegin());
271271
} else if (GNUAttrs.Range.getBegin().isValid())
272272
DeclStart = GNUAttrs.Range.getBegin();
273273
return Actions.ActOnDeclStmt(Decl, DeclStart, DeclEnd);

clang/test/Parser/cxx0x-attributes.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,30 @@ namespace test_misplacement {
7272
[[]] enum E2 { }; //expected-error{{misplaced attributes}}
7373
}
7474

75-
__attribute__(()) [[]] alignas(int) int xx; // expected-none
75+
__attribute__(()) alignas(int) int xx; // expected-none
7676
__attribute__(()) alignas(int) [[]] int yy; // expected-none
7777
[[]] __attribute__(()) alignas(int) int zz; // expected-none
7878
alignas(int) [[]] __attribute__(()) int aa; // expected-none
79+
[[]] alignas(int) __attribute__(()) int bb; // expected-none
80+
__attribute__(()) [[]] alignas(int) int cc; // expected-none
7981

8082
class C1 {
81-
__attribute__(()) [[]] alignas(int) int x; // expected-none
83+
__attribute__(()) alignas(int) int x; // expected-none
8284
__attribute__(()) alignas(int) [[]] int y; // expected-none
8385
[[]] __attribute__(()) alignas(int) int z; // expected-none
8486
alignas(int) [[]] __attribute__(()) int a; // expected-none
87+
[[]] alignas(int) __attribute__(()) int b; // expected-none
88+
__attribute__(()) [[]] alignas(int) int c; // expected-none
8589
};
8690

8791
void fn_with_decl() {
8892
__attribute__(()) alignas(int) int x; // expected-none
8993
__attribute__(()) alignas(int) [[]] int y; // expected-none
9094
[[]] __attribute__(()) alignas(int) int z; // expected-none
9195
alignas(int) [[]] __attribute__(()) int a; // expected-none
96+
[[]] alignas(int) __attribute__(()) int b; // expected-none
97+
__attribute__(()) [[]] alignas(int) int c; // expected-none
9298
}
93-
9499
// Checks attributes placed at wrong syntactic locations of class specifiers.
95100
class [[]] [[]]
96101
attr_after_class_name_decl [[]] [[]]; // expected-error {{an attribute list cannot appear here}}

0 commit comments

Comments
 (0)