Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions clang/test/Sema/warn-infinity-nan-disabled-lnx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class numeric_limits {
return _Ty();
}
};
} // namespace )
} // namespace std
}

#define NAN (__builtin_nanf(""))
Expand All @@ -87,6 +87,7 @@ class std::numeric_limits<double> {
}
};

namespace nonstd {
template <class _Ty>
class numeric_limits {
public:
Expand All @@ -110,6 +111,7 @@ class numeric_limits<double> {
return __builtin_huge_val();
}
};
} // namespace nonstd

double infinity() { return 0; }

Expand Down Expand Up @@ -254,16 +256,23 @@ int compareit(float a, float b) {
// no-inf-warning@+1 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
double y = i * std::numeric_limits<double>::infinity();

y = i * numeric_limits<double>::infinity(); // expected-no-diagnostics
y = i * nonstd::numeric_limits<double>::infinity(); // expected-no-diagnostics

// no-inf-no-nan-warning@+2 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
// no-inf-warning@+1 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
j = std::numeric_limits<float>::infinity();

j = numeric_limits<float>::infinity(); // expected-no-diagnostics
j = nonstd::numeric_limits<float>::infinity(); // expected-no-diagnostics

y = infinity(); // expected-no-diagnostics

{
using namespace std;
// no-inf-no-nan-warning@+2 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
// no-inf-warning@+1 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
double d = numeric_limits<double>::infinity();
}

return 0;

}
15 changes: 12 additions & 3 deletions clang/test/Sema/warn-infinity-nan-disabled-win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class numeric_limits {
}
};

} // namespace )
} // namespace std
}

#define INFINITY ((float)(1e+300 * 1e+300))
Expand All @@ -91,6 +91,7 @@ class std::numeric_limits<double> {
}
};

namespace nonstd {
template <class _Ty>
class numeric_limits {
public:
Expand All @@ -115,6 +116,8 @@ class numeric_limits<double> {
}
};

} // namespace nonstd

double infinity() { return 0; }

int compareit(float a, float b) {
Expand Down Expand Up @@ -246,16 +249,22 @@ int compareit(float a, float b) {
// no-inf-warning@+1 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
double y = i * std::numeric_limits<double>::infinity();

y = i * numeric_limits<double>::infinity(); // expected-no-diagnostics
y = i * nonstd::numeric_limits<double>::infinity(); // expected-no-diagnostics

// no-inf-no-nan-warning@+2 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
// no-inf-warning@+1 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
j = std::numeric_limits<float>::infinity();

j = numeric_limits<float>::infinity(); // expected-no-diagnostics
j = nonstd::numeric_limits<float>::infinity(); // expected-no-diagnostics

y = infinity(); // expected-no-diagnostics

{
using namespace std;
// no-inf-no-nan-warning@+2 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
// no-inf-warning@+1 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
double d = numeric_limits<double>::infinity();
}
return 0;

}
Loading