-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[Clang] Allow parsing arbitrary order of attributes for declarations #133107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
c46eda6
517ba9e
2b06658
04415ee
7388c93
4d0a4f0
e517ff6
ebd962d
453f5b2
c5bc577
5c8ec3c
a693469
0223b3e
121b800
d0df126
4922d9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ int templateFunction(T value) __attribute__((annotate("works"))); | |
|
||
// CHECK: ClassDecl=Test:3:7 (Definition) Extent=[3:1 - 17:2] | ||
// CHECK-NEXT: CXXAccessSpecifier=:4:1 (Definition) Extent=[4:1 - 4:8] | ||
// CHECK-NEXT: CXXMethod=aMethod:5:51 Extent=[5:3 - 5:60] | ||
// CHECK-NEXT: CXXMethod=aMethod:5:51 Extent=[5:46 - 5:60] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This means we went from pointing to the start of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think we should avoid it somehow? Or just accept it as is? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm on the fence. It's not the worst regression in behavior, but it does make the diagnostic slightly harder for users to reason about. WDYT @erichkeane ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its really quite unfortunate... I think it is at least worth seeing how much work needs to be done to get this 'right', and see if it is worth the effort. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main problem here is to determine 'right' :) Examples:
Is it what expected to be done? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the underlying issue is that we're using in-band information about source ranges that's no longer true. We used to be able to rely on the source range because the order was more strict, but as we've relaxed it, you can now mix declaration and decl specifier attributes in more exotic ways. However, addressing that may be quite involved. So I think we should probably accept this as-is; pointing to the start of the list is better than pointing to the type. |
||
// CHECK-NEXT: attribute(annotate)=spiffy_method Extent=[5:18 - 5:43] | ||
// CHECK-NEXT: CXXAccessSpecifier=:7:1 (Definition) Extent=[7:1 - 7:43] | ||
// CHECK-NEXT: attribute(annotate)=works Extent=[7:23 - 7:40] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Verify that we can parse a simple CUDA file with different attributes order. | ||
// RUN: %clang_cc1 "-triple" "nvptx-nvidia-cuda" -fsyntax-only -verify %s | ||
// expected-no-diagnostics | ||
#include "Inputs/cuda.h" | ||
|
||
struct alignas(16) float4 { | ||
float x, y, z, w; | ||
}; | ||
|
||
__attribute__((device)) float func() { | ||
__shared__ alignas(alignof(float4)) float As[4][4]; // Both combinations | ||
alignas(alignof(float4)) __shared__ float Bs[4][4]; // must be legal | ||
|
||
return As[0][0] + Bs[0][0]; | ||
} |
Uh oh!
There was an error while loading. Please reload this page.