aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2014-01-30 09:21:31 -0500
committerJason Merrill <jason@gcc.gnu.org>2014-01-30 09:21:31 -0500
commit404c2aeaae41097fd9f37c1ea74fb87cd1de6d27 (patch)
tree5a15d54643362248efd6d68a1ba93600967dfa32 /gcc
parentfc044323f492ebb6913398604104f293df99dbe3 (diff)
downloadgcc-404c2aeaae41097fd9f37c1ea74fb87cd1de6d27.zip
gcc-404c2aeaae41097fd9f37c1ea74fb87cd1de6d27.tar.gz
gcc-404c2aeaae41097fd9f37c1ea74fb87cd1de6d27.tar.bz2
re PR c++/59633 (ICE with __attribute((vector_size(...))) for enum)
PR c++/59633 gcc/ * tree.c (walk_type_fields): Handle VECTOR_TYPE. gcc/cp/ * decl2.c (attributes_naming_typedef_ok): New. * cp-tree.h: Declare it. * decl.c (grokdeclarator): Check it. * tree.c (no_linkage_check): Handle VECTOR_TYPE. From-SVN: r207302
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog3
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/decl.c1
-rw-r--r--gcc/cp/decl2.c16
-rw-r--r--gcc/cp/tree.c1
-rw-r--r--gcc/testsuite/g++.dg/ext/vector26.C8
-rw-r--r--gcc/tree.c1
8 files changed, 39 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e259b57..d571a8f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,8 @@
2014-01-30 Jason Merrill <jason@redhat.com>
+ PR c++/59633
+ * tree.c (walk_type_fields): Handle VECTOR_TYPE.
+
PR c++/59645
* cgraphunit.c (expand_thunk): Copy volatile arg to a temporary.
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 59f2b7e..037b4bd 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2014-01-30 Jason Merrill <jason@redhat.com>
+
+ PR c++/59633
+ * decl2.c (attributes_naming_typedef_ok): New.
+ * cp-tree.h: Declare it.
+ * decl.c (grokdeclarator): Check it.
+ * tree.c (no_linkage_check): Handle VECTOR_TYPE.
+
2014-01-29 Jason Merrill <jason@redhat.com>
PR c++/59707
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index ab75db8..7f46499 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -5296,6 +5296,7 @@ extern tree grokfield (const cp_declarator *, cp_decl_specifier_seq *,
extern tree grokbitfield (const cp_declarator *, cp_decl_specifier_seq *,
tree, tree);
extern tree cp_reconstruct_complex_type (tree, tree);
+extern bool attributes_naming_typedef_ok (tree);
extern void cplus_decl_attributes (tree *, tree, int);
extern void finish_anon_union (tree);
extern void cp_write_global_declarations (void);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index d7e5829..3652e8d 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -10216,6 +10216,7 @@ grokdeclarator (const cp_declarator *declarator,
&& TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
&& TYPE_ANONYMOUS_P (type)
&& declspecs->type_definition_p
+ && attributes_naming_typedef_ok (*attrlist)
&& cp_type_quals (type) == TYPE_UNQUALIFIED)
{
tree t;
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 58419ec..b2103c8 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1243,6 +1243,22 @@ save_template_attributes (tree *attr_p, tree *decl_p)
}
}
+/* Return true iff ATTRS are acceptable attributes to be applied in-place
+ to a typedef which gives a previously anonymous class or enum a name for
+ linkage purposes. */
+
+bool
+attributes_naming_typedef_ok (tree attrs)
+{
+ for (; attrs; attrs = TREE_CHAIN (attrs))
+ {
+ tree name = get_attribute_name (attrs);
+ if (is_attribute_p ("vector_size", name))
+ return false;
+ }
+ return true;
+}
+
/* Like reconstruct_complex_type, but handle also template trees. */
tree
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index ce41c3b..fe2ddab 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -2170,6 +2170,7 @@ no_linkage_check (tree t, bool relaxed_p)
case ARRAY_TYPE:
case POINTER_TYPE:
case REFERENCE_TYPE:
+ case VECTOR_TYPE:
return no_linkage_check (TREE_TYPE (t), relaxed_p);
case OFFSET_TYPE:
diff --git a/gcc/testsuite/g++.dg/ext/vector26.C b/gcc/testsuite/g++.dg/ext/vector26.C
new file mode 100644
index 0000000..6d55158
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/vector26.C
@@ -0,0 +1,8 @@
+// PR c++/59633
+// In C++98, the definition of bar is an error. In C++11, bar implicitly
+// gets internal linkage.
+
+typedef enum { e } T __attribute__((vector_size(8)));
+static void foo(T t) {}
+void bar (T t) {} // { dg-error "no linkage" "" { target c++98 } }
+// { dg-final { scan-assembler-not "globl\[ \t]*_Z3bar" } }
diff --git a/gcc/tree.c b/gcc/tree.c
index 5fdd491..1d06ba7 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -10817,6 +10817,7 @@ walk_type_fields (tree type, walk_tree_fn func, void *data,
{
case POINTER_TYPE:
case REFERENCE_TYPE:
+ case VECTOR_TYPE:
/* We have to worry about mutually recursive pointers. These can't
be written in C. They can in Ada. It's pathological, but
there's an ACATS test (c38102a) that checks it. Deal with this