public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/ibuclaw/heads/darwin)] d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests
@ 2021-09-17 14:33 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2021-09-17 14:33 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:82233fc0080c368e69ee33ebd50668f4ce844868

commit 82233fc0080c368e69ee33ebd50668f4ce844868
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Thu Dec 3 23:56:16 2020 +0100

    d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests

Diff:
---
 gcc/d/decl.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 0d46ee180e7..8ee674c426c 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -116,6 +116,27 @@ gcc_attribute_p (Dsymbol *decl)
   return false;
 }
 
+/* Returns true if DECL is either lexically nested inside a unittest function,
+   or a `version(unittest)' condition.  */
+
+static bool
+in_unittest_p (Declaration *decl)
+{
+  for (Dsymbol *p = decl->parent; p != NULL; p = p->parent)
+    {
+      if (p->isUnitTestDeclaration ())
+	return true;
+      if (FuncDeclaration *fd = p->isFuncDeclaration ())
+	{
+	  tree t = get_symbol_decl (fd);
+	  if (DECL_IN_UNITTEST_CONDITION_P (t))
+	    return true;
+	}
+    }
+
+  return false;
+}
+
 /* Implements the visitor interface to lower all Declaration AST classes
    emitted from the D Front-end to GCC trees.
    All visit methods accept one parameter D, which holds the frontend AST
@@ -655,6 +676,16 @@ public:
       }
     else if (d->isDataseg () && !(d->storage_class & STCextern))
       {
+	/* For libphobos-internal use only.  When compiling unittests, only
+	   generate code for unittest or instantiated variables.  */
+	if (flag_building_libphobos_tests)
+	  {
+	    if (!this->in_version_unittest_
+		&& !in_unittest_p (d)
+		&& !d->isInstantiated ())
+	      return;
+	  }
+
 	tree decl = get_symbol_decl (d);
 
 	/* Duplicated VarDeclarations map to the same symbol.  Check if this
@@ -767,6 +798,20 @@ public:
     if (!global.params.useUnitTests && d->isUnitTestDeclaration ())
       return;
 
+    /* For libphobos-internal use only.  When compiling unittests, only
+       generate code for unittest or instantiated functions.  */
+    if (flag_building_libphobos_tests)
+      {
+	if (!d->isUnitTestDeclaration ()
+	    && !this->in_version_unittest_
+	    && !in_unittest_p (d)
+	    && !d->isArrayOp
+	    && !d->isInstantiated ()
+	    && !d->isMain ()
+	    && !d->isCMain ())
+	  return;
+      }
+
     /* Check if any errors occurred when running semantic.  */
     if (TypeFunction *tf = d->type->isTypeFunction ())
       {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests
@ 2021-04-19 18:05 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2021-04-19 18:05 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:c19416169be92ee8342e029bc5c48cd38f88e4b5

commit c19416169be92ee8342e029bc5c48cd38f88e4b5
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Thu Dec 3 23:56:16 2020 +0100

    d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests

Diff:
---
 gcc/d/decl.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 7d1378255bd..3d7ada09d33 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -116,6 +116,27 @@ gcc_attribute_p (Dsymbol *decl)
   return false;
 }
 
+/* Returns true if DECL is either lexically nested inside a unittest function,
+   or a `version(unittest)' condition.  */
+
+static bool
+in_unittest_p (Declaration *decl)
+{
+  for (Dsymbol *p = decl->parent; p != NULL; p = p->parent)
+    {
+      if (p->isUnitTestDeclaration ())
+	return true;
+      if (FuncDeclaration *fd = p->isFuncDeclaration ())
+	{
+	  tree t = get_symbol_decl (fd);
+	  if (DECL_IN_UNITTEST_CONDITION_P (t))
+	    return true;
+	}
+    }
+
+  return false;
+}
+
 /* Implements the visitor interface to lower all Declaration AST classes
    emitted from the D Front-end to GCC trees.
    All visit methods accept one parameter D, which holds the frontend AST
@@ -655,6 +676,16 @@ public:
       }
     else if (d->isDataseg () && !(d->storage_class & STCextern))
       {
+	/* For libphobos-internal use only.  When compiling unittests, only
+	   generate code for unittest or instantiated variables.  */
+	if (flag_building_libphobos_tests)
+	  {
+	    if (!this->in_version_unittest_
+		&& !in_unittest_p (d)
+		&& !d->isInstantiated ())
+	      return;
+	  }
+
 	tree decl = get_symbol_decl (d);
 
 	/* Duplicated VarDeclarations map to the same symbol.  Check if this
@@ -767,6 +798,20 @@ public:
     if (!global.params.useUnitTests && d->isUnitTestDeclaration ())
       return;
 
+    /* For libphobos-internal use only.  When compiling unittests, only
+       generate code for unittest or instantiated functions.  */
+    if (flag_building_libphobos_tests)
+      {
+	if (!d->isUnitTestDeclaration ()
+	    && !this->in_version_unittest_
+	    && !in_unittest_p (d)
+	    && !d->isArrayOp
+	    && !d->isInstantiated ()
+	    && !d->isMain ()
+	    && !d->isCMain ())
+	  return;
+      }
+
     /* Check if any errors occurred when running semantic.  */
     if (TypeFunction *tf = d->type->isTypeFunction ())
       {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests
@ 2021-04-10 17:00 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2021-04-10 17:00 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:47e95eb33bcb3a472dcaa176a3d85523795687e2

commit 47e95eb33bcb3a472dcaa176a3d85523795687e2
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Thu Dec 3 23:56:16 2020 +0100

    d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests

Diff:
---
 gcc/d/decl.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index b07068ed6ca..7b9ce9d5281 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -115,6 +115,27 @@ gcc_attribute_p (Dsymbol *decl)
   return false;
 }
 
+/* Returns true if DECL is either lexically nested inside a unittest function,
+   or a `version(unittest)' condition.  */
+
+static bool
+in_unittest_p (Declaration *decl)
+{
+  for (Dsymbol *p = decl->parent; p != NULL; p = p->parent)
+    {
+      if (p->isUnitTestDeclaration ())
+	return true;
+      if (FuncDeclaration *fd = p->isFuncDeclaration ())
+	{
+	  tree t = get_symbol_decl (fd);
+	  if (DECL_IN_UNITTEST_CONDITION_P (t))
+	    return true;
+	}
+    }
+
+  return false;
+}
+
 /* Implements the visitor interface to lower all Declaration AST classes
    emitted from the D Front-end to GCC trees.
    All visit methods accept one parameter D, which holds the frontend AST
@@ -657,6 +678,16 @@ public:
       }
     else if (d->isDataseg () && !(d->storage_class & STCextern))
       {
+	/* For libphobos-internal use only.  When compiling unittests, only
+	   generate code for unittest or instantiated variables.  */
+	if (flag_building_libphobos_tests)
+	  {
+	    if (!this->in_version_unittest_
+		&& !in_unittest_p (d)
+		&& !d->isInstantiated ())
+	      return;
+	  }
+
 	tree decl = get_symbol_decl (d);
 
 	/* Duplicated VarDeclarations map to the same symbol.  Check if this
@@ -769,6 +800,20 @@ public:
     if (!global.params.useUnitTests && d->isUnitTestDeclaration ())
       return;
 
+    /* For libphobos-internal use only.  When compiling unittests, only
+       generate code for unittest or instantiated functions.  */
+    if (flag_building_libphobos_tests)
+      {
+	if (!d->isUnitTestDeclaration ()
+	    && !this->in_version_unittest_
+	    && !in_unittest_p (d)
+	    && !d->isArrayOp
+	    && !d->isInstantiated ()
+	    && !d->isMain ()
+	    && !d->isCMain ())
+	  return;
+      }
+
     /* Check if any errors occurred when running semantic.  */
     if (TypeFunction *tf = d->type->isTypeFunction ())
       {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests
@ 2021-04-10 15:04 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2021-04-10 15:04 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0a0d1a5b9362b77300ddeffd599ad977ee9b337e

commit 0a0d1a5b9362b77300ddeffd599ad977ee9b337e
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Thu Dec 3 23:56:16 2020 +0100

    d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests

Diff:
---
 gcc/d/decl.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index b07068ed6ca..7b9ce9d5281 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -115,6 +115,27 @@ gcc_attribute_p (Dsymbol *decl)
   return false;
 }
 
+/* Returns true if DECL is either lexically nested inside a unittest function,
+   or a `version(unittest)' condition.  */
+
+static bool
+in_unittest_p (Declaration *decl)
+{
+  for (Dsymbol *p = decl->parent; p != NULL; p = p->parent)
+    {
+      if (p->isUnitTestDeclaration ())
+	return true;
+      if (FuncDeclaration *fd = p->isFuncDeclaration ())
+	{
+	  tree t = get_symbol_decl (fd);
+	  if (DECL_IN_UNITTEST_CONDITION_P (t))
+	    return true;
+	}
+    }
+
+  return false;
+}
+
 /* Implements the visitor interface to lower all Declaration AST classes
    emitted from the D Front-end to GCC trees.
    All visit methods accept one parameter D, which holds the frontend AST
@@ -657,6 +678,16 @@ public:
       }
     else if (d->isDataseg () && !(d->storage_class & STCextern))
       {
+	/* For libphobos-internal use only.  When compiling unittests, only
+	   generate code for unittest or instantiated variables.  */
+	if (flag_building_libphobos_tests)
+	  {
+	    if (!this->in_version_unittest_
+		&& !in_unittest_p (d)
+		&& !d->isInstantiated ())
+	      return;
+	  }
+
 	tree decl = get_symbol_decl (d);
 
 	/* Duplicated VarDeclarations map to the same symbol.  Check if this
@@ -769,6 +800,20 @@ public:
     if (!global.params.useUnitTests && d->isUnitTestDeclaration ())
       return;
 
+    /* For libphobos-internal use only.  When compiling unittests, only
+       generate code for unittest or instantiated functions.  */
+    if (flag_building_libphobos_tests)
+      {
+	if (!d->isUnitTestDeclaration ()
+	    && !this->in_version_unittest_
+	    && !in_unittest_p (d)
+	    && !d->isArrayOp
+	    && !d->isInstantiated ()
+	    && !d->isMain ()
+	    && !d->isCMain ())
+	  return;
+      }
+
     /* Check if any errors occurred when running semantic.  */
     if (TypeFunction *tf = d->type->isTypeFunction ())
       {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests
@ 2021-03-14 22:00 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2021-03-14 22:00 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5d11478d155173ef2f6673f642ce5670aecae96a

commit 5d11478d155173ef2f6673f642ce5670aecae96a
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Thu Dec 3 23:56:16 2020 +0100

    d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests

Diff:
---
 gcc/d/decl.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index fef29d8e54b..0c84a5af0e9 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -115,6 +115,27 @@ gcc_attribute_p (Dsymbol *decl)
   return false;
 }
 
+/* Returns true if DECL is either lexically nested inside a unittest function,
+   or a `version(unittest)' condition.  */
+
+static bool
+in_unittest_p (Declaration *decl)
+{
+  for (Dsymbol *p = decl->parent; p != NULL; p = p->parent)
+    {
+      if (p->isUnitTestDeclaration ())
+	return true;
+      if (FuncDeclaration *fd = p->isFuncDeclaration ())
+	{
+	  tree t = get_symbol_decl (fd);
+	  if (DECL_IN_UNITTEST_CONDITION_P (t))
+	    return true;
+	}
+    }
+
+  return false;
+}
+
 /* Implements the visitor interface to lower all Declaration AST classes
    emitted from the D Front-end to GCC trees.
    All visit methods accept one parameter D, which holds the frontend AST
@@ -657,6 +678,16 @@ public:
       }
     else if (d->isDataseg () && !(d->storage_class & STCextern))
       {
+	/* For libphobos-internal use only.  When compiling unittests, only
+	   generate code for unittest or instantiated variables.  */
+	if (flag_building_libphobos_tests)
+	  {
+	    if (!this->in_version_unittest_
+		&& !in_unittest_p (d)
+		&& !d->isInstantiated ())
+	      return;
+	  }
+
 	tree decl = get_symbol_decl (d);
 
 	/* Duplicated VarDeclarations map to the same symbol.  Check if this
@@ -769,6 +800,20 @@ public:
     if (!global.params.useUnitTests && d->isUnitTestDeclaration ())
       return;
 
+    /* For libphobos-internal use only.  When compiling unittests, only
+       generate code for unittest or instantiated functions.  */
+    if (flag_building_libphobos_tests)
+      {
+	if (!d->isUnitTestDeclaration ()
+	    && !this->in_version_unittest_
+	    && !in_unittest_p (d)
+	    && !d->isArrayOp
+	    && !d->isInstantiated ()
+	    && !d->isMain ()
+	    && !d->isCMain ())
+	  return;
+      }
+
     /* Check if any errors occurred when running semantic.  */
     if (TypeFunction *tf = d->type->isTypeFunction ())
       {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests
@ 2021-03-07 17:01 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2021-03-07 17:01 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:422366ef65da54dd835ff23216508084dadfcc2c

commit 422366ef65da54dd835ff23216508084dadfcc2c
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Thu Dec 3 23:56:16 2020 +0100

    d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests

Diff:
---
 gcc/d/decl.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 15b04b1e75f..2378b1e6f13 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -115,6 +115,27 @@ gcc_attribute_p (Dsymbol *decl)
   return false;
 }
 
+/* Returns true if DECL is either lexically nested inside a unittest function,
+   or a `version(unittest)' condition.  */
+
+static bool
+in_unittest_p (Declaration *decl)
+{
+  for (Dsymbol *p = decl->parent; p != NULL; p = p->parent)
+    {
+      if (p->isUnitTestDeclaration ())
+	return true;
+      if (FuncDeclaration *fd = p->isFuncDeclaration ())
+	{
+	  tree t = get_symbol_decl (fd);
+	  if (DECL_IN_UNITTEST_CONDITION_P (t))
+	    return true;
+	}
+    }
+
+  return false;
+}
+
 /* Implements the visitor interface to lower all Declaration AST classes
    emitted from the D Front-end to GCC trees.
    All visit methods accept one parameter D, which holds the frontend AST
@@ -666,6 +687,16 @@ public:
       }
     else if (d->isDataseg () && !(d->storage_class & STCextern))
       {
+	/* For libphobos-internal use only.  When compiling unittests, only
+	   generate code for unittest or instantiated variables.  */
+	if (flag_building_libphobos_tests)
+	  {
+	    if (!this->in_version_unittest_
+		&& !in_unittest_p (d)
+		&& !d->isInstantiated ())
+	      return;
+	  }
+
 	tree decl = get_symbol_decl (d);
 
 	/* Duplicated VarDeclarations map to the same symbol.  Check if this
@@ -778,6 +809,20 @@ public:
     if (!global.params.useUnitTests && d->isUnitTestDeclaration ())
       return;
 
+    /* For libphobos-internal use only.  When compiling unittests, only
+       generate code for unittest or instantiated functions.  */
+    if (flag_building_libphobos_tests)
+      {
+	if (!d->isUnitTestDeclaration ()
+	    && !this->in_version_unittest_
+	    && !in_unittest_p (d)
+	    && !d->isArrayOp
+	    && !d->isInstantiated ()
+	    && !d->isMain ()
+	    && !d->isCMain ())
+	  return;
+      }
+
     /* Check if any errors occurred when running semantic.  */
     if (TypeFunction *tf = d->type->isTypeFunction ())
       {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests
@ 2021-01-30 19:08 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2021-01-30 19:08 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:7efcb18a29856448179296d76bc9ef05595990cc

commit 7efcb18a29856448179296d76bc9ef05595990cc
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Thu Dec 3 23:56:16 2020 +0100

    d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests

Diff:
---
 gcc/d/decl.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 15b04b1e75f..2378b1e6f13 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -115,6 +115,27 @@ gcc_attribute_p (Dsymbol *decl)
   return false;
 }
 
+/* Returns true if DECL is either lexically nested inside a unittest function,
+   or a `version(unittest)' condition.  */
+
+static bool
+in_unittest_p (Declaration *decl)
+{
+  for (Dsymbol *p = decl->parent; p != NULL; p = p->parent)
+    {
+      if (p->isUnitTestDeclaration ())
+	return true;
+      if (FuncDeclaration *fd = p->isFuncDeclaration ())
+	{
+	  tree t = get_symbol_decl (fd);
+	  if (DECL_IN_UNITTEST_CONDITION_P (t))
+	    return true;
+	}
+    }
+
+  return false;
+}
+
 /* Implements the visitor interface to lower all Declaration AST classes
    emitted from the D Front-end to GCC trees.
    All visit methods accept one parameter D, which holds the frontend AST
@@ -666,6 +687,16 @@ public:
       }
     else if (d->isDataseg () && !(d->storage_class & STCextern))
       {
+	/* For libphobos-internal use only.  When compiling unittests, only
+	   generate code for unittest or instantiated variables.  */
+	if (flag_building_libphobos_tests)
+	  {
+	    if (!this->in_version_unittest_
+		&& !in_unittest_p (d)
+		&& !d->isInstantiated ())
+	      return;
+	  }
+
 	tree decl = get_symbol_decl (d);
 
 	/* Duplicated VarDeclarations map to the same symbol.  Check if this
@@ -778,6 +809,20 @@ public:
     if (!global.params.useUnitTests && d->isUnitTestDeclaration ())
       return;
 
+    /* For libphobos-internal use only.  When compiling unittests, only
+       generate code for unittest or instantiated functions.  */
+    if (flag_building_libphobos_tests)
+      {
+	if (!d->isUnitTestDeclaration ()
+	    && !this->in_version_unittest_
+	    && !in_unittest_p (d)
+	    && !d->isArrayOp
+	    && !d->isInstantiated ()
+	    && !d->isMain ()
+	    && !d->isCMain ())
+	  return;
+      }
+
     /* Check if any errors occurred when running semantic.  */
     if (TypeFunction *tf = d->type->isTypeFunction ())
       {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests
@ 2021-01-28 17:31 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2021-01-28 17:31 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:bf25ce0c4f42c9140a24777d11f36f5d7162ef52

commit bf25ce0c4f42c9140a24777d11f36f5d7162ef52
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Thu Dec 3 23:56:16 2020 +0100

    d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests

Diff:
---
 gcc/d/decl.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 15b04b1e75f..2378b1e6f13 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -115,6 +115,27 @@ gcc_attribute_p (Dsymbol *decl)
   return false;
 }
 
+/* Returns true if DECL is either lexically nested inside a unittest function,
+   or a `version(unittest)' condition.  */
+
+static bool
+in_unittest_p (Declaration *decl)
+{
+  for (Dsymbol *p = decl->parent; p != NULL; p = p->parent)
+    {
+      if (p->isUnitTestDeclaration ())
+	return true;
+      if (FuncDeclaration *fd = p->isFuncDeclaration ())
+	{
+	  tree t = get_symbol_decl (fd);
+	  if (DECL_IN_UNITTEST_CONDITION_P (t))
+	    return true;
+	}
+    }
+
+  return false;
+}
+
 /* Implements the visitor interface to lower all Declaration AST classes
    emitted from the D Front-end to GCC trees.
    All visit methods accept one parameter D, which holds the frontend AST
@@ -666,6 +687,16 @@ public:
       }
     else if (d->isDataseg () && !(d->storage_class & STCextern))
       {
+	/* For libphobos-internal use only.  When compiling unittests, only
+	   generate code for unittest or instantiated variables.  */
+	if (flag_building_libphobos_tests)
+	  {
+	    if (!this->in_version_unittest_
+		&& !in_unittest_p (d)
+		&& !d->isInstantiated ())
+	      return;
+	  }
+
 	tree decl = get_symbol_decl (d);
 
 	/* Duplicated VarDeclarations map to the same symbol.  Check if this
@@ -778,6 +809,20 @@ public:
     if (!global.params.useUnitTests && d->isUnitTestDeclaration ())
       return;
 
+    /* For libphobos-internal use only.  When compiling unittests, only
+       generate code for unittest or instantiated functions.  */
+    if (flag_building_libphobos_tests)
+      {
+	if (!d->isUnitTestDeclaration ()
+	    && !this->in_version_unittest_
+	    && !in_unittest_p (d)
+	    && !d->isArrayOp
+	    && !d->isInstantiated ()
+	    && !d->isMain ()
+	    && !d->isCMain ())
+	  return;
+      }
+
     /* Check if any errors occurred when running semantic.  */
     if (TypeFunction *tf = d->type->isTypeFunction ())
       {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests
@ 2021-01-11 11:39 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2021-01-11 11:39 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:7fcf24b53c7221025d71b900d981dcfe3566ed51

commit 7fcf24b53c7221025d71b900d981dcfe3566ed51
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Thu Dec 3 23:56:16 2020 +0100

    d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests

Diff:
---
 gcc/d/decl.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 15b04b1e75f..2378b1e6f13 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -115,6 +115,27 @@ gcc_attribute_p (Dsymbol *decl)
   return false;
 }
 
+/* Returns true if DECL is either lexically nested inside a unittest function,
+   or a `version(unittest)' condition.  */
+
+static bool
+in_unittest_p (Declaration *decl)
+{
+  for (Dsymbol *p = decl->parent; p != NULL; p = p->parent)
+    {
+      if (p->isUnitTestDeclaration ())
+	return true;
+      if (FuncDeclaration *fd = p->isFuncDeclaration ())
+	{
+	  tree t = get_symbol_decl (fd);
+	  if (DECL_IN_UNITTEST_CONDITION_P (t))
+	    return true;
+	}
+    }
+
+  return false;
+}
+
 /* Implements the visitor interface to lower all Declaration AST classes
    emitted from the D Front-end to GCC trees.
    All visit methods accept one parameter D, which holds the frontend AST
@@ -666,6 +687,16 @@ public:
       }
     else if (d->isDataseg () && !(d->storage_class & STCextern))
       {
+	/* For libphobos-internal use only.  When compiling unittests, only
+	   generate code for unittest or instantiated variables.  */
+	if (flag_building_libphobos_tests)
+	  {
+	    if (!this->in_version_unittest_
+		&& !in_unittest_p (d)
+		&& !d->isInstantiated ())
+	      return;
+	  }
+
 	tree decl = get_symbol_decl (d);
 
 	/* Duplicated VarDeclarations map to the same symbol.  Check if this
@@ -778,6 +809,20 @@ public:
     if (!global.params.useUnitTests && d->isUnitTestDeclaration ())
       return;
 
+    /* For libphobos-internal use only.  When compiling unittests, only
+       generate code for unittest or instantiated functions.  */
+    if (flag_building_libphobos_tests)
+      {
+	if (!d->isUnitTestDeclaration ()
+	    && !this->in_version_unittest_
+	    && !in_unittest_p (d)
+	    && !d->isArrayOp
+	    && !d->isInstantiated ()
+	    && !d->isMain ()
+	    && !d->isCMain ())
+	  return;
+      }
+
     /* Check if any errors occurred when running semantic.  */
     if (TypeFunction *tf = d->type->isTypeFunction ())
       {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests
@ 2020-12-22 13:40 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2020-12-22 13:40 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:c77c67bf0b30e8becc9dd4bd6e6d7597e1d49ec7

commit c77c67bf0b30e8becc9dd4bd6e6d7597e1d49ec7
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Thu Dec 3 23:56:16 2020 +0100

    d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests

Diff:
---
 gcc/d/decl.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 6df92599cb7..d3b68d5ca59 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -115,6 +115,27 @@ gcc_attribute_p (Dsymbol *decl)
   return false;
 }
 
+/* Returns true if DECL is either lexically nested inside a unittest function,
+   or a `version(unittest)' condition.  */
+
+static bool
+in_unittest_p (Declaration *decl)
+{
+  for (Dsymbol *p = decl->parent; p != NULL; p = p->parent)
+    {
+      if (p->isUnitTestDeclaration ())
+	return true;
+      if (FuncDeclaration *fd = p->isFuncDeclaration ())
+	{
+	  tree t = get_symbol_decl (fd);
+	  if (DECL_IN_UNITTEST_CONDITION_P (t))
+	    return true;
+	}
+    }
+
+  return false;
+}
+
 /* Implements the visitor interface to lower all Declaration AST classes
    emitted from the D Front-end to GCC trees.
    All visit methods accept one parameter D, which holds the frontend AST
@@ -666,6 +687,16 @@ public:
       }
     else if (d->isDataseg () && !(d->storage_class & STCextern))
       {
+	/* For libphobos-internal use only.  When compiling unittests, only
+	   generate code for unittest or instantiated variables.  */
+	if (flag_building_libphobos_tests)
+	  {
+	    if (!this->in_version_unittest_
+		&& !in_unittest_p (d)
+		&& !d->isInstantiated ())
+	      return;
+	  }
+
 	tree decl = get_symbol_decl (d);
 
 	/* Duplicated VarDeclarations map to the same symbol.  Check if this
@@ -778,6 +809,20 @@ public:
     if (!global.params.useUnitTests && d->isUnitTestDeclaration ())
       return;
 
+    /* For libphobos-internal use only.  When compiling unittests, only
+       generate code for unittest or instantiated functions.  */
+    if (flag_building_libphobos_tests)
+      {
+	if (!d->isUnitTestDeclaration ()
+	    && !this->in_version_unittest_
+	    && !in_unittest_p (d)
+	    && !d->isArrayOp
+	    && !d->isInstantiated ()
+	    && !d->isMain ()
+	    && !d->isCMain ())
+	  return;
+      }
+
     /* Check if any errors occurred when running semantic.  */
     if (TypeFunction *tf = d->type->isTypeFunction ())
       {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests
@ 2020-12-09  9:51 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2020-12-09  9:51 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:684dd9ca5f7575d59e01bc7429ebf5252932b958

commit 684dd9ca5f7575d59e01bc7429ebf5252932b958
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Thu Dec 3 23:56:16 2020 +0100

    d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests

Diff:
---
 gcc/d/decl.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 1e46f108722..f06f1e587a7 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -115,6 +115,27 @@ gcc_attribute_p (Dsymbol *decl)
   return false;
 }
 
+/* Returns true if DECL is either lexically nested inside a unittest function,
+   or a `version(unittest)' condition.  */
+
+static bool
+in_unittest_p (Declaration *decl)
+{
+  for (Dsymbol *p = decl->parent; p != NULL; p = p->parent)
+    {
+      if (p->isUnitTestDeclaration ())
+	return true;
+      if (FuncDeclaration *fd = p->isFuncDeclaration ())
+	{
+	  tree t = get_symbol_decl (fd);
+	  if (DECL_IN_UNITTEST_CONDITION_P (t))
+	    return true;
+	}
+    }
+
+  return false;
+}
+
 /* Implements the visitor interface to lower all Declaration AST classes
    emitted from the D Front-end to GCC trees.
    All visit methods accept one parameter D, which holds the frontend AST
@@ -684,6 +705,16 @@ public:
       }
     else if (d->isDataseg () && !(d->storage_class & STCextern))
       {
+	/* For libphobos-internal use only.  When compiling unittests, only
+	   generate code for unittest or instantiated variables.  */
+	if (flag_building_libphobos_tests)
+	  {
+	    if (!this->in_version_unittest_
+		&& !in_unittest_p (d)
+		&& !d->isInstantiated ())
+	      return;
+	  }
+
 	tree decl = get_symbol_decl (d);
 
 	/* Duplicated VarDeclarations map to the same symbol.  Check if this
@@ -796,6 +827,20 @@ public:
     if (!global.params.useUnitTests && d->isUnitTestDeclaration ())
       return;
 
+    /* For libphobos-internal use only.  When compiling unittests, only
+       generate code for unittest or instantiated functions.  */
+    if (flag_building_libphobos_tests)
+      {
+	if (!d->isUnitTestDeclaration ()
+	    && !this->in_version_unittest_
+	    && !in_unittest_p (d)
+	    && !d->isArrayOp
+	    && !d->isInstantiated ()
+	    && !d->isMain ()
+	    && !d->isCMain ())
+	  return;
+      }
+
     /* Check if any errors occurred when running semantic.  */
     if (TypeFunction *tf = d->type->isTypeFunction ())
       {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests
@ 2020-12-05 23:47 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2020-12-05 23:47 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:fb6adbeab8931f9b9621231475f049c18b007445

commit fb6adbeab8931f9b9621231475f049c18b007445
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Thu Dec 3 23:56:16 2020 +0100

    d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests

Diff:
---
 gcc/d/decl.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 1e46f108722..f06f1e587a7 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -115,6 +115,27 @@ gcc_attribute_p (Dsymbol *decl)
   return false;
 }
 
+/* Returns true if DECL is either lexically nested inside a unittest function,
+   or a `version(unittest)' condition.  */
+
+static bool
+in_unittest_p (Declaration *decl)
+{
+  for (Dsymbol *p = decl->parent; p != NULL; p = p->parent)
+    {
+      if (p->isUnitTestDeclaration ())
+	return true;
+      if (FuncDeclaration *fd = p->isFuncDeclaration ())
+	{
+	  tree t = get_symbol_decl (fd);
+	  if (DECL_IN_UNITTEST_CONDITION_P (t))
+	    return true;
+	}
+    }
+
+  return false;
+}
+
 /* Implements the visitor interface to lower all Declaration AST classes
    emitted from the D Front-end to GCC trees.
    All visit methods accept one parameter D, which holds the frontend AST
@@ -684,6 +705,16 @@ public:
       }
     else if (d->isDataseg () && !(d->storage_class & STCextern))
       {
+	/* For libphobos-internal use only.  When compiling unittests, only
+	   generate code for unittest or instantiated variables.  */
+	if (flag_building_libphobos_tests)
+	  {
+	    if (!this->in_version_unittest_
+		&& !in_unittest_p (d)
+		&& !d->isInstantiated ())
+	      return;
+	  }
+
 	tree decl = get_symbol_decl (d);
 
 	/* Duplicated VarDeclarations map to the same symbol.  Check if this
@@ -796,6 +827,20 @@ public:
     if (!global.params.useUnitTests && d->isUnitTestDeclaration ())
       return;
 
+    /* For libphobos-internal use only.  When compiling unittests, only
+       generate code for unittest or instantiated functions.  */
+    if (flag_building_libphobos_tests)
+      {
+	if (!d->isUnitTestDeclaration ()
+	    && !this->in_version_unittest_
+	    && !in_unittest_p (d)
+	    && !d->isArrayOp
+	    && !d->isInstantiated ()
+	    && !d->isMain ()
+	    && !d->isCMain ())
+	  return;
+      }
+
     /* Check if any errors occurred when running semantic.  */
     if (TypeFunction *tf = d->type->isTypeFunction ())
       {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests
@ 2020-12-03 22:57 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2020-12-03 22:57 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f77e89099ecfbeb0965fce3d654518d88cceed58

commit f77e89099ecfbeb0965fce3d654518d88cceed58
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Thu Dec 3 23:56:16 2020 +0100

    d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests

Diff:
---
 gcc/d/decl.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 1e46f108722..f06f1e587a7 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -115,6 +115,27 @@ gcc_attribute_p (Dsymbol *decl)
   return false;
 }
 
+/* Returns true if DECL is either lexically nested inside a unittest function,
+   or a `version(unittest)' condition.  */
+
+static bool
+in_unittest_p (Declaration *decl)
+{
+  for (Dsymbol *p = decl->parent; p != NULL; p = p->parent)
+    {
+      if (p->isUnitTestDeclaration ())
+	return true;
+      if (FuncDeclaration *fd = p->isFuncDeclaration ())
+	{
+	  tree t = get_symbol_decl (fd);
+	  if (DECL_IN_UNITTEST_CONDITION_P (t))
+	    return true;
+	}
+    }
+
+  return false;
+}
+
 /* Implements the visitor interface to lower all Declaration AST classes
    emitted from the D Front-end to GCC trees.
    All visit methods accept one parameter D, which holds the frontend AST
@@ -684,6 +705,16 @@ public:
       }
     else if (d->isDataseg () && !(d->storage_class & STCextern))
       {
+	/* For libphobos-internal use only.  When compiling unittests, only
+	   generate code for unittest or instantiated variables.  */
+	if (flag_building_libphobos_tests)
+	  {
+	    if (!this->in_version_unittest_
+		&& !in_unittest_p (d)
+		&& !d->isInstantiated ())
+	      return;
+	  }
+
 	tree decl = get_symbol_decl (d);
 
 	/* Duplicated VarDeclarations map to the same symbol.  Check if this
@@ -796,6 +827,20 @@ public:
     if (!global.params.useUnitTests && d->isUnitTestDeclaration ())
       return;
 
+    /* For libphobos-internal use only.  When compiling unittests, only
+       generate code for unittest or instantiated functions.  */
+    if (flag_building_libphobos_tests)
+      {
+	if (!d->isUnitTestDeclaration ()
+	    && !this->in_version_unittest_
+	    && !in_unittest_p (d)
+	    && !d->isArrayOp
+	    && !d->isInstantiated ()
+	    && !d->isMain ()
+	    && !d->isCMain ())
+	  return;
+      }
+
     /* Check if any errors occurred when running semantic.  */
     if (TypeFunction *tf = d->type->isTypeFunction ())
       {


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-09-17 14:33 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-17 14:33 [gcc(refs/users/ibuclaw/heads/darwin)] d: Don't emit normal functions and declarations when compiling with -fbuilding-libphobos-tests Iain Buclaw
  -- strict thread matches above, loose matches on Subject: below --
2021-04-19 18:05 Iain Buclaw
2021-04-10 17:00 Iain Buclaw
2021-04-10 15:04 Iain Buclaw
2021-03-14 22:00 Iain Buclaw
2021-03-07 17:01 Iain Buclaw
2021-01-30 19:08 Iain Buclaw
2021-01-28 17:31 Iain Buclaw
2021-01-11 11:39 Iain Buclaw
2020-12-22 13:40 Iain Buclaw
2020-12-09  9:51 Iain Buclaw
2020-12-05 23:47 Iain Buclaw
2020-12-03 22:57 Iain Buclaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).