aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDodji Seketeli <dseketel@redhat.com>2008-07-11 18:12:37 +0000
committerDodji Seketeli <dodji@gcc.gnu.org>2008-07-11 20:12:37 +0200
commit94eeabbe1999a998aa8fb64a86e794c77755d0df (patch)
treea0177fe10608323d2634279173ad1ff453c94508
parentec4d7730c818bb14591b9d0c82f92e73cadf27fb (diff)
downloadgcc-94eeabbe1999a998aa8fb64a86e794c77755d0df.zip
gcc-94eeabbe1999a998aa8fb64a86e794c77755d0df.tar.gz
gcc-94eeabbe1999a998aa8fb64a86e794c77755d0df.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog12
-rw-r--r--gcc/cp/decl.c26
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/g++.old-deja/g++.jason/crash11.C2
4 files changed, 31 insertions, 16 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c48fe96..7b73ee1 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,12 @@
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
* cp-tree.h (struct cp_decl_specifier_seq): add a location field. It
carries the location of the primary type.
@@ -13,7 +20,8 @@
cp_parser_type_specifier, cp_parser_simple_type_specifier,
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
* pt.c, semantic.c:
@@ -148,7 +156,7 @@
* pt.c: (tsubst_copy_and_build): Adjust.
(unify): Handle { }.
* name-lookup.c (arg_assoc_type): Handle init_list_type_node.
-
+
2008-07-01 Daniel Jacobowitz <dan@codesourcery.com>
* typeck.c (comp_ptr_ttypes_real): Use vector_targets_convertible_p.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index fc76ebe..83d2c4e 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -8005,19 +8005,6 @@ grokdeclarator (const cp_declarator *declarator,
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
&& ! toplevel_bindings_p ())
error ("nested function %qs declared %<extern%>", name);
@@ -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 &
and in case doing stupid register allocation. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9833a0f..cf57c77 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+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.
diff --git a/gcc/testsuite/g++.old-deja/g++.jason/crash11.C b/gcc/testsuite/g++.old-deja/g++.jason/crash11.C
index e88eb78..5cc8e5f 100644
--- a/gcc/testsuite/g++.old-deja/g++.jason/crash11.C
+++ b/gcc/testsuite/g++.old-deja/g++.jason/crash11.C
@@ -6,4 +6,4 @@ struct A {
};
const char foo[] = "bar";
const A a = { foo };
-extern const A* ap = &a;
+extern const A* ap = &a; //{ dg-warning "warning: 'ap' initialized and declared 'extern'" }