+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
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);
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)
{
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. */
TREE_PUBLIC (decl) = (declspecs->storage_class != sc_static
&& (DECL_THIS_EXTERN (decl)
|| ! constp
+ || volatilep
|| inlinep));
TREE_STATIC (decl) = ! DECL_EXTERNAL (decl);
}
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)
+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.
--- /dev/null
+/* 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 ();
+}
--- /dev/null
+/* 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;