Repository navigation
In C++ mode do not warn about inline combined with noinline [GH #183]
#251
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
Merged
Merged
Changes from all commits
Commits
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,20 @@ | ||
| //allowed_words: NOINLINE | ||
| [GH #183] | ||
| GNU compatibility: "inline" combined with "noinline" on a definition | ||
|
|
||
| In GNU and Clang C++ modes, the front end warned that a routine is both | ||
| "inline" and "noinline" when a function definition was declared "inline" and | ||
| had the GNU "noinline" attribute, but GCC accepts that combination silently | ||
| (it is used, e.g., by Boost through "BOOST_NOINLINE inline"). For example: | ||
|
|
||
| inline __attribute__((noinline)) int f(int x) { // No warning now. | ||
| return x; | ||
| } | ||
|
|
||
| In C modes, where GCC and Clang warn about the combination in all of those | ||
| cases, the behavior is unchanged. | ||
|
|
||
| Also, instantiating a function template (or a member function of a class | ||
| template) that is both "inline" and "noinline" no longer repeats the warning | ||
| "At end of source" for each instance, only the template declarations are | ||
| checked. |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
4 changes: 0 additions & 4 deletions
4
tests/tests/imported/gnu/cpp/gcov/.gcov-10.rto/default.1.1.txt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1 @@ | ||
| eccp -DTEST_NUMBER=1 --gnu_version=999999 -tused -e 200 --no_wrap --no_wrap_diagnostics Test_name.c | ||
| "Test_name.c", line 9: warning: routine is both "inline" and "noinline" | ||
| inline int __attribute__ ((noinline)) Foo () | ||
| ^ | ||
|
|
4 changes: 0 additions & 4 deletions
4
tests/tests/imported/gnu/cpp/ipa/.nothrow-1.rto/default.1.1.txt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1 @@ | ||
| fe_only -DTEST_NUMBER=1 --gnu_version=999999 -tused -e 200 --no_wrap --no_wrap_diagnostics Test_name.c | ||
| "Test_name.c", line 11: warning: routine is both "inline" and "noinline" | ||
| __attribute__ ((noinline)) | ||
| ^ | ||
|
|
4 changes: 0 additions & 4 deletions
4
tests/tests/imported/gnu/cpp/ipa/.pure-const-1.rto/default.1.1.txt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1 @@ | ||
| fe_only -DTEST_NUMBER=1 --gnu_version=999999 -tused -e 200 --no_wrap --no_wrap_diagnostics Test_name.c | ||
| "Test_name.c", line 11: warning: routine is both "inline" and "noinline" | ||
| __attribute__ ((noinline)) | ||
| ^ | ||
|
|
4 changes: 0 additions & 4 deletions
4
tests/tests/imported/gnu/cpp/ipa/.pure-const-2.rto/default.1.1.txt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1 @@ | ||
| fe_only -DTEST_NUMBER=1 --gnu_version=999999 -tused -e 200 --no_wrap --no_wrap_diagnostics Test_name.c | ||
| "Test_name.c", line 10: warning: routine is both "inline" and "noinline" | ||
| __attribute__ ((noinline)) | ||
| ^ | ||
|
|
8 changes: 0 additions & 8 deletions
8
tests/tests/imported/gnu/cpp/ipa/.pure-const-3.rto/default.1.1.txt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,9 +1 @@ | ||
| fe_only -DTEST_NUMBER=1 --gnu_version=999999 -tused -e 200 --no_wrap --no_wrap_diagnostics Test_name.c | ||
| "./ipa/pure-const-3.h", line 7: warning: routine is both "inline" and "noinline" | ||
| __attribute__ ((noinline)) | ||
| ^ | ||
|
|
||
| "./ipa/pure-const-3.h", line 15: warning: routine is both "inline" and "noinline" | ||
| __attribute__ ((noinline)) | ||
| ^ | ||
|
|
8 changes: 0 additions & 8 deletions
8
tests/tests/imported/gnu/cpp/ipa/.pure-const-3b.rto/default.1.1.txt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,9 +1 @@ | ||
| fe_only -DTEST_NUMBER=1 --gnu_version=999999 -tused -e 200 --no_wrap --no_wrap_diagnostics Test_name.c | ||
| "./ipa/pure-const-3.h", line 7: warning: routine is both "inline" and "noinline" | ||
| __attribute__ ((noinline)) | ||
| ^ | ||
|
|
||
| "./ipa/pure-const-3.h", line 15: warning: routine is both "inline" and "noinline" | ||
| __attribute__ ((noinline)) | ||
| ^ | ||
|
|
58 changes: 58 additions & 0 deletions
58
tests/tests/regressions/.gh-183-negative.rto/default.1.1.txt
This file contains hidden or 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,58 @@ | ||
| fe_only -DTEST_NUMBER=1 --gnu_version=150000 --diag_error=inline_gnu_noinline_conflict --c++17 Test_name.c | ||
| "Test_name.c", line 9: error: routine is both "inline" and "noinline" | ||
| inline NOINLINE int f1(int x); // Error: not a definition. | ||
| ^ | ||
|
|
||
| "Test_name.c", line 10: error: routine is both "inline" and "noinline" | ||
| inline int f1(int x) { return x; } // Error: inline after noinline. | ||
| ^ | ||
|
|
||
| "Test_name.c", line 12: error: routine is both "inline" and "noinline" | ||
| inline int f2(int x) NOINLINE; // Error: not a definition. | ||
| ^ | ||
|
|
||
| "Test_name.c", line 15: error: routine is both "inline" and "noinline" | ||
| inline int f3(int x) { return x; } // Error: inline after noinline. | ||
| ^ | ||
|
|
||
| "Test_name.c", line 18: error: routine is both "inline" and "noinline" | ||
| inline NOINLINE int f4(int x) { return x; } // Error: inline after | ||
| ^ | ||
|
|
||
| "Test_name.c", line 22: error: routine is both "inline" and "noinline" | ||
| NOINLINE int f5(int x) { return x; } // Error: noinline after inline. | ||
| ^ | ||
|
|
||
| "Test_name.c", line 25: error: routine is both "inline" and "noinline" | ||
| inline NOINLINE int f6(int x) { return x; } // Error: noinline after | ||
| ^ | ||
|
|
||
| "Test_name.c", line 29: error: routine is both "inline" and "noinline" | ||
| constexpr NOINLINE int f7(int x) { return x; } // Error: noinline after | ||
| ^ | ||
|
|
||
| "Test_name.c", line 38: error: routine is both "inline" and "noinline" | ||
| inline NOINLINE int A::m1(int x) { return x; } // Error. | ||
| ^ | ||
|
|
||
| "Test_name.c", line 39: error: routine is both "inline" and "noinline" | ||
| inline NOINLINE int A::m2(int x) { return x; } // Error (only once). | ||
| ^ | ||
|
|
||
| "Test_name.c", line 40: error: routine is both "inline" and "noinline" | ||
| inline NOINLINE int A::m3(int x) { return x; } // Error. | ||
| ^ | ||
|
|
||
| "Test_name.c", line 41: error: routine is both "inline" and "noinline" | ||
| template <class T> inline NOINLINE T A::m4(T x) { return x; } // Error. | ||
| ^ | ||
|
|
||
| "Test_name.c", line 47: error: routine is both "inline" and "noinline" | ||
| template <class T> inline T B<T>::m1(T x) { return x; } // Error. | ||
| ^ | ||
|
|
||
| "Test_name.c", line 48: error: routine is both "inline" and "noinline" | ||
| template <class T> NOINLINE T B<T>::m2(T x) { return x; } // Error. | ||
| ^ | ||
|
|
||
| 14 errors detected in the compilation of "Test_name.c". |
This file contains hidden or 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 @@ | ||
| fe_only -DTEST_NUMBER=1 --gnu_version=150000 --diag_error=inline_gnu_noinline_conflict --c++17 Test_name.c |
This file contains hidden or 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 @@ | ||
| fe_only -DTEST_NUMBER=1 --gnu_version=150000 --diag_error=inline_gnu_noinline_conflict --c++17 Test_name.c |
This file contains hidden or 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,55 @@ | ||
| //type:fn | ||
| //options_all:--gnu_version=150000 --diag_error=inline_gnu_noinline_conflict | ||
| //options:--c++17 | ||
| // Cases in which GCC still diagnoses "inline" combined with "noinline" in C++ | ||
| // (see gh-183.sft.cpp for the cases in which it does not): declarations that | ||
| // are not definitions, and redeclarations that add one to the other. | ||
| #define NOINLINE __attribute__((__noinline__)) | ||
|
|
||
| inline NOINLINE int f1(int x); // Error: not a definition. | ||
| inline int f1(int x) { return x; } // Error: inline after noinline. | ||
|
|
||
| inline int f2(int x) NOINLINE; // Error: not a definition. | ||
|
|
||
| NOINLINE int f3(int x); | ||
| inline int f3(int x) { return x; } // Error: inline after noinline. | ||
|
|
||
| NOINLINE int f4(int x); | ||
| inline NOINLINE int f4(int x) { return x; } // Error: inline after | ||
| // noinline (only once). | ||
|
|
||
| inline int f5(int x); | ||
| NOINLINE int f5(int x) { return x; } // Error: noinline after inline. | ||
|
|
||
| inline int f6(int x); | ||
| inline NOINLINE int f6(int x) { return x; } // Error: noinline after | ||
| // inline. | ||
|
|
||
| constexpr int f7(int x); | ||
| constexpr NOINLINE int f7(int x) { return x; } // Error: noinline after | ||
| // inline. | ||
|
|
||
| struct A { | ||
| inline NOINLINE int m1(int x); // No error in the class. | ||
| NOINLINE int m2(int x); | ||
| inline int m3(int x); | ||
| template <class T> inline T m4(T x); | ||
| }; | ||
| inline NOINLINE int A::m1(int x) { return x; } // Error. | ||
| inline NOINLINE int A::m2(int x) { return x; } // Error (only once). | ||
| inline NOINLINE int A::m3(int x) { return x; } // Error. | ||
| template <class T> inline NOINLINE T A::m4(T x) { return x; } // Error. | ||
|
|
||
| template <class T> struct B { | ||
| NOINLINE T m1(T x); | ||
| inline T m2(T x); | ||
| }; | ||
| template <class T> inline T B<T>::m1(T x) { return x; } // Error. | ||
| template <class T> NOINLINE T B<T>::m2(T x) { return x; } // Error. | ||
|
|
||
| int g() { | ||
| A a; | ||
| B<int> b; // Instantiating B<int>::m1 and m2 adds no further errors. | ||
| return f1(1) + f3(1) + f4(1) + f5(1) + f6(1) + f7(1) + a.m1(1) + a.m2(1) + | ||
| a.m3(1) + a.m4(1) + b.m1(1) + b.m2(1); | ||
| } |
This file contains hidden or 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,22 @@ | ||
| //type:fp | ||
| //options_all:--gnu_version=150000 --diag_error=inline_gnu_noinline_conflict | ||
| //options:--c++17 | ||
| //require:BACK_END_IS_CP_GEN_BE 0 | ||
| // Like gh-183.sft.cpp: GCC does not diagnose an "inline" definition with the | ||
| // "noinline" attribute that follows a declaration without "inline". (The | ||
| // C++-generating back end puts out the earlier declaration with "inline", so | ||
| // its generated code would legitimately be diagnosed; hence the requirement.) | ||
| #define NOINLINE __attribute__((__noinline__)) | ||
|
|
||
| int f(int x); | ||
| inline NOINLINE int f(int x) { return x; } | ||
|
|
||
| struct A { | ||
| int m(int x); | ||
| }; | ||
| inline NOINLINE int A::m(int x) { return x; } | ||
|
|
||
| int g() { | ||
| A a; | ||
| return f(1) + a.m(1); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.