[PATCH] D153590: Don't use float_t and double_t with #pragma clang fp eval_method.

2023-06-26 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

In D153590#4446358 , @mgorny wrote:

> This change causes test regressions on 32-bit x86:
>
>   FAIL: Clang :: Sema/fp-eval-pragma-with-float-double_t-3.c (14665 of 17845)
>    TEST 'Clang :: 
> Sema/fp-eval-pragma-with-float-double_t-3.c' FAILED 
>   Script:
>   --
>   : 'RUN: at line 1';   
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/clang
>  -cc1 -internal-isystem 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/17/include
>  -nostdsysteminc -verify -fsyntax-only -verify -DNOERROR 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
>   : 'RUN: at line 2';   
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/clang
>  -cc1 -internal-isystem 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/17/include
>  -nostdsysteminc -verify -fsyntax-only -x c++ -DCPP -DNOERROR 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
>   : 'RUN: at line 4';   
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/clang
>  -cc1 -internal-isystem 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/17/include
>  -nostdsysteminc -verify -fsyntax-only -ffp-eval-method=extended -DNOERROR 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
>   : 'RUN: at line 5';   
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/clang
>  -cc1 -internal-isystem 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/17/include
>  -nostdsysteminc -verify -fsyntax-only -x c++ -DCPP  
> -ffp-eval-method=extended -DNOERROR 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
>   : 'RUN: at line 8';   
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/clang
>  -cc1 -internal-isystem 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/17/include
>  -nostdsysteminc -verify -fsyntax-only -ffp-eval-method=source 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
>   : 'RUN: at line 9';   
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/clang
>  -cc1 -internal-isystem 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/17/include
>  -nostdsysteminc -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=source 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
>   : 'RUN: at line 11';   
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/clang
>  -cc1 -internal-isystem 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/17/include
>  -nostdsysteminc -verify -fsyntax-only -ffp-eval-method=double 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
>   : 'RUN: at line 12';   
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/clang
>  -cc1 -internal-isystem 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/17/include
>  -nostdsysteminc -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=double 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
>   --
>   Exit Code: 1
>   
>   Command Output (stderr):
>   --
>   + : 'RUN: at line 1'
>   + 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/clang
>  -cc1 -internal-isystem 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/17/include
>  -nostdsysteminc -verify -fsyntax-only -verify -DNOERROR 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
>   error: 'warning' diagnostics seen but not expected: 
> File 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
>  Line 36: Setting the floating point evaluation method to `source` on a 
> target without SSE is not supported.
> File 
> /var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
>  Line 43: Setting the floating 

[PATCH] D153590: Don't use float_t and double_t with #pragma clang fp eval_method.

2023-06-24 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

This change causes test regressions on 32-bit x86:

  FAIL: Clang :: Sema/fp-eval-pragma-with-float-double_t-3.c (14665 of 17845)
   TEST 'Clang :: 
Sema/fp-eval-pragma-with-float-double_t-3.c' FAILED 
  Script:
  --
  : 'RUN: at line 1';   
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/clang
 -cc1 -internal-isystem 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/17/include
 -nostdsysteminc -verify -fsyntax-only -verify -DNOERROR 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
  : 'RUN: at line 2';   
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/clang
 -cc1 -internal-isystem 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/17/include
 -nostdsysteminc -verify -fsyntax-only -x c++ -DCPP -DNOERROR 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
  : 'RUN: at line 4';   
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/clang
 -cc1 -internal-isystem 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/17/include
 -nostdsysteminc -verify -fsyntax-only -ffp-eval-method=extended -DNOERROR 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
  : 'RUN: at line 5';   
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/clang
 -cc1 -internal-isystem 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/17/include
 -nostdsysteminc -verify -fsyntax-only -x c++ -DCPP  -ffp-eval-method=extended 
-DNOERROR 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
  : 'RUN: at line 8';   
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/clang
 -cc1 -internal-isystem 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/17/include
 -nostdsysteminc -verify -fsyntax-only -ffp-eval-method=source 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
  : 'RUN: at line 9';   
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/clang
 -cc1 -internal-isystem 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/17/include
 -nostdsysteminc -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=source 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
  : 'RUN: at line 11';   
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/clang
 -cc1 -internal-isystem 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/17/include
 -nostdsysteminc -verify -fsyntax-only -ffp-eval-method=double 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
  : 'RUN: at line 12';   
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/clang
 -cc1 -internal-isystem 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/17/include
 -nostdsysteminc -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=double 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  + : 'RUN: at line 1'
  + 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/clang
 -cc1 -internal-isystem 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/17/include
 -nostdsysteminc -verify -fsyntax-only -verify -DNOERROR 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
  error: 'warning' diagnostics seen but not expected: 
File 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
 Line 36: Setting the floating point evaluation method to `source` on a target 
without SSE is not supported.
File 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
 Line 43: Setting the floating point evaluation method to `source` on a target 
without SSE is not supported.
File 
/var/tmp/portage/sys-devel/clang-17.0.0_pre20230624/work/clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
 Line 50: Setting the floating 

[PATCH] D153590: Don't use float_t and double_t with #pragma clang fp eval_method.

2023-06-23 Thread Zahira Ammarguellat via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG63b0b82fd6be: When float_t and double_t types are used 
inside a scope with (authored by zahiraam).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153590/new/

https://reviews.llvm.org/D153590

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TokenKinds.def
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-only-in-default-eval.cpp
  clang/test/Sema/fp-eval-pragma-with-float-double_t-1.c
  clang/test/Sema/fp-eval-pragma-with-float-double_t-2.c
  clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c

Index: clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
===
--- /dev/null
+++ clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -verify -DNOERROR %s
+// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -DNOERROR %s
+
+// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=extended -DNOERROR %s
+// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP \
+// RUN: -ffp-eval-method=extended -DNOERROR %s
+
+// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=source %s
+// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=source %s
+
+// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=double %s
+// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=double %s
+
+
+#ifdef NOERROR
+// expected-no-diagnostics
+typedef float float_t;
+typedef double double_t;
+#else
+#ifdef CPP
+typedef float float_t; //expected-error 9 {{cannot use type 'float_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
+
+typedef double double_t; //expected-error 9 {{cannot use type 'double_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
+#else
+typedef float float_t; //expected-error 7 {{cannot use type 'float_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
+  
+typedef double double_t; //expected-error 7 {{cannot use type 'double_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
+#endif
+#endif
+
+float foo1() {
+#pragma clang fp eval_method(extended)
+  float a;
+  double b;
+  return a - b;
+}
+  
+float foo2() {
+#pragma clang fp eval_method(extended)
+  float_t a; 
+  double_t b; 
+  return a - b;
+}
+  
+void foo3() {
+#pragma clang fp eval_method(extended)
+  char buff[sizeof(float_t)];
+  char bufd[sizeof(double_t)];
+  buff[1] = bufd[2];
+}
+  
+float foo4() {
+#pragma clang fp eval_method(extended)
+  typedef float_t FT;
+  typedef double_t DT;
+  FT a;
+  DT b;
+  return a - b;
+}
+  
+int foo5() {
+#pragma clang fp eval_method(extended)
+  int t = _Generic( 1.0L, float_t:1, default:0);
+  int v = _Generic( 1.0L, double_t:1, default:0);
+  return t;
+}
+
+void foo6() {
+#pragma clang fp eval_method(extended)
+  float f = (float_t)1; 
+  double d = (double_t)2; 
+}
+  
+void foo7() {
+#pragma clang fp eval_method(extended)
+  float c1 = (float_t)12;
+  double c2 = (double_t)13;
+}
+  
+float foo8() {
+#pragma clang fp eval_method(extended)
+  extern float_t f;
+  extern double_t g;
+  return f-g;
+}
+
+#ifdef CPP
+void foo9() {
+#pragma clang fp eval_method(extended)
+  auto resf = [](float_t f) { return f; };
+  auto resd = [](double_t g) { return g; };
+}
+
+void foo10() {
+#pragma clang fp eval_method(extended)
+  using Ft = float_t;
+  using Dt = double_t;
+  Ft a;
+  Dt b;
+}
+#endif
+ 
Index: clang/test/Sema/fp-eval-pragma-with-float-double_t-2.c
===
--- /dev/null
+++ clang/test/Sema/fp-eval-pragma-with-float-double_t-2.c
@@ -0,0 +1,100 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -DNOERROR %s
+// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -DNOERROR %s
+
+// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=double -DNOERROR %s
+// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=double -DNOERROR %s
+
+// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=source %s
+// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=source %s
+
+// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=extended %s
+// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=extended %s 
+
+#ifdef NOERROR
+// expected-no-diagnostics
+typedef float float_t;
+typedef double double_t;
+#else
+#ifdef CPP
+typedef float float_t; //expected-error 9 {{cannot use type 'float_t' within '#pragma clang 

[PATCH] D153590: Don't use float_t and double_t with #pragma clang fp eval_method.

2023-06-23 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153590/new/

https://reviews.llvm.org/D153590

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


[PATCH] D153590: Don't use float_t and double_t with #pragma clang fp eval_method.

2023-06-23 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 533981.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153590/new/

https://reviews.llvm.org/D153590

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TokenKinds.def
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-only-in-default-eval.cpp
  clang/test/Sema/fp-eval-pragma-with-float-double_t-1.c
  clang/test/Sema/fp-eval-pragma-with-float-double_t-2.c
  clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c

Index: clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
===
--- /dev/null
+++ clang/test/Sema/fp-eval-pragma-with-float-double_t-3.c
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -verify -DNOERROR %s
+// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -DNOERROR %s
+
+// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=extended -DNOERROR %s
+// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP \
+// RUN: -ffp-eval-method=extended -DNOERROR %s
+
+// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=source %s
+// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=source %s
+
+// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=double %s
+// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=double %s
+
+
+#ifdef NOERROR
+// expected-no-diagnostics
+typedef float float_t;
+typedef double double_t;
+#else
+#ifdef CPP
+typedef float float_t; //expected-error 9 {{cannot use type 'float_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
+
+typedef double double_t; //expected-error 9 {{cannot use type 'double_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
+#else
+typedef float float_t; //expected-error 7 {{cannot use type 'float_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
+  
+typedef double double_t; //expected-error 7 {{cannot use type 'double_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
+#endif
+#endif
+
+float foo1() {
+#pragma clang fp eval_method(extended)
+  float a;
+  double b;
+  return a - b;
+}
+  
+float foo2() {
+#pragma clang fp eval_method(extended)
+  float_t a; 
+  double_t b; 
+  return a - b;
+}
+  
+void foo3() {
+#pragma clang fp eval_method(extended)
+  char buff[sizeof(float_t)];
+  char bufd[sizeof(double_t)];
+  buff[1] = bufd[2];
+}
+  
+float foo4() {
+#pragma clang fp eval_method(extended)
+  typedef float_t FT;
+  typedef double_t DT;
+  FT a;
+  DT b;
+  return a - b;
+}
+  
+int foo5() {
+#pragma clang fp eval_method(extended)
+  int t = _Generic( 1.0L, float_t:1, default:0);
+  int v = _Generic( 1.0L, double_t:1, default:0);
+  return t;
+}
+
+void foo6() {
+#pragma clang fp eval_method(extended)
+  float f = (float_t)1; 
+  double d = (double_t)2; 
+}
+  
+void foo7() {
+#pragma clang fp eval_method(extended)
+  float c1 = (float_t)12;
+  double c2 = (double_t)13;
+}
+  
+float foo8() {
+#pragma clang fp eval_method(extended)
+  extern float_t f;
+  extern double_t g;
+  return f-g;
+}
+
+#ifdef CPP
+void foo9() {
+#pragma clang fp eval_method(extended)
+  auto resf = [](float_t f) { return f; };
+  auto resd = [](double_t g) { return g; };
+}
+
+void foo10() {
+#pragma clang fp eval_method(extended)
+  using Ft = float_t;
+  using Dt = double_t;
+  Ft a;
+  Dt b;
+}
+#endif
+ 
Index: clang/test/Sema/fp-eval-pragma-with-float-double_t-2.c
===
--- /dev/null
+++ clang/test/Sema/fp-eval-pragma-with-float-double_t-2.c
@@ -0,0 +1,100 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -DNOERROR %s
+// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -DNOERROR %s
+
+// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=double -DNOERROR %s
+// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=double -DNOERROR %s
+
+// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=source %s
+// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=source %s
+
+// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=extended %s
+// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -DCPP -ffp-eval-method=extended %s 
+
+#ifdef NOERROR
+// expected-no-diagnostics
+typedef float float_t;
+typedef double double_t;
+#else
+#ifdef CPP
+typedef float float_t; //expected-error 9 {{cannot use type 'float_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
+  
+typedef double double_t; //expected-error 9 {{cannot use type 'double_t' within '#pragma 

[PATCH] D153590: Don't use float_t and double_t with #pragma clang fp eval_method.

2023-06-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

`abi-check` is a really generic name for a test case; could you rename those 
three tests to something more specific to this feature?  Also, your tests are 
only testing this behavior in C++.

Patch functionality LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153590/new/

https://reviews.llvm.org/D153590

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


[PATCH] D153590: Don't use float_t and double_t with #pragma clang fp eval_method.

2023-06-22 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam created this revision.
zahiraam added reviewers: rjmccall, andrew.w.kaylor, aaron.ballman.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
zahiraam requested review of this revision.
Herald added a project: clang.

When float_t and double_t types are used inside a scope with a '#pragma clang 
fp eval_method', it can lead to ABI breakage.
See https://godbolt.org/z/56zG4Wo91
This patch prevents this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153590

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TokenKinds.def
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/abi-check-1.cpp
  clang/test/Sema/abi-check-2.cpp
  clang/test/Sema/abi-check-3.cpp
  clang/test/Sema/attr-only-in-default-eval.cpp

Index: clang/test/Sema/attr-only-in-default-eval.cpp
===
--- /dev/null
+++ clang/test/Sema/attr-only-in-default-eval.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef float float_t [[clang::available_only_in_default_eval_method]];
+using double_t __attribute__((available_only_in_default_eval_method)) = double;
+
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+class  __attribute__((available_only_in_default_eval_method)) C1 {
+};
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+class  [[clang::available_only_in_default_eval_method]] C2 {
+};
+
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+struct [[clang::available_only_in_default_eval_method]] S1;
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+struct __attribute__((available_only_in_default_eval_method)) S2;
+
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+void __attribute__((available_only_in_default_eval_method)) foo();
+// expected-error@+1{{'available_only_in_default_eval_method' attribute cannot be applied to types}}
+void [[clang::available_only_in_default_eval_method]] goo();
+// expected-error@+1{{'available_only_in_default_eval_method' attribute cannot be applied to types}}
+void bar() [[clang::available_only_in_default_eval_method]];
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+void barz() __attribute__((available_only_in_default_eval_method));
+
Index: clang/test/Sema/abi-check-3.cpp
===
--- /dev/null
+++ clang/test/Sema/abi-check-3.cpp
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -DNOERROR %s
+// RUN: %clang_cc1 -fsyntax-only -verify -ffp-eval-method=extended -DNOERROR %s
+
+// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=source %s
+// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=double %s
+
+
+#ifdef NOERROR
+// expected-no-diagnostics
+typedef float float_t;
+typedef double double_t;
+#else
+typedef float float_t; //expected-error 9 {{cannot use type 'float_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
+
+typedef double double_t; //expected-error 9 {{cannot use type 'double_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
+#endif
+
+float foo1() {
+#pragma clang fp eval_method(extended)
+  float a;
+  double b;
+  return a - b;
+}
+
+float foo2() {
+#pragma clang fp eval_method(extended)
+  float_t a; 
+  double_t b; 
+  return a - b;
+}
+
+void foo3() {
+#pragma clang fp eval_method(extended)
+  char buff[sizeof(float_t)];
+  char bufd[sizeof(double_t)];
+  buff[1] = bufd[2];
+}
+
+float foo4() {
+#pragma clang fp eval_method(extended)
+  typedef float_t FT;
+  typedef double_t DT;
+  FT a;
+  DT b;
+  return a - b;
+}
+
+int foo5() {
+#pragma clang fp eval_method(extended)
+  int t = _Generic( 1.0L, float_t:1, default:0);
+  int v = _Generic( 1.0L, double_t:1, default:0);
+  return t;
+}
+
+void foo6() {
+#pragma clang fp eval_method(extended)
+  auto resf = [](float_t f) { return f; };
+  auto resd = [](double_t g) { return g; };
+}
+
+void foo7() {
+#pragma clang fp eval_method(extended)
+  float f = (float_t)1; 
+  double d = (double_t)2; 
+}
+
+void foo8() {
+#pragma clang fp eval_method(extended)
+  using Ft = float_t;
+  using Dt = double_t;
+  Ft a;
+  Dt b;
+}
+
+void foo9() {
+#pragma clang fp eval_method(extended)
+  float c1 = (float_t)12;
+  double c2 = (double_t)13;
+}
+
+float foo10() {
+#pragma clang fp eval_method(extended)
+  extern float_t f;
+  extern double_t g;
+  return f-g;
+}
Index: