+2013-07-09 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/51786
+ * parser.c (cp_parser_simple_declaration): Before calling shadow_tag
+ also check declares_class_or_enum.
+
2013-07-08 Jason Merrill <jason@redhat.com>
PR c++/57550
/* Issue an error message if no declarators are present, and the
decl-specifier-seq does not itself declare a class or
- enumeration. */
+ enumeration: [dcl.dcl]/3. */
if (!saw_declarator)
{
if (cp_parser_declares_only_class_p (parser))
- shadow_tag (&decl_specifiers);
+ {
+ if (!declares_class_or_enum
+ && decl_specifiers.type
+ && OVERLOAD_TYPE_P (decl_specifiers.type))
+ /* Ensure an error is issued anyway when finish_decltype_type,
+ called via cp_parser_decl_specifier_seq, returns a class or
+ an enumeration (c++/51786). */
+ decl_specifiers.type = NULL_TREE;
+ shadow_tag (&decl_specifiers);
+ }
/* Perform any deferred access checks. */
perform_deferred_access_checks (tf_warning_or_error);
}
+2013-07-09 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/51786
+ * g++.dg/cpp0x/pr51786.C: New.
+
2013-07-08 Janis Johnson <janisjo@codesourcery.com>
* gcc.target/powerpc/tfmode_off.c: Skip for EABI targets.
--- /dev/null
+// PR c++/51786
+// { dg-do compile { target c++11 } }
+
+enum E {};
+struct A {};
+
+void foo() { decltype(E{}); } // { dg-error "does not declare anything" }
+void bar() { decltype(A{}); } // { dg-error "does not declare anything" }