diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2014-08-25 08:32:04 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2014-08-25 08:32:04 +0000 |
commit | 985acf5a0ac506f6df453475d0bfd7466ad392d5 (patch) | |
tree | e33f8a7749a7fbd62dcf2839192eb89550037785 | |
parent | 028aee171abc1b13e97734bac4a3db46743d7a6b (diff) | |
download | gcc-985acf5a0ac506f6df453475d0bfd7466ad392d5.zip gcc-985acf5a0ac506f6df453475d0bfd7466ad392d5.tar.gz gcc-985acf5a0ac506f6df453475d0bfd7466ad392d5.tar.bz2 |
re PR c++/34938 (ICE with function pointers and attribute noreturn)
/cp
2014-08-25 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/34938
* cp-tree.h (TFF_POINTER): Add.
* cxx-pretty-print.h (pp_cxx_cv_qualifiers): Forward the third
argument too.
* error.c (dump_type_suffix): Actually print the const and noreturn
attribute when appropriate.
/testsuite
2014-08-25 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/34938
* g++.dg/template/pr34938-1.C: New.
* g++.dg/template/pr34938-2.C: Likewise.
From-SVN: r214415
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 4 | ||||
-rw-r--r-- | gcc/cp/cxx-pretty-print.h | 4 | ||||
-rw-r--r-- | gcc/cp/error.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/pr34938-1.C | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/pr34938-2.C | 10 |
7 files changed, 42 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e770ab0..18a281b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2014-08-25 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/34938 + * cp-tree.h (TFF_POINTER): Add. + * cxx-pretty-print.h (pp_cxx_cv_qualifiers): Forward the third + argument too. + * error.c (dump_type_suffix): Actually print the const and noreturn + attribute when appropriate. + 2014-08-23 Edward Smith-Rowland <3dw4rd@verizon.net> * decl.c (compute_array_index_type, grokdeclarator, diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 5d4df6b..43818cd 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4728,7 +4728,8 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, TYPENAME_FLAG }; TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS: do not omit template arguments identical to their defaults. TFF_NO_TEMPLATE_BINDINGS: do not print information about the template - arguments for a function template specialization. */ + arguments for a function template specialization. + TFF_POINTER: we are printing a pointer type. */ #define TFF_PLAIN_IDENTIFIER (0) #define TFF_SCOPE (1) @@ -4745,6 +4746,7 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, TYPENAME_FLAG }; #define TFF_UNQUALIFIED_NAME (1 << 11) #define TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS (1 << 12) #define TFF_NO_TEMPLATE_BINDINGS (1 << 13) +#define TFF_POINTER (1 << 14) /* Returns the TEMPLATE_DECL associated to a TEMPLATE_TEMPLATE_PARM node. */ diff --git a/gcc/cp/cxx-pretty-print.h b/gcc/cp/cxx-pretty-print.h index 2dc3f95..9bdd4b6 100644 --- a/gcc/cp/cxx-pretty-print.h +++ b/gcc/cp/cxx-pretty-print.h @@ -59,8 +59,8 @@ struct cxx_pretty_printer : c_pretty_printer #define pp_cxx_cv_qualifier_seq(PP, T) \ pp_c_type_qualifier_list (PP, T) -#define pp_cxx_cv_qualifiers(PP, CV) \ - pp_c_cv_qualifiers (PP, CV, false) +#define pp_cxx_cv_qualifiers(PP, CV, FT) \ + pp_c_cv_qualifiers (PP, CV, FT) #define pp_cxx_whitespace(PP) pp_c_whitespace (PP) #define pp_cxx_left_paren(PP) pp_c_left_paren (PP) diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 9f0498d..86fd405 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -820,6 +820,8 @@ dump_type_suffix (cxx_pretty_printer *pp, tree t, int flags) if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE || TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE) pp_cxx_right_paren (pp); + if (TREE_CODE (t) == POINTER_TYPE) + flags |= TFF_POINTER; dump_type_suffix (pp, TREE_TYPE (t), flags); break; @@ -839,7 +841,9 @@ dump_type_suffix (cxx_pretty_printer *pp, tree t, int flags) dump_parameters (pp, arg, flags & ~TFF_FUNCTION_DEFAULT_ARGUMENTS); pp->padding = pp_before; - pp_cxx_cv_qualifiers (pp, type_memfn_quals (t)); + pp_cxx_cv_qualifiers (pp, type_memfn_quals (t), + TREE_CODE (t) == FUNCTION_TYPE + && (flags & TFF_POINTER)); dump_ref_qualifier (pp, t, flags); dump_exception_spec (pp, TYPE_RAISES_EXCEPTIONS (t), flags); dump_type_suffix (pp, TREE_TYPE (t), flags); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 82e1047..eb06e0b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-08-25 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/34938 + * g++.dg/template/pr34938-1.C: New. + * g++.dg/template/pr34938-2.C: Likewise. + 2014-08-24 Oleg Endo <olegendo@gcc.gnu.org> PR target/61996 diff --git a/gcc/testsuite/g++.dg/template/pr34938-1.C b/gcc/testsuite/g++.dg/template/pr34938-1.C new file mode 100644 index 0000000..f23a5a3 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr34938-1.C @@ -0,0 +1,7 @@ +// PR c++/34938 + +typedef void (*fptr)() __attribute((noreturn)); +template<int> void foo(); +template<fptr> void bar(); + +fptr f = bar< foo<0> >; // { dg-error "noreturn" } diff --git a/gcc/testsuite/g++.dg/template/pr34938-2.C b/gcc/testsuite/g++.dg/template/pr34938-2.C new file mode 100644 index 0000000..fe7650f --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr34938-2.C @@ -0,0 +1,10 @@ +// PR c++/34938 + +template <class T> struct A { }; +struct B { }; + +A<void()const>* p1 = 42; // { dg-error "void\\(\\) const" } +A<void(B::*)()const>* p2 = 42; // { dg-error "void \\(B::\\*\\)\\(\\) const" } + +A<void()volatile>* p3 = 42; // { dg-error "void\\(\\) volatile" } +A<void(B::*)()volatile>* p4 = 42; // { dg-error "void \\(B::\\*\\)\\(\\) volatile" } |