Skip to content

Commit c46eda6

Browse files
committed
[CLANG] Enable alignas after GNU attributes
1 parent 1cc07a0 commit c46eda6

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

clang/lib/Parse/ParseStmt.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@ StmtResult Parser::ParseStatementOrDeclarationAfterAttributes(
296296
goto Retry;
297297
}
298298

299+
case tok::kw_alignas: {
300+
ParseAlignmentSpecifier(CXX11Attrs);
301+
goto Retry;
302+
}
303+
299304
case tok::kw_template: {
300305
SourceLocation DeclEnd;
301306
ParseTemplateDeclarationOrSpecialization(DeclaratorContext::Block, DeclEnd,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Verify that we can parse a simple CUDA file with different attributes order.
2+
// RUN: %clang_cc1 "-triple" "nvptx-nvidia-cuda" -fsyntax-only -verify %s
3+
// expected-no-diagnostics
4+
#include "Inputs/cuda.h"
5+
6+
struct alignas(16) float4 {
7+
float x, y, z, w;
8+
};
9+
10+
__attribute__((device)) float func() {
11+
__shared__ alignas(alignof(float4)) float As[4][4]; // Both combinations
12+
alignas(alignof(float4)) __shared__ float Bs[4][4]; // must be legal
13+
14+
return As[0][0] + Bs[0][0];
15+
}

0 commit comments

Comments
 (0)