forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Emit a diagnostic warning about parsing ambiguity in a conjunction #55
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
378e907
feat: first version of implementation
BaLiKfromUA 53c7d38
test: add basic test for parsing
BaLiKfromUA 98b0a59
minor refactoring
BaLiKfromUA 32c3567
fix: add suppressing of introduced warning
BaLiKfromUA 99e6528
feat: add warning for parsing of '&' token in reflection expr
BaLiKfromUA 44b62f0
style: revert some changes
BaLiKfromUA a13d5e8
style: remove tabs
BaLiKfromUA 6772510
style: remove tabs
BaLiKfromUA 7be17b0
refactor: improve wording in warning
BaLiKfromUA bfdfdd6
refactor: replace hardcoded lines in tests
BaLiKfromUA a736536
fix: false positive warning during parsing rvalue of type `meta::info`
BaLiKfromUA 3554cdb
refactor: rename and move test to Reflection folder
BaLiKfromUA af2a8c1
refactor: change wording in warning
BaLiKfromUA 5bb406e
fix typo
BaLiKfromUA a2aead4
test: add more test cases
BaLiKfromUA 07bba7b
test: add more test cases
BaLiKfromUA File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Copyright 2024 Bloomberg Finance L.P. | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// RUN: %clang_cc1 -std=c++26 -freflection -Wno-parentheses -verify %s | ||
|
||
|
||
enum MyEnum { x, y, e = -1, f, z = 99 }; | ||
|
||
void func(MyEnum && x) { // ok | ||
MyEnum value{}; | ||
MyEnum& ref = value; | ||
|
||
constexpr auto reflValue = ^value; | ||
|
||
constexpr bool test_comparison_0 = reflValue != (^MyEnum) && true; // ok | ||
constexpr bool test_comparison_1 = (reflValue != (^MyEnum) && true); // ok | ||
|
||
constexpr bool test_comparison_2 = ^MyEnum != (^MyEnum) && true; // ok | ||
constexpr bool test_comparison_3 = (^MyEnum != (^MyEnum) && true); // ok | ||
|
||
constexpr bool test_comparison_4 = (reflValue != (^MyEnum) & true); // ok | ||
|
||
constexpr bool test_comparison_5 = reflValue != ^MyEnum && true; | ||
// expected-warning@-1 {{token '&&' binds left to type 'T &&'; did you mean '(^T) &&'?}} | ||
// expected-error@-2 {{expected ';' at end of declaration}} | ||
constexpr bool test_comparison_6 = reflValue != ^MyEnum & true; | ||
// expected-warning@-1 {{token '&' binds left to type 'T &'; did you mean '(^T) &'?}} | ||
// expected-error@-2 {{expected ';' at end of declaration}} | ||
|
||
constexpr bool test_comparison_7 = ^MyEnum& == reflValue; // ok | ||
constexpr bool test_comparison_8 = ^MyEnum& != reflValue; // ok | ||
|
||
constexpr bool test_comparison_9 = ^MyEnum& < reflValue; | ||
// expected-error@-1 {{invalid operands to binary expression ('meta::info' and 'const meta::info')}} | ||
constexpr bool test_comparison_10 = ^MyEnum& > reflValue; | ||
// expected-error@-1 {{invalid operands to binary expression ('meta::info' and 'const meta::info')}} | ||
constexpr bool test_comparison_11 = ^MyEnum& <= reflValue; | ||
// expected-error@-1 {{invalid operands to binary expression ('meta::info' and 'const meta::info')}} | ||
constexpr bool test_comparison_12 = ^MyEnum& >= reflValue; | ||
// expected-error@-1 {{invalid operands to binary expression ('meta::info' and 'const meta::info')}} | ||
|
||
constexpr auto test_comparison_13 = reflValue != ^MyEnum&& || true; // ok | ||
constexpr auto test_comparison_14 = reflValue != ^MyEnum& | true; // ok | ||
|
||
constexpr auto test_comparison_15 = reflValue != ^MyEnum&; // ok | ||
constexpr auto test_comparison_16 = reflValue == ^MyEnum&; // ok | ||
|
||
constexpr auto test_ref_type_0 = ^MyEnum &; // ok | ||
constexpr auto test_ref_type_1 = ^MyEnum &&; // ok | ||
constexpr auto test_ref_type_2 = (^MyEnum &); // ok | ||
constexpr auto test_ref_type_3 = (^MyEnum &&); // ok | ||
|
||
constexpr auto ternary_comparison_test_0 = reflValue == ^MyEnum& ? 1 : 0; // ok | ||
constexpr auto ternary_comparison_test_1 = (2 > 0) ? ^MyEnum& : ^MyEnum; // ok | ||
constexpr auto ternary_comparison_test_2 = (2 > 0) ? ^MyEnum : ^MyEnum&; // ok | ||
|
||
constexpr auto test_init_0 {^MyEnum&}; // ok | ||
constexpr auto test_type_id_0 = ^MyEnum&(*)(bool); // ok | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, there are a lot more cases here. I'm not sure this approach will work (although it might - not really sure one way or the other).
In addition to those, in the presence of some user-defined
You could have
^int& + o
, along with:-
,*
,/
,%
,]
,|
,||
<=
,>=
,>
.Those are all the cases I can think of off the top of my head, but I may have forgotten some.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you! gonna think more how to address it