DR 1511 - const volatile variables and ODR
DR 1511 - const volatile variables and ODR * decl.c (grokvardecl): Change flags argument to type_quals, add conceptp argument. Set TREE_PUBLIC for non-static volatile vars. (grokdeclarator): Adjust grokvardecl caller. * g++.dg/DRs/dr1511-1.C: New test. * g++.dg/DRs/dr1511-2.C: New test. From-SVN: r241176
This commit is contained in:
parent
2579762a4b
commit
064ed55a66
@ -1,3 +1,10 @@
|
||||
2016-10-14 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
DR 1511 - const volatile variables and ODR
|
||||
* decl.c (grokvardecl): Change flags argument to type_quals,
|
||||
add conceptp argument. Set TREE_PUBLIC for non-static volatile vars.
|
||||
(grokdeclarator): Adjust grokvardecl caller.
|
||||
|
||||
2016-10-13 Martin Sebor <msebor@redhat.com>
|
||||
|
||||
PR c++/71912
|
||||
|
@ -68,7 +68,7 @@ static int unary_op_p (enum tree_code);
|
||||
static void push_local_name (tree);
|
||||
static tree grok_reference_init (tree, tree, tree, int);
|
||||
static tree grokvardecl (tree, tree, tree, const cp_decl_specifier_seq *,
|
||||
int, int, int, int, tree);
|
||||
int, int, int, bool, int, tree);
|
||||
static int check_static_variable_definition (tree, tree);
|
||||
static void record_unknown_type (tree, const char *);
|
||||
static tree builtin_function_1 (tree, tree, bool);
|
||||
@ -8512,8 +8512,9 @@ grokvardecl (tree type,
|
||||
tree orig_declarator,
|
||||
const cp_decl_specifier_seq *declspecs,
|
||||
int initialized,
|
||||
int flags,
|
||||
int type_quals,
|
||||
int inlinep,
|
||||
bool conceptp,
|
||||
int template_count,
|
||||
tree scope)
|
||||
{
|
||||
@ -8522,8 +8523,8 @@ grokvardecl (tree type,
|
||||
|
||||
gcc_assert (!name || identifier_p (name));
|
||||
|
||||
bool constp = flags&1;
|
||||
bool conceptp = flags&2;
|
||||
bool constp = (type_quals & TYPE_QUAL_CONST) != 0;
|
||||
bool volatilep = (type_quals & TYPE_QUAL_VOLATILE) != 0;
|
||||
|
||||
/* Compute the scope in which to place the variable, but remember
|
||||
whether or not that scope was explicitly specified by the user. */
|
||||
@ -8580,6 +8581,7 @@ grokvardecl (tree type,
|
||||
TREE_PUBLIC (decl) = (declspecs->storage_class != sc_static
|
||||
&& (DECL_THIS_EXTERN (decl)
|
||||
|| ! constp
|
||||
|| volatilep
|
||||
|| inlinep));
|
||||
TREE_STATIC (decl) = ! DECL_EXTERNAL (decl);
|
||||
}
|
||||
@ -11626,8 +11628,9 @@ grokdeclarator (const cp_declarator *declarator,
|
||||
decl = grokvardecl (type, dname, unqualified_id,
|
||||
declspecs,
|
||||
initialized,
|
||||
((type_quals & TYPE_QUAL_CONST) != 0) | (2 * concept_p),
|
||||
type_quals,
|
||||
inlinep,
|
||||
concept_p,
|
||||
template_count,
|
||||
ctype ? ctype : in_namespace);
|
||||
if (decl == NULL_TREE)
|
||||
|
@ -1,3 +1,9 @@
|
||||
2016-10-14 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
DR 1511 - const volatile variables and ODR
|
||||
* g++.dg/DRs/dr1511-1.C: New test.
|
||||
* g++.dg/DRs/dr1511-2.C: New test.
|
||||
|
||||
2016-10-14 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
* gnat.dg/debug7.adb (dg-options): Remove -g.
|
||||
|
38
gcc/testsuite/g++.dg/DRs/dr1511-1.C
Normal file
38
gcc/testsuite/g++.dg/DRs/dr1511-1.C
Normal file
@ -0,0 +1,38 @@
|
||||
/* DR 1511 - const volatile variables and the one-definition rule */
|
||||
/* { dg-do run } */
|
||||
/* { dg-additional-sources "dr1511-2.C" } */
|
||||
|
||||
typedef const int cint;
|
||||
typedef const volatile int cvint;
|
||||
typedef volatile int vint;
|
||||
const int v1 = 5;
|
||||
extern volatile const int v2;
|
||||
cint v3 = 7;
|
||||
extern cvint v4;
|
||||
extern const vint v5;
|
||||
extern volatile cint v6;
|
||||
const int w1 = 5;
|
||||
extern volatile const int w2;
|
||||
cint w3 = 7;
|
||||
extern cvint w4;
|
||||
extern const vint w5;
|
||||
extern volatile cint w6;
|
||||
extern const int &r1;
|
||||
extern volatile const int &r2;
|
||||
extern const int &r3;
|
||||
extern const volatile int &r4;
|
||||
extern const volatile int &r5;
|
||||
extern const volatile int &r6;
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
if (v1 != 5 || v2 != 6 || v3 != 7 || v4 != 8 || v5 != 9 || v6 != 10)
|
||||
__builtin_abort ();
|
||||
if (w1 != 5 || w2 != 6 || w3 != 7 || w4 != 8 || w5 != 9 || w6 != 10)
|
||||
__builtin_abort ();
|
||||
if (r1 != w1 || &r1 == &w1 || r2 != w2 || &r2 != &w2 || r3 != w3 || &r3 == &w3)
|
||||
__builtin_abort ();
|
||||
if (r4 != w4 || &r4 != &w4 || r5 != w5 || &r5 != &w5 || r6 != w6 || &r6 != &w6)
|
||||
__builtin_abort ();
|
||||
}
|
24
gcc/testsuite/g++.dg/DRs/dr1511-2.C
Normal file
24
gcc/testsuite/g++.dg/DRs/dr1511-2.C
Normal file
@ -0,0 +1,24 @@
|
||||
/* DR 1511 - const volatile variables and the one-definition rule */
|
||||
/* { dg-do compile } */
|
||||
|
||||
typedef const int cint;
|
||||
typedef const volatile int cvint;
|
||||
typedef volatile int vint;
|
||||
const int v1 = 5;
|
||||
volatile const int v2 = 6;
|
||||
cint v3 = 7;
|
||||
cvint v4 = 8;
|
||||
const vint v5 = 9;
|
||||
volatile cint v6 = 10;
|
||||
const int w1 = 5;
|
||||
volatile const int w2 = 6;
|
||||
cint w3 = 7;
|
||||
cvint w4 = 8;
|
||||
const vint w5 = 9;
|
||||
volatile cint w6 = 10;
|
||||
const int &r1 = w1;
|
||||
volatile const int &r2 = w2;
|
||||
const int &r3 = w3;
|
||||
const volatile int &r4 = w4;
|
||||
const volatile int &r5 = w5;
|
||||
const volatile int &r6 = w6;
|
Loading…
Reference in New Issue
Block a user