Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHannes Vogt2019-09-13 16:09:45 -0400
committerNathan Ridge2019-09-24 01:03:27 -0400
commitaee38fb062025cf9d0d74c0d4f69bd05f064805c (patch)
treedcc125cea5d17d7884dcc3739c95c7d803811159 /core/org.eclipse.cdt.core/parser/org/eclipse/cdt
parentcf7e1f87c9b0a258c48b4fb3063d2aa4c37111fd (diff)
downloadorg.eclipse.cdt-aee38fb062025cf9d0d74c0d4f69bd05f064805c.tar.gz
org.eclipse.cdt-aee38fb062025cf9d0d74c0d4f69bd05f064805c.tar.xz
org.eclipse.cdt-aee38fb062025cf9d0d74c0d4f69bd05f064805c.zip
Bug 549036 - Init Type(std::initializer_list) from Type{...}
Fix constructor calls of the form Type{...} to a constructor of the form Type(std::initializer_list<T>). So far only Type({...}) was supported. Change-Id: I09e3b8c9c73c30e12c0c370a5c88885079a14746 Signed-off-by: Hannes Vogt <hannes@havogt.de>
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org/eclipse/cdt')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java
index 85bd7612c1..291a175a59 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java
@@ -300,8 +300,17 @@ public class EvalTypeId extends CPPDependentEvaluation {
ICPPClassType classType = (ICPPClassType) simplifiedType;
ICPPEvaluation[] arguments = fArguments;
ICPPConstructor[] constructors = classType.getConstructors();
- if (arguments.length == 1 && arguments[0] instanceof EvalInitList && !fUsesBracedInitList) {
+ if (fUsesBracedInitList && arguments.length > 0) {
// List-initialization of a class (dcl.init.list-3).
+ // e.g. A{1,2}
+ ICPPConstructor[] ctors = getInitializerListConstructors(constructors);
+ if (ctors.length != 0) {
+ constructors = ctors;
+ arguments = new EvalInitList[] { new EvalInitList(arguments, getTemplateDefinition()) };
+ }
+ } else if (arguments.length == 1 && arguments[0] instanceof EvalInitList && !fUsesBracedInitList) {
+ // List-initialization of a class (dcl.init.list-3).
+ // e.g. A({1,2})
if (TypeTraits.isAggregateClass(classType)) {
// Pretend that aggregate initialization is calling the default constructor.
return findDefaultConstructor(classType, constructors);

Back to the top