public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-8173] c++: unsigned int32_t enum promotion [PR102804]
@ 2022-04-15  1:55 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2022-04-15  1:55 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e580f81d22d61153564959f08d9a6d3bcc7fd386

commit r12-8173-ge580f81d22d61153564959f08d9a6d3bcc7fd386
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Apr 14 17:49:47 2022 -0400

    c++: unsigned int32_t enum promotion [PR102804]
    
    There's been an extension for a long time to allow applying 'unsigned' to an
    int typedef, but that was confusing the integer promotion code.  Fixed by
    forgetting about the typedef in that case.
    
    I'm going to make this an unconditional pedwarn in stage 1.
    
            PR c++/102804
    
    gcc/cp/ChangeLog:
    
            * decl.cc (grokdeclarator): Drop typedef used with 'unsigned'.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/ext/unsigned-typedef1.C: New test.

Diff:
---
 gcc/cp/decl.cc                               | 2 ++
 gcc/testsuite/g++.dg/ext/unsigned-typedef1.C | 9 +++++++++
 2 files changed, 11 insertions(+)

diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index d51fd75b003..2852093d624 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -12243,6 +12243,8 @@ grokdeclarator (const cp_declarator *declarator,
 	      pedwarn (loc, OPT_Wpedantic, "%qs specified with %qT",
 		       key, type);
 	      ok = !flag_pedantic_errors;
+	      type = DECL_ORIGINAL_TYPE (typedef_decl);
+	      typedef_decl = NULL_TREE;
 	    }
 	  else if (declspecs->decltype_p)
 	    error_at (loc, "%qs specified with %<decltype%>", key);
diff --git a/gcc/testsuite/g++.dg/ext/unsigned-typedef1.C b/gcc/testsuite/g++.dg/ext/unsigned-typedef1.C
new file mode 100644
index 00000000000..360b5f81edf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/unsigned-typedef1.C
@@ -0,0 +1,9 @@
+// PR c++/102804
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wpedantic" }
+
+using int32_t = int;
+enum: unsigned int32_t { foo };	// { dg-warning "int32_t" }
+int f(int) = delete;
+int f(unsigned);
+auto x = f(1 ? foo : 1);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-15  1:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-15  1:55 [gcc r12-8173] c++: unsigned int32_t enum promotion [PR102804] Jason Merrill

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).