public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104197] New: clang: gcc/cp/pt.cc:28481:19: warning: predefined identifier is only valid inside function [-Wpredefined-identifier-outside-function]
@ 2022-01-24 7:59 marxin at gcc dot gnu.org
2022-01-24 8:20 ` [Bug c++/104197] " pinskia at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-01-24 7:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104197
Bug ID: 104197
Summary: clang: gcc/cp/pt.cc:28481:19: warning: predefined
identifier is only valid inside function
[-Wpredefined-identifier-outside-function]
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: marxin at gcc dot gnu.org
CC: ppalka at gcc dot gnu.org
Target Milestone: ---
I noticed the following new warning by clang:
/home/marxin/Programming/gcc/gcc/cp/pt.cc:28481:19: warning: predefined
identifier is only valid inside function
[-Wpredefined-identifier-outside-function]
int level = current_template_depth + 1)
^
/home/marxin/Programming/gcc/gcc/cp/cp-tree.h:1903:29: note: expanded from
macro 'current_template_depth'
(current_template_parms ? TMPL_PARMS_DEPTH (current_template_parms) : 0)
^
/home/marxin/Programming/gcc/gcc/cp/cp-tree.h:3802:38: note: expanded from
macro 'TMPL_PARMS_DEPTH'
((HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_PURPOSE (NODE)))
^
/home/marxin/Programming/gcc/gcc/tree.h:1098:29: note: expanded from macro
'TREE_PURPOSE'
#define TREE_PURPOSE(NODE) (TREE_LIST_CHECK (NODE)->list.purpose)
^
./tree-check.h:8:28: note: expanded from macro 'TREE_LIST_CHECK'
#define TREE_LIST_CHECK(t) TREE_CHECK (t, TREE_LIST)
^
/home/marxin/Programming/gcc/gcc/tree.h:252:39: note: expanded from macro
'TREE_CHECK'
(tree_check ((T), __FILE__, __LINE__, __FUNCTION__, (CODE)))
^
Is it something we should care about, or is it a false alarm?
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/104197] clang: gcc/cp/pt.cc:28481:19: warning: predefined identifier is only valid inside function [-Wpredefined-identifier-outside-function]
2022-01-24 7:59 [Bug c++/104197] New: clang: gcc/cp/pt.cc:28481:19: warning: predefined identifier is only valid inside function [-Wpredefined-identifier-outside-function] marxin at gcc dot gnu.org
@ 2022-01-24 8:20 ` pinskia at gcc dot gnu.org
2022-01-24 8:23 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-24 8:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104197
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So the error message comes from the following:
int tree_check(int, int, const char*);
int g(int t = tree_check(1, 1, __FUNCTION__));
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/104197] clang: gcc/cp/pt.cc:28481:19: warning: predefined identifier is only valid inside function [-Wpredefined-identifier-outside-function]
2022-01-24 7:59 [Bug c++/104197] New: clang: gcc/cp/pt.cc:28481:19: warning: predefined identifier is only valid inside function [-Wpredefined-identifier-outside-function] marxin at gcc dot gnu.org
2022-01-24 8:20 ` [Bug c++/104197] " pinskia at gcc dot gnu.org
@ 2022-01-24 8:23 ` pinskia at gcc dot gnu.org
2022-01-24 8:23 ` [Bug c++/104197] [12 Regression] " pinskia at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-24 8:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104197
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |build, internal-improvement
Status|UNCONFIRMED |NEW
Last reconfirmed| |2022-01-24
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=30811
Ever confirmed|0 |1
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Found the bug which talks about how we should be rejecting this PR 30811.
So this is a correct warning which we should deal with.
Confirmed.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/104197] [12 Regression] clang: gcc/cp/pt.cc:28481:19: warning: predefined identifier is only valid inside function [-Wpredefined-identifier-outside-function]
2022-01-24 7:59 [Bug c++/104197] New: clang: gcc/cp/pt.cc:28481:19: warning: predefined identifier is only valid inside function [-Wpredefined-identifier-outside-function] marxin at gcc dot gnu.org
2022-01-24 8:20 ` [Bug c++/104197] " pinskia at gcc dot gnu.org
2022-01-24 8:23 ` pinskia at gcc dot gnu.org
@ 2022-01-24 8:23 ` pinskia at gcc dot gnu.org
2022-01-24 8:30 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-24 8:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104197
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |12.0
Summary|clang: |[12 Regression] clang:
|gcc/cp/pt.cc:28481:19: |gcc/cp/pt.cc:28481:19:
|warning: predefined |warning: predefined
|identifier is only valid |identifier is only valid
|inside function |inside function
|[-Wpredefined-identifier-ou |[-Wpredefined-identifier-ou
|tside-function] |tside-function]
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/104197] [12 Regression] clang: gcc/cp/pt.cc:28481:19: warning: predefined identifier is only valid inside function [-Wpredefined-identifier-outside-function]
2022-01-24 7:59 [Bug c++/104197] New: clang: gcc/cp/pt.cc:28481:19: warning: predefined identifier is only valid inside function [-Wpredefined-identifier-outside-function] marxin at gcc dot gnu.org
` (2 preceding siblings ...)
2022-01-24 8:23 ` [Bug c++/104197] [12 Regression] " pinskia at gcc dot gnu.org
@ 2022-01-24 8:30 ` pinskia at gcc dot gnu.org
2022-01-24 8:32 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-24 8:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104197
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Something like this will fix the warning:
apinski@xeond:~/src/upstream-gcc-git/gcc/gcc/cp$ git diff
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index bba62a5800a..33969fc646c 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -28477,9 +28477,13 @@ make_args_non_dependent (vec<tree, va_gc> *args)
by default. If set_canonical is true, we set TYPE_CANONICAL on it. */
static tree
-make_auto_1 (tree name, bool set_canonical,
- int level = current_template_depth + 1)
+make_auto_1 (tree name, bool set_canonical, bool level0 = false)
{
+ int level;
+ if (!level0)
+ level = current_template_depth + 1;
+ else
+ level = 0;
tree au = cxx_make_type (TEMPLATE_TYPE_PARM);
TYPE_NAME (au) = build_decl (input_location, TYPE_DECL, name, au);
TYPE_STUB_DECL (au) = TYPE_NAME (au);
@@ -28514,7 +28518,7 @@ make_auto (void)
tree
make_template_placeholder (tree tmpl)
{
- tree t = make_auto_1 (auto_identifier, false, /*level=*/0);
+ tree t = make_auto_1 (auto_identifier, false, /*level0=*/true);
CLASS_PLACEHOLDER_TEMPLATE (t) = tmpl;
/* Our canonical type depends on the placeholder. */
TYPE_CANONICAL (t) = canonical_type_parameter (t);
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/104197] [12 Regression] clang: gcc/cp/pt.cc:28481:19: warning: predefined identifier is only valid inside function [-Wpredefined-identifier-outside-function]
2022-01-24 7:59 [Bug c++/104197] New: clang: gcc/cp/pt.cc:28481:19: warning: predefined identifier is only valid inside function [-Wpredefined-identifier-outside-function] marxin at gcc dot gnu.org
` (3 preceding siblings ...)
2022-01-24 8:30 ` pinskia at gcc dot gnu.org
@ 2022-01-24 8:32 ` pinskia at gcc dot gnu.org
2022-01-24 9:25 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-24 8:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104197
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I should mention the use of __FUNCTION__ inside the default argument is
rejected by MSVC which is why I have marked it as a build failure.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/104197] [12 Regression] clang: gcc/cp/pt.cc:28481:19: warning: predefined identifier is only valid inside function [-Wpredefined-identifier-outside-function]
2022-01-24 7:59 [Bug c++/104197] New: clang: gcc/cp/pt.cc:28481:19: warning: predefined identifier is only valid inside function [-Wpredefined-identifier-outside-function] marxin at gcc dot gnu.org
` (4 preceding siblings ...)
2022-01-24 8:32 ` pinskia at gcc dot gnu.org
@ 2022-01-24 9:25 ` rguenth at gcc dot gnu.org
2022-01-24 14:33 ` ppalka at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-24 9:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104197
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/104197] [12 Regression] clang: gcc/cp/pt.cc:28481:19: warning: predefined identifier is only valid inside function [-Wpredefined-identifier-outside-function]
2022-01-24 7:59 [Bug c++/104197] New: clang: gcc/cp/pt.cc:28481:19: warning: predefined identifier is only valid inside function [-Wpredefined-identifier-outside-function] marxin at gcc dot gnu.org
` (5 preceding siblings ...)
2022-01-24 9:25 ` rguenth at gcc dot gnu.org
@ 2022-01-24 14:33 ` ppalka at gcc dot gnu.org
2022-01-24 16:48 ` cvs-commit at gcc dot gnu.org
2022-01-24 16:48 ` ppalka at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-01-24 14:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104197
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/104197] [12 Regression] clang: gcc/cp/pt.cc:28481:19: warning: predefined identifier is only valid inside function [-Wpredefined-identifier-outside-function]
2022-01-24 7:59 [Bug c++/104197] New: clang: gcc/cp/pt.cc:28481:19: warning: predefined identifier is only valid inside function [-Wpredefined-identifier-outside-function] marxin at gcc dot gnu.org
` (6 preceding siblings ...)
2022-01-24 14:33 ` ppalka at gcc dot gnu.org
@ 2022-01-24 16:48 ` cvs-commit at gcc dot gnu.org
2022-01-24 16:48 ` ppalka at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-24 16:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104197
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:b1aa2a3cf1ba233ccd5a49fde85a2ca7e5f620e9
commit r12-6847-gb1aa2a3cf1ba233ccd5a49fde85a2ca7e5f620e9
Author: Patrick Palka <ppalka@redhat.com>
Date: Mon Jan 24 11:47:13 2022 -0500
c++: Fix non-portable default argument of make_auto_1 [PR104197]
Avoid using the macro current_template_depth, which expands to an
expression that uses __FUNCTION__, within the signature of a function.
PR c++/104197
gcc/cp/ChangeLog:
* pt.cc (make_auto_1): Use -1 as a placeholder default argument
for level.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/104197] [12 Regression] clang: gcc/cp/pt.cc:28481:19: warning: predefined identifier is only valid inside function [-Wpredefined-identifier-outside-function]
2022-01-24 7:59 [Bug c++/104197] New: clang: gcc/cp/pt.cc:28481:19: warning: predefined identifier is only valid inside function [-Wpredefined-identifier-outside-function] marxin at gcc dot gnu.org
` (7 preceding siblings ...)
2022-01-24 16:48 ` cvs-commit at gcc dot gnu.org
@ 2022-01-24 16:48 ` ppalka at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-01-24 16:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104197
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-01-24 16:48 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-24 7:59 [Bug c++/104197] New: clang: gcc/cp/pt.cc:28481:19: warning: predefined identifier is only valid inside function [-Wpredefined-identifier-outside-function] marxin at gcc dot gnu.org
2022-01-24 8:20 ` [Bug c++/104197] " pinskia at gcc dot gnu.org
2022-01-24 8:23 ` pinskia at gcc dot gnu.org
2022-01-24 8:23 ` [Bug c++/104197] [12 Regression] " pinskia at gcc dot gnu.org
2022-01-24 8:30 ` pinskia at gcc dot gnu.org
2022-01-24 8:32 ` pinskia at gcc dot gnu.org
2022-01-24 9:25 ` rguenth at gcc dot gnu.org
2022-01-24 14:33 ` ppalka at gcc dot gnu.org
2022-01-24 16:48 ` cvs-commit at gcc dot gnu.org
2022-01-24 16:48 ` ppalka at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).