From: Paolo Carlini Date: Wed, 12 Dec 2018 21:36:26 +0000 (+0000) Subject: decl.c (grokdeclarator): Fix location of error message about static data member defin... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=77a242860085d70b33d12302ca8c729f0c060905;p=gcc.git decl.c (grokdeclarator): Fix location of error message about static data member definition. /cp 2018-12-12 Paolo Carlini * decl.c (grokdeclarator): Fix location of error message about static data member definition. /testsuite 2018-12-12 Paolo Carlini * g++.dg/other/static5.C: New. From-SVN: r267066 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2c1f39288c4..a32e1d05491 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-12-12 Paolo Carlini + + * decl.c (grokdeclarator): Fix location of error message about + static data member definition. + 2018-12-12 Jakub Jelinek PR c++/88446 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 9b0ea702ec4..5435ef2c824 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -12724,7 +12724,8 @@ grokdeclarator (const cp_declarator *declarator, DECL_CONTEXT (decl) = ctype; if (staticp == 1) { - permerror (input_location, "% may not be used when defining " + permerror (declspecs->locations[ds_storage_class], + "% may not be used when defining " "(as opposed to declaring) a static data member"); staticp = 0; storage_class = sc_none; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2fbf69c3067..856dfdf8d45 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2018-12-12 Paolo Carlini + + * g++.dg/other/static5.C: New. + 2018-12-12 Segher Boessenkool PR testsuite/88318 diff --git a/gcc/testsuite/g++.dg/other/static5.C b/gcc/testsuite/g++.dg/other/static5.C new file mode 100644 index 00000000000..007b7c398d1 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/static5.C @@ -0,0 +1,8 @@ +struct S +{ + static int i; + const static double d; +}; + +static int S::i; // { dg-error "1:.static. may not be used" } +const static double S::d = 1.0; // { dg-error "7:.static. may not be used" }