https://github.com/AmrDeveloper created 
https://github.com/llvm/llvm-project/pull/123806

Follow up for improving the test after 
https://github.com/llvm/llvm-project/pull/123417

>From 38031e9aed519f4fd3b21dff7e79c69a0150efd9 Mon Sep 17 00:00:00 2001
From: AmrDeveloper <am...@programmer.net>
Date: Tue, 21 Jan 2025 20:11:21 +0100
Subject: [PATCH] [Clang] Improve testing of non std functions with name
 infinity

---
 .../test/Sema/warn-infinity-nan-disabled-lnx.cpp  | 15 ++++++++++++---
 .../test/Sema/warn-infinity-nan-disabled-win.cpp  | 15 ++++++++++++---
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/clang/test/Sema/warn-infinity-nan-disabled-lnx.cpp 
b/clang/test/Sema/warn-infinity-nan-disabled-lnx.cpp
index 4f46b777c88742..b80d6997c71da6 100644
--- a/clang/test/Sema/warn-infinity-nan-disabled-lnx.cpp
+++ b/clang/test/Sema/warn-infinity-nan-disabled-lnx.cpp
@@ -65,7 +65,7 @@ class numeric_limits {
         return _Ty();
     }
 };
-} // namespace )
+} // namespace std
 }
 
 #define NAN (__builtin_nanf(""))
@@ -87,6 +87,7 @@ class std::numeric_limits<double>  {
     }
 };
 
+namespace nonstd {
 template <class _Ty>
 class numeric_limits {
 public:
@@ -110,6 +111,7 @@ class numeric_limits<double>  {
         return __builtin_huge_val();
     }
 };
+} // namespace nonstd
 
 double infinity() { return 0; }
 
@@ -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;
 
 }
diff --git a/clang/test/Sema/warn-infinity-nan-disabled-win.cpp 
b/clang/test/Sema/warn-infinity-nan-disabled-win.cpp
index 655024f5909b33..e845fa646fccef 100644
--- a/clang/test/Sema/warn-infinity-nan-disabled-win.cpp
+++ b/clang/test/Sema/warn-infinity-nan-disabled-win.cpp
@@ -69,7 +69,7 @@ class numeric_limits {
     }
 };
 
-} // namespace )
+} // namespace std
 }
 
 #define INFINITY ((float)(1e+300 * 1e+300))
@@ -91,6 +91,7 @@ class std::numeric_limits<double>  {
     }
 };
 
+namespace nonstd {
 template <class _Ty>
 class numeric_limits {
 public:
@@ -115,6 +116,8 @@ class numeric_limits<double>  {
     }
 };
 
+} // namespace nonstd
+
 double infinity() { return 0; }
 
 int compareit(float a, float b) {
@@ -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;
 
 }

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to