mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-23 10:54:07 +08:00
c++: inline variables and modules
We weren't writing out the definition of an inline variable, so the importer either got an undefined symbol or 0. gcc/cp/ChangeLog: * module.cc (has_definition): Also true for inline vars. gcc/testsuite/ChangeLog: * g++.dg/modules/inline-1_a.C: New test. * g++.dg/modules/inline-1_b.C: New test.
This commit is contained in:
parent
74498be0e6
commit
819f67a2f6
@ -11919,7 +11919,8 @@ has_definition (tree decl)
|
||||
since there's no TU to emit them in otherwise. */
|
||||
return true;
|
||||
|
||||
if (!decl_maybe_constant_var_p (decl))
|
||||
if (!decl_maybe_constant_var_p (decl)
|
||||
&& !DECL_INLINE_VAR_P (decl))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
11
gcc/testsuite/g++.dg/modules/inline-1_a.C
Normal file
11
gcc/testsuite/g++.dg/modules/inline-1_a.C
Normal file
@ -0,0 +1,11 @@
|
||||
// { dg-additional-options -fmodules }
|
||||
// { dg-module-do run }
|
||||
export module M;
|
||||
|
||||
inline int b = 42;
|
||||
struct A
|
||||
{
|
||||
static inline int a = 4200;
|
||||
};
|
||||
|
||||
export inline int f() { return b+A::a; }
|
8
gcc/testsuite/g++.dg/modules/inline-1_b.C
Normal file
8
gcc/testsuite/g++.dg/modules/inline-1_b.C
Normal file
@ -0,0 +1,8 @@
|
||||
// { dg-additional-options -fmodules }
|
||||
import M;
|
||||
|
||||
int main()
|
||||
{
|
||||
if (f() != 4242)
|
||||
__builtin_abort ();
|
||||
}
|
Loading…
Reference in New Issue
Block a user