From 0d1d0dc8aa325982f4a07d79bce1a5b21e71d4ab Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 9 Jun 2011 15:06:59 +0000 Subject: [PATCH] re PR c++/29003 (operator name accepted in typedef) /cp 2011-06-09 Paolo Carlini PR c++/29003 * decl.c (grokdeclarator): Reject operator names in typedefs. /testsuite 2011-06-09 Paolo Carlini PR c++/29003 * g++.dg/parse/error38.C: New. From-SVN: r174846 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl.c | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/parse/error38.C | 3 +++ 4 files changed, 20 insertions(+) create mode 100644 gcc/testsuite/g++.dg/parse/error38.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2ffefaf15ba..df665d1f57f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2011-06-09 Paolo Carlini + + PR c++/29003 + * decl.c (grokdeclarator): Reject operator names in typedefs. + 2011-06-08 Jason Merrill PR c++/49107 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d7da3908154..a7447c3d6fe 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8441,6 +8441,13 @@ grokdeclarator (const cp_declarator *declarator, return error_mark_node; } + if (dname && IDENTIFIER_OPNAME_P (dname) + && declspecs->specs[(int)ds_typedef]) + { + error ("declaration of %qD as %", dname); + return error_mark_node; + } + /* Anything declared one level down from the top level must be one of the parameters of a function (because the body is at least two levels down). */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d2ebaf6ca6d..6bece5724ff 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-06-09 Paolo Carlini + + PR c++/29003 + * g++.dg/parse/error38.C: New. + 2011-06-09 Jakub Jelinek PR middle-end/49308 diff --git a/gcc/testsuite/g++.dg/parse/error38.C b/gcc/testsuite/g++.dg/parse/error38.C new file mode 100644 index 00000000000..63162a8ad84 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/error38.C @@ -0,0 +1,3 @@ +// PR c++/29003 + +typedef int operator !(); // { dg-error "declaration" } -- 2.30.2