public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111790] New: Unwarranted missing template keyword warning
@ 2023-10-12 16:37 t.bartels@tu-berlin.de
  2023-10-12 16:42 ` [Bug c++/111790] " t.bartels@tu-berlin.de
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: t.bartels@tu-berlin.de @ 2023-10-12 16:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111790

            Bug ID: 111790
           Summary: Unwarranted missing template keyword warning
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: t.bartels@tu-berlin.de
  Target Milestone: ---

Consider the following code:

template <typename T> //no warning if this is not a template
struct X
{
    T v;
};

template <typename T>
inline void f() {
    X<T> x; //no warning with e.g. X<int>
    if(x.v < 0 && 
       0 > -1) {} //No warning without the "-"
}

int main() {
    f<int>(); //Still get a warning without this instantiation.
}

GCC 12, 13, current trunk and seemingly everything after b8ffa71e427 give me a
warning for this:
warning: expected 'template' keyword before dependent template name
[-Wmissing-template-keyword]

But GCC compiles it, so it seems to interpret it correctly at some point after
triggering the warning. I tried to look into it and thought that maybe 

cp_lexer_peek_token (parser->lexer)->type
              <= CPP_LAST_PUNCTUATOR

in line 6447 of gcc/cp/parser.cc is too general but I do not have a proposed
patch.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-07 21:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-12 16:37 [Bug c++/111790] New: Unwarranted missing template keyword warning t.bartels@tu-berlin.de
2023-10-12 16:42 ` [Bug c++/111790] " t.bartels@tu-berlin.de
2023-10-16 23:29 ` [Bug c++/111790] [12/13/14 Regression] " ppalka at gcc dot gnu.org
2024-02-01 23:25 ` mpolacek at gcc dot gnu.org
2024-03-07 21:05 ` law 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).