forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
clang:codegenclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerquality-of-implementation
Description
https://godbolt.org/z/4MGx14osY
struct S {
constexpr bool operator==(int) const { return false; }
};
template<class T> int f() {
while (T() == 0) [[likely]] {
return 0;
}
}
template int f<S>();
template int f<int>();
Clang correctly diagnoses one warning for f<S>
and one warning for f<int>
:
<source>:9:1: warning: non-void function does not return a value [-Wreturn-type]
9 | }
| ^
<source>:11:14: note: in instantiation of function template specialization 'f<S>' requested here
11 | template int f<S>();
| ^
<source>:6:24: warning: attribute 'likely' has no effect when annotating an infinite loop [-Wignored-attributes]
6 | while (T() == 0) [[likely]] {
| ^~~~~~
<source>:6:5: note: annotating the infinite loop here
6 | while (T() == 0) [[likely]] {
| ^~~~~~~~~~~~~~~~
2 warnings generated.
The -Wreturn-type
warning (produced by Sema) helpfully includes a note pointing the user at f<S>
.
The -Wignored-attributes
warning (produced by CodeGen) unhelpfully doesn't include any note pointing the user at f<int>
.
Presumably that information is difficult to come by, in CodeGen, but it sure would be useful.
Metadata
Metadata
Assignees
Labels
clang:codegenclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerquality-of-implementation