[Bug c++/111790] New: Unwarranted missing template keyword warning

2023-10-12 Thread t.bartels--- via 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.bart...@tu-berlin.de
  Target Milestone: ---

Consider the following code:

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

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

int main() {
f(); //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.

[Bug c++/111790] Unwarranted missing template keyword warning

2023-10-12 Thread t.bartels--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111790

--- Comment #1 from Tinko Sebastian Bartels  ---
A command line that can trigger the behavior is

g++ main.cpp

One of the versions for which it occurs is

g++ -v
Es werden eingebaute Spezifikationen verwendet.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/lto-wrapper
Ziel: x86_64-pc-linux-gnu
Konfiguriert mit: /build/gcc/src/gcc/configure
--enable-languages=ada,c,c++,d,fortran,go,lto,objc,obj-c++ --enable-bootstrap
--prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--with-build-config=bootstrap-lto --with-linker-hash-style=gnu
--with-system-zlib --enable-__cxa_atexit --enable-cet=auto
--enable-checking=release --enable-clocale=gnu --enable-default-pie
--enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object
--enable-libstdcxx-backtrace --enable-link-serialization=1
--enable-linker-build-id --enable-lto --enable-multilib --enable-plugin
--enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-werror
Thread-Modell: posix
Unterstützte LTO-Kompressionsalgorithmen: zlib zstd
gcc-Version 13.2.1 20230801 (GCC)