aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2011-11-08 10:27:34 +0000
committerDodji Seketeli <dodji@gcc.gnu.org>2011-11-08 11:27:34 +0100
commit7d29c953afdd7232bf34cb40eaf28511692b3e77 (patch)
treeed6788aec0d242532fa9ce54ad04936c2ec78e50 /gcc
parent7fcefa55251f44ce3933fd4709f23d1b83accdf8 (diff)
downloadgcc-7d29c953afdd7232bf34cb40eaf28511692b3e77.zip
gcc-7d29c953afdd7232bf34cb40eaf28511692b3e77.tar.gz
gcc-7d29c953afdd7232bf34cb40eaf28511692b3e77.tar.bz2
Fix context handling of alias-declaration
gcc/cp/ * decl.c (start_decl): Update comment. * error.c (dump_alias_template_specialization): Dump the context of the specialization. * parser.c (cp_parser_alias_declaration): Call pop_scope on the pushed scope yielded by start_decl. gcc/testsuite * g++.dg/cpp0x/alias-decl-11.C: New test. From-SVN: r181152
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/decl.c7
-rw-r--r--gcc/cp/error.c2
-rw-r--r--gcc/cp/parser.c7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/alias-decl-11.C8
6 files changed, 34 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5a492e9..bcdecdf 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2011-11-08 Dodji Seketeli <dodji@redhat.com>
+
+ Fix context handling of alias-declaration
+ * decl.c (start_decl): Update comment.
+ * error.c (dump_alias_template_specialization): Dump the context
+ of the specialization.
+ * parser.c (cp_parser_alias_declaration): Call pop_scope on the
+ pushed scope yielded by start_decl.
+
2011-11-08 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/50864
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index e4b91cc..1c33776 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4295,8 +4295,11 @@ groktypename (cp_decl_specifier_seq *type_specifiers,
deleted function, but 0 (SD_UNINITIALIZED) if this is a variable
implicitly initialized via a default constructor. ATTRIBUTES and
PREFIX_ATTRIBUTES are GNU attributes associated with this declaration.
- *PUSHED_SCOPE_P is set to the scope entered in this function, if any; if
- set, the caller is responsible for calling pop_scope. */
+
+ The scope represented by the context of the returned DECL is pushed
+ (if it is not the global namespace) and is assigned to
+ *PUSHED_SCOPE_P. The caller is then responsible for calling
+ pop_scope on *PUSHED_SCOPE_P if it is set. */
tree
start_decl (const cp_declarator *declarator,
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 841366f..d2b6a62 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -341,6 +341,8 @@ dump_alias_template_specialization (tree t, int flags)
gcc_assert (alias_template_specialization_p (t));
+ if (!(flags & TFF_UNQUALIFIED_NAME))
+ dump_scope (CP_DECL_CONTEXT (TYPE_NAME (t)), flags);
name = TYPE_IDENTIFIER (t);
pp_cxx_tree_identifier (cxx_pp, name);
dump_template_parms (TYPE_TEMPLATE_INFO (t),
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 7d04971..3d35877 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -14891,7 +14891,7 @@ cp_parser_using_declaration (cp_parser* parser,
static tree
cp_parser_alias_declaration (cp_parser* parser)
{
- tree id, type, decl, dummy, attributes;
+ tree id, type, decl, pushed_scope = NULL_TREE, attributes;
location_t id_location;
cp_declarator *declarator;
cp_decl_specifier_seq decl_specs;
@@ -14925,12 +14925,15 @@ cp_parser_alias_declaration (cp_parser* parser)
NULL_TREE, attributes);
else
decl = start_decl (declarator, &decl_specs, 0,
- attributes, NULL_TREE, &dummy);
+ attributes, NULL_TREE, &pushed_scope);
if (decl == error_mark_node)
return decl;
cp_finish_decl (decl, NULL_TREE, 0, NULL_TREE, 0);
+ if (pushed_scope)
+ pop_scope (pushed_scope);
+
/* If decl is a template, return its TEMPLATE_DECL so that it gets
added into the symbol table; otherwise, return the TYPE_DECL. */
if (DECL_LANG_SPECIFIC (decl)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 12ad3d4..a62b11c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2011-11-08 Dodji Seketeli <dodji@redhat.com>
+
+ Fix context handling of alias-declaration
+ * g++.dg/cpp0x/alias-decl-11.C: New test.
+
2011-11-08 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/50864
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-11.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-11.C
new file mode 100644
index 0000000..43ef7ba
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-11.C
@@ -0,0 +1,8 @@
+// { dg-options "-std=c++0x" }
+
+namespace N
+{
+ template <class T> using U = T*;
+};
+
+void f(N::U<int>) { blah; } // { dg-error "void f(N::U<int>)|not declared" }