[PATCH] D52248: [SEMA] ignore duplicate declaration specifiers from typeof exprs

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 18 14:06:03 PDT 2018


nickdesaulniers created this revision.
nickdesaulniers added reviewers: srhines, gbiv.
Herald added a reviewer: george.burgess.iv.
Herald added a subscriber: cfe-commits.
nickdesaulniers removed a reviewer: gbiv.

Fixes PR32985.


Repository:
  rC Clang

https://reviews.llvm.org/D52248

Files:
  lib/Sema/SemaType.cpp
  test/Sema/gnu89.c


Index: test/Sema/gnu89.c
===================================================================
--- test/Sema/gnu89.c
+++ test/Sema/gnu89.c
@@ -3,3 +3,8 @@
 int f(int restrict);
 
 void main() {} // expected-warning {{return type of 'main' is not 'int'}} expected-note {{change return type to 'int'}}
+
+// Do not warn about duplicate const declaration specifier as the result of
+// typeof in gnu89.
+const int c_i;
+const typeof(c_i) c_i3; // expected-warning {{extension used}}
Index: lib/Sema/SemaType.cpp
===================================================================
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1680,7 +1680,9 @@
     // than once in the same specifier-list or qualifier-list, either directly
     // or via one or more typedefs."
     if (!S.getLangOpts().C99 && !S.getLangOpts().CPlusPlus
-        && TypeQuals & Result.getCVRQualifiers()) {
+        && TypeQuals & Result.getCVRQualifiers() &&
+        !S.getLangOpts().GNUMode &&
+        DS.getTypeSpecType() != DeclSpec::TST_typeofExpr) {
       if (TypeQuals & DeclSpec::TQ_const && Result.isConstQualified()) {
         S.Diag(DS.getConstSpecLoc(), diag::ext_duplicate_declspec)
           << "const";


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52248.166034.patch
Type: text/x-patch
Size: 1196 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180918/57497d1a/attachment.bin>


More information about the cfe-commits mailing list