[llvm-branch-commits] [cfe-branch] r325104 - Merging r323998:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Feb 14 01:06:43 PST 2018
Author: hans
Date: Wed Feb 14 01:06:43 2018
New Revision: 325104
URL: http://llvm.org/viewvc/llvm-project?rev=325104&view=rev
Log:
Merging r323998:
------------------------------------------------------------------------
r323998 | rsmith | 2018-02-01 21:01:49 +0100 (Thu, 01 Feb 2018) | 5 lines
PR36157: When injecting an implicit function declaration in C89, find the right
DeclContext rather than injecting it wherever we happen to be.
This avoids creating functions whose DeclContext is a struct or similar.
------------------------------------------------------------------------
Added:
cfe/branches/release_60/test/Sema/cxx-as-c.c
- copied unchanged from r323998, cfe/trunk/test/Sema/cxx-as-c.c
Modified:
cfe/branches/release_60/ (props changed)
cfe/branches/release_60/lib/Sema/SemaDecl.cpp
cfe/branches/release_60/test/Sema/bitfield.c
Propchange: cfe/branches/release_60/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Feb 14 01:06:43 2018
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:321754,321771,321777,321779,321933,322018,322236,322245-322246,322350,322390,322405,322420,322518,322593,322813,322901,322904,322984,323008,323123,323155,323360,323485,323904,323935,324059,324134,324246,324419,324439,324514,324537,324594
+/cfe/trunk:321754,321771,321777,321779,321933,322018,322236,322245-322246,322350,322390,322405,322420,322518,322593,322813,322901,322904,322984,323008,323123,323155,323360,323485,323904,323935,323998,324059,324134,324246,324419,324439,324514,324537,324594
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_60/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_60/lib/Sema/SemaDecl.cpp?rev=325104&r1=325103&r2=325104&view=diff
==============================================================================
--- cfe/branches/release_60/lib/Sema/SemaDecl.cpp (original)
+++ cfe/branches/release_60/lib/Sema/SemaDecl.cpp Wed Feb 14 01:06:43 2018
@@ -12507,10 +12507,20 @@ void Sema::ActOnFinishDelayedAttribute(S
/// call, forming a call to an implicitly defined function (per C99 6.5.1p2).
NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc,
IdentifierInfo &II, Scope *S) {
+ // Find the scope in which the identifier is injected and the corresponding
+ // DeclContext.
+ // FIXME: C89 does not say what happens if there is no enclosing block scope.
+ // In that case, we inject the declaration into the translation unit scope
+ // instead.
Scope *BlockScope = S;
while (!BlockScope->isCompoundStmtScope() && BlockScope->getParent())
BlockScope = BlockScope->getParent();
+ Scope *ContextScope = BlockScope;
+ while (!ContextScope->getEntity())
+ ContextScope = ContextScope->getParent();
+ ContextRAII SavedContext(*this, ContextScope->getEntity());
+
// Before we produce a declaration for an implicitly defined
// function, see whether there was a locally-scoped declaration of
// this name as a function or variable. If so, use that
Modified: cfe/branches/release_60/test/Sema/bitfield.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_60/test/Sema/bitfield.c?rev=325104&r1=325103&r2=325104&view=diff
==============================================================================
--- cfe/branches/release_60/test/Sema/bitfield.c (original)
+++ cfe/branches/release_60/test/Sema/bitfield.c Wed Feb 14 01:06:43 2018
@@ -82,3 +82,7 @@ typedef __typeof__(+(t5.n--)) Unsigned;
struct Test6 {
: 0.0; // expected-error{{type name requires a specifier or qualifier}}
};
+
+struct PR36157 {
+ int n : 1 ? 1 : implicitly_declare_function(); // expected-warning {{invalid in C99}}
+};
More information about the llvm-branch-commits
mailing list