Commit 94eeabbe by Dodji Seketeli Committed by Dodji Seketeli

re PR c++/13101 (incorrect warning on initialized extern const function pointer)

2008-07-11  Dodji Seketeli  <dseketel@redhat.com>

	PR c++/13101
	* decl.c (grokdeclarator): Warn about initializing variables
	  of storage class 'extern' only after the type of the declarator
	  has been properly computed.

From-SVN: r137723
parent ec4d7730
2008-07-11 Dodji Seketeli <dseketel@redhat.com> 2008-07-11 Dodji Seketeli <dseketel@redhat.com>
PR c++/13101
* decl.c (grokdeclarator): Warn about initializing variables
of storage class 'extern' only after the type of the declarator
has been properly computed.
2008-07-11 Dodji Seketeli <dseketel@redhat.com>
PR c++/31754 PR c++/31754
* cp-tree.h (struct cp_decl_specifier_seq): add a location field. It * cp-tree.h (struct cp_decl_specifier_seq): add a location field. It
carries the location of the primary type. carries the location of the primary type.
...@@ -13,7 +20,8 @@ ...@@ -13,7 +20,8 @@
cp_parser_type_specifier, cp_parser_simple_type_specifier, cp_parser_type_specifier, cp_parser_simple_type_specifier,
cp_parser_omp_for_loop, cp_parser_pragma): use location in error messages. cp_parser_omp_for_loop, cp_parser_pragma): use location in error messages.
2008-06-30 Dodji Seketeli <dseketel@redhat.com>
2008-07-11 Dodji Seketeli <dseketel@redhat.com>
PR c++/31754 PR c++/31754
* pt.c, semantic.c: * pt.c, semantic.c:
......
...@@ -8005,19 +8005,6 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -8005,19 +8005,6 @@ grokdeclarator (const cp_declarator *declarator,
storage_class = sc_none; storage_class = sc_none;
} }
} }
else if (storage_class == sc_extern && initialized
&& !funcdef_flag)
{
if (toplevel_bindings_p ())
{
/* It's common practice (and completely valid) to have a const
be initialized and declared extern. */
if (!(type_quals & TYPE_QUAL_CONST))
warning (0, "%qs initialized and declared %<extern%>", name);
}
else
error ("%qs has both %<extern%> and initializer", name);
}
else if (storage_class == sc_extern && funcdef_flag else if (storage_class == sc_extern && funcdef_flag
&& ! toplevel_bindings_p ()) && ! toplevel_bindings_p ())
error ("nested function %qs declared %<extern%>", name); error ("nested function %qs declared %<extern%>", name);
...@@ -9236,6 +9223,19 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -9236,6 +9223,19 @@ grokdeclarator (const cp_declarator *declarator,
} }
} }
if (storage_class == sc_extern && initialized && !funcdef_flag)
{
if (toplevel_bindings_p ())
{
/* It's common practice (and completely valid) to have a const
be initialized and declared extern. */
if (!(type_quals & TYPE_QUAL_CONST))
warning (0, "%qs initialized and declared %<extern%>", name);
}
else
error ("%qs has both %<extern%> and initializer", name);
}
/* Record `register' declaration for warnings on & /* Record `register' declaration for warnings on &
and in case doing stupid register allocation. */ and in case doing stupid register allocation. */
......
2008-07-11 Dodji Seketeli <dseketel@redhat.com> 2008-07-11 Dodji Seketeli <dseketel@redhat.com>
PR c++/13101
* g++.dg/parse/func-ptr-decl.C: New test.
* gcc/testsuite/g++.old-deja/g++.jason/crash11.C: Update this to
catch a warning that is generated by virtue of fixing this bug.
2008-07-11 Dodji Seketeli <dseketel@redhat.com>
* g++.dg/other/semicolon.C: Tighten this test, making it column aware. * g++.dg/other/semicolon.C: Tighten this test, making it column aware.
* g++.dg/parse/error15.C: update this because of more accurate column * g++.dg/parse/error15.C: update this because of more accurate column
numbers in error reporting. numbers in error reporting.
......
...@@ -6,4 +6,4 @@ struct A { ...@@ -6,4 +6,4 @@ struct A {
}; };
const char foo[] = "bar"; const char foo[] = "bar";
const A a = { foo }; const A a = { foo };
extern const A* ap = &a; extern const A* ap = &a; //{ dg-warning "warning: 'ap' initialized and declared 'extern'" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment