Index: lib/Sema/SemaType.cpp =================================================================== --- lib/Sema/SemaType.cpp +++ lib/Sema/SemaType.cpp @@ -1679,8 +1679,9 @@ // C90 6.5.3 constraints: "The same type qualifier shall not appear more // 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()) { + if (!S.getLangOpts().C99 && !S.getLangOpts().CPlusPlus && + 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"; 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}}