public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c++/modules: fix up recent testcases
@ 2023-10-25 18:32 Patrick Palka
  2023-10-25 21:09 ` Nathan Sidwell
  2023-10-25 21:24 ` Jason Merrill
  0 siblings, 2 replies; 3+ messages in thread
From: Patrick Palka @ 2023-10-25 18:32 UTC (permalink / raw)
  To: gcc-patches; +Cc: jason, nathan, Patrick Palka

Tested on x86_64-pc-linux-gnu, does this look OK for trunk?

Declaring get() inline seems necessary to avoid link failure:

  /usr/bin/ld: /tmp/ccwdv6Co.o: in function `g3@pr105322.Decltype()':
  decltype-1_b.C:(.text._ZW8pr105322W8Decltype2g3v[_ZW8pr105322W8Decltype2g3v]+0x18): undefined reference to `f@pr105322.Decltype()::A::get()'

Not sure if that's expected?

-- >8 --

This fixes some minor issues with the testcases from
r14-4806-g084addf8a700fa.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/decltype-1_a.C: Add missing } to dg-module-do
	directive.  Declare f()::A::get() inline.
	* g++.dg/modules/lambda-5_a.C: Add missing } to dg-module-do
	directive.
---
 gcc/testsuite/g++.dg/modules/decltype-1_a.C | 4 ++--
 gcc/testsuite/g++.dg/modules/lambda-5_a.C   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/g++.dg/modules/decltype-1_a.C b/gcc/testsuite/g++.dg/modules/decltype-1_a.C
index ca66e8b598a..6512f151aae 100644
--- a/gcc/testsuite/g++.dg/modules/decltype-1_a.C
+++ b/gcc/testsuite/g++.dg/modules/decltype-1_a.C
@@ -1,5 +1,5 @@
 // PR c++/105322
-// { dg-module-do link
+// { dg-module-do link }
 // { dg-additional-options -fmodules-ts }
 // { dg-module-cmi pr105322.Decltype }
 
@@ -7,7 +7,7 @@ export module pr105322.Decltype;
 
 auto f() {
   struct A { int m;
-    int get () { return m; }
+    inline int get () { return m; }
   };
   return A{};
 }
diff --git a/gcc/testsuite/g++.dg/modules/lambda-5_a.C b/gcc/testsuite/g++.dg/modules/lambda-5_a.C
index 6b589d4965c..37d0e77b1e1 100644
--- a/gcc/testsuite/g++.dg/modules/lambda-5_a.C
+++ b/gcc/testsuite/g++.dg/modules/lambda-5_a.C
@@ -1,5 +1,5 @@
 // PR c++/105322
-// { dg-module-do link
+// { dg-module-do link }
 // { dg-additional-options -fmodules-ts }
 // { dg-module-cmi pr105322.Lambda }
 
-- 
2.42.0.482.g2e8e77cbac


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

* Re: [PATCH] c++/modules: fix up recent testcases
  2023-10-25 18:32 [PATCH] c++/modules: fix up recent testcases Patrick Palka
@ 2023-10-25 21:09 ` Nathan Sidwell
  2023-10-25 21:24 ` Jason Merrill
  1 sibling, 0 replies; 3+ messages in thread
From: Nathan Sidwell @ 2023-10-25 21:09 UTC (permalink / raw)
  To: Patrick Palka, gcc-patches; +Cc: jason

Patrick,

thanks for noticing this, and this is a suitable workaround for another bug.

We should either be emitting the definition of that member function in the 
object file of its containing function.  Or it should be implicitly inline.

I know in module perview the in-class defined member functions at namespace 
scope are /not/ implicitly inline.  But I can't recall what the std says about 
non-namespace scope classes.

Ah, it appears to be the former we should be doing:

[class.mfct] If a member function is attached to the global module and is 
defined (9.5) in its class definition, it is inline (9.2.8).

Notice we can get into the weird situation that the member functions of a local 
class of a module-purview inline function might not themselves be inline!


On 10/25/23 14:32, Patrick Palka wrote:
> Tested on x86_64-pc-linux-gnu, does this look OK for trunk?
> 
> Declaring get() inline seems necessary to avoid link failure:
> 
>    /usr/bin/ld: /tmp/ccwdv6Co.o: in function `g3@pr105322.Decltype()':
>    decltype-1_b.C:(.text._ZW8pr105322W8Decltype2g3v[_ZW8pr105322W8Decltype2g3v]+0x18): undefined reference to `f@pr105322.Decltype()::A::get()'
> 
> Not sure if that's expected?
> 
> -- >8 --
> 
> This fixes some minor issues with the testcases from
> r14-4806-g084addf8a700fa.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* g++.dg/modules/decltype-1_a.C: Add missing } to dg-module-do
> 	directive.  Declare f()::A::get() inline.
> 	* g++.dg/modules/lambda-5_a.C: Add missing } to dg-module-do
> 	directive.
> ---
>   gcc/testsuite/g++.dg/modules/decltype-1_a.C | 4 ++--
>   gcc/testsuite/g++.dg/modules/lambda-5_a.C   | 2 +-
>   2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/gcc/testsuite/g++.dg/modules/decltype-1_a.C b/gcc/testsuite/g++.dg/modules/decltype-1_a.C
> index ca66e8b598a..6512f151aae 100644
> --- a/gcc/testsuite/g++.dg/modules/decltype-1_a.C
> +++ b/gcc/testsuite/g++.dg/modules/decltype-1_a.C
> @@ -1,5 +1,5 @@
>   // PR c++/105322
> -// { dg-module-do link
> +// { dg-module-do link }
>   // { dg-additional-options -fmodules-ts }
>   // { dg-module-cmi pr105322.Decltype }
>   
> @@ -7,7 +7,7 @@ export module pr105322.Decltype;
>   
>   auto f() {
>     struct A { int m;
> -    int get () { return m; }
> +    inline int get () { return m; }
>     };
>     return A{};
>   }
> diff --git a/gcc/testsuite/g++.dg/modules/lambda-5_a.C b/gcc/testsuite/g++.dg/modules/lambda-5_a.C
> index 6b589d4965c..37d0e77b1e1 100644
> --- a/gcc/testsuite/g++.dg/modules/lambda-5_a.C
> +++ b/gcc/testsuite/g++.dg/modules/lambda-5_a.C
> @@ -1,5 +1,5 @@
>   // PR c++/105322
> -// { dg-module-do link
> +// { dg-module-do link }
>   // { dg-additional-options -fmodules-ts }
>   // { dg-module-cmi pr105322.Lambda }
>   

-- 
Nathan Sidwell


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

* Re: [PATCH] c++/modules: fix up recent testcases
  2023-10-25 18:32 [PATCH] c++/modules: fix up recent testcases Patrick Palka
  2023-10-25 21:09 ` Nathan Sidwell
@ 2023-10-25 21:24 ` Jason Merrill
  1 sibling, 0 replies; 3+ messages in thread
From: Jason Merrill @ 2023-10-25 21:24 UTC (permalink / raw)
  To: Patrick Palka, gcc-patches; +Cc: nathan

On 10/25/23 14:32, Patrick Palka wrote:
> Tested on x86_64-pc-linux-gnu, does this look OK for trunk?
> 
> Declaring get() inline seems necessary to avoid link failure:
> 
>    /usr/bin/ld: /tmp/ccwdv6Co.o: in function `g3@pr105322.Decltype()':
>    decltype-1_b.C:(.text._ZW8pr105322W8Decltype2g3v[_ZW8pr105322W8Decltype2g3v]+0x18): undefined reference to `f@pr105322.Decltype()::A::get()'
> 
> Not sure if that's expected?

That seems like a bug.  My guess is that the bug is treating f()::A::get 
as internal linkage, but Nathan should have a better understanding of 
how it's supposed to work.

> -- >8 --
> 
> This fixes some minor issues with the testcases from
> r14-4806-g084addf8a700fa.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* g++.dg/modules/decltype-1_a.C: Add missing } to dg-module-do
> 	directive.  Declare f()::A::get() inline.
> 	* g++.dg/modules/lambda-5_a.C: Add missing } to dg-module-do
> 	directive.
> ---
>   gcc/testsuite/g++.dg/modules/decltype-1_a.C | 4 ++--
>   gcc/testsuite/g++.dg/modules/lambda-5_a.C   | 2 +-
>   2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/gcc/testsuite/g++.dg/modules/decltype-1_a.C b/gcc/testsuite/g++.dg/modules/decltype-1_a.C
> index ca66e8b598a..6512f151aae 100644
> --- a/gcc/testsuite/g++.dg/modules/decltype-1_a.C
> +++ b/gcc/testsuite/g++.dg/modules/decltype-1_a.C
> @@ -1,5 +1,5 @@
>   // PR c++/105322
> -// { dg-module-do link
> +// { dg-module-do link }
>   // { dg-additional-options -fmodules-ts }
>   // { dg-module-cmi pr105322.Decltype }
>   
> @@ -7,7 +7,7 @@ export module pr105322.Decltype;
>   
>   auto f() {
>     struct A { int m;
> -    int get () { return m; }
> +    inline int get () { return m; }
>     };
>     return A{};
>   }
> diff --git a/gcc/testsuite/g++.dg/modules/lambda-5_a.C b/gcc/testsuite/g++.dg/modules/lambda-5_a.C
> index 6b589d4965c..37d0e77b1e1 100644
> --- a/gcc/testsuite/g++.dg/modules/lambda-5_a.C
> +++ b/gcc/testsuite/g++.dg/modules/lambda-5_a.C
> @@ -1,5 +1,5 @@
>   // PR c++/105322
> -// { dg-module-do link
> +// { dg-module-do link }
>   // { dg-additional-options -fmodules-ts }
>   // { dg-module-cmi pr105322.Lambda }
>   


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

end of thread, other threads:[~2023-10-25 21:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-25 18:32 [PATCH] c++/modules: fix up recent testcases Patrick Palka
2023-10-25 21:09 ` Nathan Sidwell
2023-10-25 21:24 ` Jason Merrill

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).