diff mbox

C++ PATCH for c++/52906 (ICE with attribute by itself)

Message ID 4F85C409.6080305@redhat.com
State New
Headers show

Commit Message

Jason Merrill April 11, 2012, 5:48 p.m. UTC
We can't talk about the type if there is no type.

Tested x86_64-pc-linux-gnu, applying to trunk.

Comments

Jakub Jelinek April 11, 2012, 5:58 p.m. UTC | #1
On Wed, Apr 11, 2012 at 01:48:57PM -0400, Jason Merrill wrote:
> We can't talk about the type if there is no type.
> 
> Tested x86_64-pc-linux-gnu, applying to trunk.

Shouldn't this go to 4.7 too?

> commit bc94f519583cdfc705c1bde750a06bbd42537193
> Author: Jason Merrill <jason@redhat.com>
> Date:   Wed Apr 11 10:08:37 2012 -0400
> 
>     	PR c++/52906
>     	* decl.c (check_tag_decl): Don't complain about attributes if we
>     	don't even have a type.
> 
> diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
> index e2f01d5..8b22192 100644
> --- a/gcc/cp/decl.c
> +++ b/gcc/cp/decl.c
> @@ -4224,7 +4224,7 @@ check_tag_decl (cp_decl_specifier_seq *declspecs)
>          error ("%<constexpr%> cannot be used for type declarations");
>      }
>  
> -  if (declspecs->attributes && warn_attributes)
> +  if (declspecs->attributes && warn_attributes && declared_type)
>      {
>        location_t loc;
>        if (!CLASS_TYPE_P (declared_type)
> diff --git a/gcc/testsuite/g++.dg/ext/attrib45.C b/gcc/testsuite/g++.dg/ext/attrib45.C
> new file mode 100644
> index 0000000..0be1322
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/ext/attrib45.C
> @@ -0,0 +1,3 @@
> +// PR c++/52906
> +
> +__attribute__ ((__deprecated__)); // { dg-error "does not declare anything" }


	Jakub
diff mbox

Patch

commit bc94f519583cdfc705c1bde750a06bbd42537193
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Apr 11 10:08:37 2012 -0400

    	PR c++/52906
    	* decl.c (check_tag_decl): Don't complain about attributes if we
    	don't even have a type.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index e2f01d5..8b22192 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4224,7 +4224,7 @@  check_tag_decl (cp_decl_specifier_seq *declspecs)
         error ("%<constexpr%> cannot be used for type declarations");
     }
 
-  if (declspecs->attributes && warn_attributes)
+  if (declspecs->attributes && warn_attributes && declared_type)
     {
       location_t loc;
       if (!CLASS_TYPE_P (declared_type)
diff --git a/gcc/testsuite/g++.dg/ext/attrib45.C b/gcc/testsuite/g++.dg/ext/attrib45.C
new file mode 100644
index 0000000..0be1322
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/attrib45.C
@@ -0,0 +1,3 @@ 
+// PR c++/52906
+
+__attribute__ ((__deprecated__)); // { dg-error "does not declare anything" }